Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

chore(audit-log): trim comments and the __proto__ test

Vlad Ligaieb08b153a044
diff --git a/backend/src/lib/validator/log-safe-text.test.ts b/backend/src/lib/validator/log-safe-text.test.ts
index bee8397e7e..f2ec825a3f 100644
--- a/backend/src/lib/validator/log-safe-text.test.ts
+++ b/backend/src/lib/validator/log-safe-text.test.ts
@@ -111,21 +111,14 @@ describe("sanitizeLogPayload", () => {
});
test("keeps a key of __proto__ as an own property", () => {
- // Plain assignment hits the inherited setter and the field never reaches the stored record.
- // Computed keys, because the literal form would set the prototype as the object is built.
- const sanitized = sanitizeLogPayload({
- ["__proto__"]: { sub: `a${NUL}b` },
- [`__pro${ZWSP}to__`]: "second",
- ok: 1
- }) as Record<string, unknown>;
+ // Computed keys: the literal form would set the prototype as the object is built.
+ const sanitized = sanitizeLogPayload({ ["__proto__"]: { sub: `a${NUL}b` }, [`__pro${ZWSP}to__`]: "second" });
const roundTripped = JSON.parse(JSON.stringify(sanitized)) as Record<string, unknown>;
- const entry = (key: string) => Object.entries(roundTripped).find(([name]) => name === key)?.[1];
+ const value = (key: string) => Object.entries(roundTripped).find(([name]) => name === key)?.[1];
- expect(Object.keys(roundTripped).sort()).toEqual(["__proto__", "__proto__~2", "ok"]);
- expect(entry("__proto__")).toEqual({ sub: "ab" });
- expect(entry("__proto__~2")).toBe("second");
- expect(roundTripped.ok).toBe(1);
+ expect(value("__proto__")).toEqual({ sub: "ab" });
+ expect(value("__proto__~2")).toBe("second");
});
test("whitespace controls collapse to a single space, preserving word boundaries", () => {
diff --git a/backend/src/lib/validator/log-safe-text.ts b/backend/src/lib/validator/log-safe-text.ts
index 5d4439bafc..c3a2fa41a3 100644
--- a/backend/src/lib/validator/log-safe-text.ts
+++ b/backend/src/lib/validator/log-safe-text.ts
@@ -118,10 +118,8 @@ export const sanitizeLogPayload = <T>(payload: T): T => {
while (pending.length) {
const [source, target] = pending.pop()!;
- // defineProperty rather than assignment: a key of `__proto__` hits the inherited setter, which
- // sets the prototype instead of writing an own property and drops the field from the serialized
- // record. Metadata keys can come from a third party, since `oidcClaimsReceived` is whatever the
- // IdP returned.
+ // defineProperty, not assignment: a `__proto__` key hits the inherited setter and sets the
+ // prototype instead of writing a field. Metadata keys come from the IdP on OIDC login.
const put = (key: string | number, value: unknown) => {
Object.defineProperty(target, key, { value, enumerable: true, writable: true, configurable: true });
};
diff --git a/backend/src/server/lib/audit-safe-text-schema.test.ts b/backend/src/server/lib/audit-safe-text-schema.test.ts
index 21a6c22762..da23ed0a2f 100644
--- a/backend/src/server/lib/audit-safe-text-schema.test.ts
+++ b/backend/src/server/lib/audit-safe-text-schema.test.ts
@@ -77,8 +77,6 @@ describe("routes that feed audit metadata keep the wrapper", () => {
const source = read(file);
const wrapped = source.match(/reason: auditSafeText\(.*allowMultiline: true/g) ?? [];
- // The count is the guard: a wrapper dropped from a field, or the multiline flag flipped off,
- // takes it below the expected number.
expect(wrapped).toHaveLength(expected);
});
});