Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: fix out of bounds (#16912)
rebeliceabd9d3265ac1
diff --git a/backend/plugin/db/pg/query.go b/backend/plugin/db/pg/query.goindex e011f0cf66..a98c52c2a1 100644--- a/backend/plugin/db/pg/query.go+++ b/backend/plugin/db/pg/query.go@@ -165,6 +165,12 @@ func padZeroes(rawStr string, acc int) string {} else if minusIndex := strings.Index(rawStr, "-"); minusIndex >= 0 {endIndex = minusIndex}++ // Validate slice bounds to prevent runtime panic+ if endIndex <= dotIndex {+ return rawStr+ }+decimalPart := rawStr[dotIndex+1 : endIndex]if len(decimalPart) < acc {rawStr = rawStr[:endIndex] + strings.Repeat("0", acc-len(decimalPart)) + rawStr[endIndex:]diff --git a/backend/plugin/db/pg/query_test.go b/backend/plugin/db/pg/query_test.goindex 3ffe0c9a46..3769aba0a8 100644--- a/backend/plugin/db/pg/query_test.go+++ b/backend/plugin/db/pg/query_test.go@@ -49,6 +49,12 @@ func TestPadZeroes(t *testing.T) {acc: 6,expected: "12:34:56.123000-02:00",},+ {+ name: "Invalid format: timezone before decimal (edge case fix)",+ rawStr: "12:34-05:56.123",+ acc: 6,+ expected: "12:34-05:56.123",+ },}for _, test := range tests {