Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update cel parser (#20686)
ecmadaob01edd993b22
diff --git a/frontend/src/react/lib/sensitive-data/utils.test.ts b/frontend/src/react/lib/sensitive-data/utils.test.tsnew file mode 100644index 0000000000..de92389796--- /dev/null+++ b/frontend/src/react/lib/sensitive-data/utils.test.ts@@ -0,0 +1,43 @@+import { create } from "@bufbuild/protobuf";+import { describe, expect, test } from "vitest";+import { ExprSchema } from "@/types/proto-es/google/type/expr_pb";+import { MaskingExemptionPolicy_ExemptionSchema } from "@/types/proto-es/v1/org_policy_service_pb";+import type { SensitiveColumn } from "./types";+import { isCurrentColumnException } from "./utils";++const sensitiveColumn: SensitiveColumn = {+ database: {+ name: "instances/prod/databases/hr",+ } as SensitiveColumn["database"],+ maskData: {+ schema: "public",+ table: "employee",+ column: "email",+ semanticTypeId: "",+ classificationId: "",+ target: {} as SensitiveColumn["maskData"]["target"],+ },+};++const makeException = (expression: string) =>+ create(MaskingExemptionPolicy_ExemptionSchema, {+ condition: create(ExprSchema, { expression }),+ });++describe("isCurrentColumnException", () => {+ test("matches a parenthesized resource condition with expiration", () => {+ const exception = makeException(+ '(resource.instance_id == "prod" && resource.database_name == "hr" && resource.schema_name == "public" && resource.table_name == "employee" && resource.column_name == "email") && request.time < timestamp("2026-04-15T00:00:00Z")'+ );++ expect(isCurrentColumnException(exception, sensitiveColumn)).toBe(true);+ });++ test("matches a parenthesized resource condition with classification level", () => {+ const exception = makeException(+ '(resource.instance_id == "prod" && resource.database_name == "hr" && resource.schema_name == "public" && resource.table_name == "employee" && resource.column_name == "email") && resource.classification_level <= 2'+ );++ expect(isCurrentColumnException(exception, sensitiveColumn)).toBe(true);+ });+});diff --git a/frontend/src/react/lib/sensitive-data/utils.ts b/frontend/src/react/lib/sensitive-data/utils.tsindex 114690fdf6..3968b5b679 100644--- a/frontend/src/react/lib/sensitive-data/utils.ts+++ b/frontend/src/react/lib/sensitive-data/utils.ts@@ -34,14 +34,19 @@ export const isCurrentColumnException = (// no expression means can access all databases.return true;}- const databaseExpression = expression+ let databaseExpression = expression+ .trim().split(" && ").filter((expr) =>!expr.startsWith(CEL_ATTRIBUTE_REQUEST_TIME) &&!expr.startsWith(CEL_ATTRIBUTE_RESOURCE_CLASSIFICATION_LEVEL))- .join(" && ");+ .join(" && ")+ .trim();+ if (databaseExpression.startsWith("(") && databaseExpression.endsWith(")")) {+ databaseExpression = databaseExpression.slice(1, -1).trim();+ }const matches = getExpressionsForDatabaseResource(convertSensitiveColumnToDatabaseResource(sensitiveColumn));