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(cosmosdb): retain source paths for unnamed VALUE expressions (#19677)
h3n4l116ad509879b
diff --git a/backend/api/v1/catalog_masking_cosmosdb_test.go b/backend/api/v1/catalog_masking_cosmosdb_test.goindex fb562e48de..c0688c891e 100644--- a/backend/api/v1/catalog_masking_cosmosdb_test.go+++ b/backend/api/v1/catalog_masking_cosmosdb_test.go@@ -381,6 +381,54 @@ func TestCosmosDBMaskingValueCount(t *testing.T) {require.Equal(t, `42`, row.Values[0].GetStringValue())}+func TestCosmosDBMaskingValueConcatSensitive(t *testing.T) {+ // SELECT VALUE CONCAT(c.name, " <", c.email, ">") -- no alias, expression has sensitive c.email.+ // The expression has no output name, but source paths must still be tracked so+ // findMaskerForScalarValue can detect that c.email is sensitive and mask the result.+ schema := cosmosDBTestSchema()+ maskers := cosmosDBMaskers()+ query := `SELECT VALUE CONCAT(c.name, " <", c.email, ">") FROM container c`+ span := getCosmosDBQuerySpan(t, query)++ row := &v1pb.QueryRow{+ Values: []*v1pb.RowValue{+ {Kind: &v1pb.RowValue_StringValue{StringValue: `"Alice <[email protected]>"`}},+ },+ }+ result := &v1pb.QueryResult{+ ColumnNames: []string{"result"},+ ColumnTypeNames: []string{"TEXT"},+ Rows: []*v1pb.QueryRow{row},+ }++ err := maskCosmosDBResultsForTest(span, []*v1pb.QueryResult{result}, schema, maskers)+ require.NoError(t, err)+ require.Equal(t, `"******"`, row.Values[0].GetStringValue())+}++func TestCosmosDBMaskingValueConcatNonSensitive(t *testing.T) {+ // SELECT VALUE CONCAT(c.name, " - ", c.country) -- no alias, no sensitive fields.+ schema := cosmosDBTestSchema()+ maskers := cosmosDBMaskers()+ query := `SELECT VALUE CONCAT(c.name, " - ", c.country) FROM container c`+ span := getCosmosDBQuerySpan(t, query)++ row := &v1pb.QueryRow{+ Values: []*v1pb.RowValue{+ {Kind: &v1pb.RowValue_StringValue{StringValue: `"Alice - US"`}},+ },+ }+ result := &v1pb.QueryResult{+ ColumnNames: []string{"result"},+ ColumnTypeNames: []string{"TEXT"},+ Rows: []*v1pb.QueryRow{row},+ }++ err := maskCosmosDBResultsForTest(span, []*v1pb.QueryResult{result}, schema, maskers)+ require.NoError(t, err)+ require.Equal(t, `"Alice - US"`, row.Values[0].GetStringValue())+}+// ---------------------------------------------------------------------------// Test: Expression projections// ---------------------------------------------------------------------------diff --git a/backend/plugin/parser/cosmosdb/query_span.go b/backend/plugin/parser/cosmosdb/query_span.goindex 4d54616d4e..e54ab8ddc1 100644--- a/backend/plugin/parser/cosmosdb/query_span.go+++ b/backend/plugin/parser/cosmosdb/query_span.go@@ -78,9 +78,8 @@ func (l *querySpanResultListener) EnterSelect(ctx *parser.SelectContext) {sourceFieldPaths := make(map[string][]*base.PathAST)for _, property := range ctx.Select_clause().Select_specification().Object_property_list().AllObject_property() {paths, name := extractPathsFromObjectProperty(property, containerName, fromAlias)- if name == "" {- continue- }+ // For VALUE expressions without an alias (e.g., SELECT VALUE CONCAT(c.name, c.email) FROM c),+ // the name is empty but we still store paths so scalar masking can detect sensitive fields.for _, path := range paths {if len(path) == 0 {continue