Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: masking exemption filter (#21730)

ecmadao6fe7067f1593
diff --git a/frontend/src/routes/project/utils/maskingExemption.test.ts b/frontend/src/routes/project/utils/maskingExemption.test.ts
index bf0a80492a..24e39b796b 100644
--- a/frontend/src/routes/project/utils/maskingExemption.test.ts
+++ b/frontend/src/routes/project/utils/maskingExemption.test.ts
@@ -49,6 +49,19 @@ describe("generateMemberScopeSummary", () => {
});
describe("resourceCoversDatabase", () => {
+ test("matches a parsed database scope on a project instance", () => {
+ expect(
+ resourceCoversDatabase(
+ {
+ databaseFullName: "instances/prod/databases/hr",
+ instanceResourceId: "prod",
+ databaseResourceId: "hr",
+ },
+ "projects/payroll/instances/prod/databases/hr"
+ )
+ ).toBe(true);
+ });
+
test("matches global and instance-scoped resources", () => {
expect(
resourceCoversDatabase(
diff --git a/frontend/src/routes/project/utils/maskingExemption.ts b/frontend/src/routes/project/utils/maskingExemption.ts
index 3bb4534db0..7b853ac5df 100644
--- a/frontend/src/routes/project/utils/maskingExemption.ts
+++ b/frontend/src/routes/project/utils/maskingExemption.ts
@@ -7,16 +7,18 @@ export const resourceCoversDatabase = (
resource: DatabaseResource,
databaseFullName: string
): boolean => {
- if (resource.databaseFullName) {
- return resource.databaseFullName === databaseFullName;
- }
const { instanceName, databaseName } =
extractDatabaseResourceName(databaseFullName);
+ if (resource.instanceResourceId || resource.databaseResourceId) {
+ return (
+ (!resource.instanceResourceId ||
+ resource.instanceResourceId === instanceName) &&
+ (!resource.databaseResourceId ||
+ resource.databaseResourceId === databaseName)
+ );
+ }
return (
- (!resource.instanceResourceId ||
- resource.instanceResourceId === instanceName) &&
- (!resource.databaseResourceId ||
- resource.databaseResourceId === databaseName)
+ !resource.databaseFullName || resource.databaseFullName === databaseFullName
);
};
diff --git a/frontend/tests/e2e/masking-exemption/masking-exemption.spec.ts b/frontend/tests/e2e/masking-exemption/masking-exemption.spec.ts
index 4d8761aadb..c4d61c3839 100644
--- a/frontend/tests/e2e/masking-exemption/masking-exemption.spec.ts
+++ b/frontend/tests/e2e/masking-exemption/masking-exemption.spec.ts
@@ -764,11 +764,6 @@ test.describe("Filtering by database keeps every exemption written for it (K2)",
});
test("the database's own exemption stays and another database's goes", async () => {
- // The suite's sample instance is project-owned, so the filter's value is
- // projects/<p>/instances/<i>/databases/<d>, while the parser names an
- // instance_id + database_name scope instances/<i>/databases/<d> and the
- // filter compares the two names exactly (BYT-10359).
- test.fail();
const listPage = new MaskingExemptionPage(page, env.baseURL);
await listPage.goto(projectId);
await expect(listPage.getMemberItem(DBA_EMAIL)).toBeVisible();