Carries 359 template commits, tag v0.2.0 plus one documentation commit: the generator-built feature index with its app, bounded-context and feature declarations, the src/platform kernel and scale tooling, the 2026-09-24 src review fixes, and the 2026-09-25 maturity review round with its CHANGELOG [보안]/[계약] rows. 691 of the 824 template paths are applied, 85 of them merged with product changes; 127 are not carried. Product identity is unchanged: name, version 0.1.0, routes, design and the TechLog domain. Three decisions worth naming. TechLog stays composed directly, as the last two syncs recorded; its directory carries a NOT_INSTALLED marker that says so, and every installed-* composer takes the template's projection with TechLog added on top. The reference sample is no longer installed: the template now installs a feature only through feature-module.ts and context-routes.ts, which load the screens this product deleted, so its three operations, six schemas and one topic leave the registries, recorded as registry change evidence. And AppRouter mounts the platform and TechLog routes only; the template's bounded-context route gateway waits for a generator-installed feature. Required fixes: readSubject on the BFF session owner (without it every HTTP Studio session would close as integration-failed), zod through the facade in nine TechLog files, noUnusedLocals, and public/config.json written out to match the local profile. Derived baselines were recomputed after reproducing both sides' values: CI contract 101 commands / 106 references / 141 artifacts, gate shape c9adcf85; registry approval 2dc6c3a3; the runtime config schema baseline equals the schema at8210d48. Verified here: types, lint, architecture, adapter inventory, CI contract, i18n, design system, diagnostics, browser security, dev release manifest, TechLog contract and build pass; 220 component, 155 integration, 15 contract, 418 TechLog, 43 reference-feature, 18 recipe and 46 release-coherence tests pass, and 2381 of 2383 unit tests. Reproduced at8210d48first and unchanged: check:registries (byte-identical), test:runtime-schema, verify:documentation. Brought by the template and escalated rather than suppressed: check:request-fanout on TechLog's cursor pagination, check:remediation-ledger (fails upstream too), the shared-chunk hash test, and the registry-dependent sample removal and second-feature tests. Playwright suites were not run. Full record, the five open questions and the follow-ups in docs/operations/template-sync-2026-09-29.md. (cherry picked from commit b2170cf265dea45dc9cc05d3c61e627e97f31cdb)
191 lines
6.1 KiB
TypeScript
191 lines
6.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
DEFAULT_TELEMETRY_PAYLOAD_BUDGET,
|
|
REDACTED,
|
|
redactTelemetryPayload,
|
|
TRUNCATED,
|
|
} from "../../../src/platform/telemetry/redact-telemetry.ts";
|
|
|
|
describe("redactTelemetryPayload", () => {
|
|
it.each([
|
|
"password",
|
|
"authorization",
|
|
"cookie",
|
|
"accessToken",
|
|
"refreshToken",
|
|
"access_token",
|
|
"Set-Cookie",
|
|
"apiKey",
|
|
"clientSecret",
|
|
])("redacts %s recursively", (secretKey) => {
|
|
const input = { nested: { [secretKey]: "secret", safe: "ok" } };
|
|
const result = redactTelemetryPayload(input);
|
|
|
|
expect(JSON.stringify(result)).not.toContain("secret");
|
|
expect(result).toMatchObject({ nested: { safe: "ok" } });
|
|
});
|
|
|
|
it("redacts credential-shaped values under innocent keys", () => {
|
|
const result = redactTelemetryPayload({
|
|
note: "Bearer abc.def.ghi",
|
|
jwt: "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.sig",
|
|
list: ["Basic dXNlcjpwYXNz"],
|
|
});
|
|
expect(result).toEqual({ note: REDACTED, jwt: REDACTED, list: [REDACTED] });
|
|
});
|
|
|
|
it("keeps legitimate telemetry values and innocent keys untouched", () => {
|
|
const legitimate = {
|
|
reason: "REQUEST_TIMEOUT",
|
|
operation: "LIST_ORDER_ITEMS",
|
|
routeId: "orders.items.detail",
|
|
featureId: "order-feature",
|
|
resourceId: "01J8Z3K7Q9W4N2B6C5D1E0F7GH",
|
|
uuid: "3f2a9c1e-5b7d-4e8f-9a0b-1c2d3e4f5a6b",
|
|
traceHex: "4bf92f3577b34da6a3ce929d0e0e4736",
|
|
plan: "BASIC_PLAN",
|
|
dependency: "react@19.1.0",
|
|
path: "/api/resources?limit=20&cursor=c1#top",
|
|
message: "error code=REQUEST_TIMEOUT after 3 attempts",
|
|
status: 404,
|
|
durationMs: 12.5,
|
|
retried: false,
|
|
spinner: "visible",
|
|
author: "system",
|
|
compass: "north",
|
|
opinion: "none",
|
|
shipping: "standard",
|
|
isPinned: true,
|
|
code: "E_CONFLICT",
|
|
key: "sort-order",
|
|
};
|
|
expect(redactTelemetryPayload(legitimate)).toEqual(legitimate);
|
|
});
|
|
|
|
it.each([
|
|
"pwd",
|
|
"pass",
|
|
"auth",
|
|
"otp",
|
|
"pin",
|
|
"userPwd",
|
|
"pin_code",
|
|
"PINCode",
|
|
"x-otp",
|
|
"authHeader",
|
|
"passcode",
|
|
])("redacts the short secret key %s as a whole key token", (secretKey) => {
|
|
const result = redactTelemetryPayload({ [secretKey]: "s3cr3t", safe: "ok" });
|
|
expect(result).toEqual({ safe: "ok" });
|
|
});
|
|
|
|
it("redacts credentials in the middle of a string", () => {
|
|
expect(
|
|
redactTelemetryPayload({
|
|
header: "request failed: Authorization: Bearer abc",
|
|
basic: "proxy said Basic dXNlcjpwYXNz was rejected",
|
|
jwt: "retry with eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.c2lnbmF0dXJl now",
|
|
}),
|
|
).toEqual({
|
|
header: `request failed: Authorization: ${REDACTED}`,
|
|
basic: `proxy said ${REDACTED} was rejected`,
|
|
jwt: `retry with ${REDACTED} now`,
|
|
});
|
|
});
|
|
|
|
it("masks secret URL query and fragment parameters", () => {
|
|
expect(
|
|
redactTelemetryPayload(
|
|
"GET https://api.example.com/cb?code=abc123&state=xyz&access_token=tok456&key=k1#id_token=jwt789",
|
|
),
|
|
).toBe(
|
|
`GET https://api.example.com/cb?code=${REDACTED}&state=xyz&access_token=${REDACTED}&key=${REDACTED}#id_token=${REDACTED}`,
|
|
);
|
|
expect(redactTelemetryPayload("/login?user=a&password=hunter2&otp=123456")).toBe(
|
|
`/login?user=a&password=${REDACTED}&otp=${REDACTED}`,
|
|
);
|
|
});
|
|
|
|
it("masks email addresses", () => {
|
|
expect(
|
|
redactTelemetryPayload({ note: "invite failed for jane.doe+test@example.co.uk twice" }),
|
|
).toEqual({ note: `invite failed for ${REDACTED} twice` });
|
|
});
|
|
|
|
it("does not leak a secret cut in half by truncation", () => {
|
|
const budget = { ...DEFAULT_TELEMETRY_PAYLOAD_BUDGET, maxStringLength: 32 };
|
|
const cut = redactTelemetryPayload(
|
|
{
|
|
email: `${"x".repeat(20)} jane.doe@example.com`,
|
|
query: `/cb${"x".repeat(10)}?access_token=abcdefghijklmnopqrstuvwxyz`,
|
|
bearer: `${"x".repeat(20)} Bearer abcdefghijklmnopqrstuvwxyz`,
|
|
},
|
|
budget,
|
|
);
|
|
expect(JSON.stringify(cut)).not.toMatch(/jane|abcd/u);
|
|
expect(JSON.stringify(cut)).toContain(TRUNCATED);
|
|
});
|
|
|
|
it("never invokes getters, toJSON or foreign prototypes", () => {
|
|
let invoked = false;
|
|
class Carrier {
|
|
visible = "kept";
|
|
toJSON() {
|
|
invoked = true;
|
|
return { leaked: true };
|
|
}
|
|
}
|
|
const hostile = Object.defineProperty(new Carrier(), "computed", {
|
|
enumerable: true,
|
|
get() {
|
|
invoked = true;
|
|
return "computed";
|
|
},
|
|
});
|
|
|
|
const result = redactTelemetryPayload({ hostile });
|
|
|
|
expect(invoked).toBe(false);
|
|
expect(result).toEqual({ hostile: { visible: "kept" } });
|
|
expect(Object.getPrototypeOf((result as { hostile: object }).hostile)).toBe(
|
|
Object.prototype,
|
|
);
|
|
});
|
|
|
|
it("bounds depth, width, array length and string length", () => {
|
|
let deep: unknown = "leaf";
|
|
for (let depth = 0; depth < 50; depth += 1) deep = { next: deep };
|
|
const wide = Object.fromEntries(
|
|
Array.from({ length: 500 }, (_, index) => [`k${index}`, index]),
|
|
);
|
|
const result = redactTelemetryPayload(
|
|
{ deep, wide, list: Array.from({ length: 1_000 }, (_, i) => i), text: "x".repeat(5_000) },
|
|
{ maxDepth: 4, maxKeys: 10, maxArrayItems: 5, maxStringLength: 16 },
|
|
) as Record<string, unknown>;
|
|
|
|
expect(JSON.stringify(result)).toContain(TRUNCATED);
|
|
expect(Object.keys(result["wide"] as object).length).toBeLessThanOrEqual(10);
|
|
expect(result["list"]).toHaveLength(5);
|
|
expect((result["text"] as string).length).toBeLessThanOrEqual(16 + TRUNCATED.length);
|
|
});
|
|
|
|
it("does not let prototype keys pollute the copy", () => {
|
|
const payload = JSON.parse('{"__proto__":{"polluted":true},"ok":1}') as unknown;
|
|
const result = redactTelemetryPayload(payload) as Record<string, unknown>;
|
|
expect(result).toEqual({ ok: 1 });
|
|
expect(({} as Record<string, unknown>)["polluted"]).toBeUndefined();
|
|
});
|
|
|
|
it("normalizes non-JSON leaves", () => {
|
|
expect(
|
|
redactTelemetryPayload({
|
|
n: Number.NaN,
|
|
f: () => 1,
|
|
u: undefined,
|
|
b: 10n,
|
|
}),
|
|
).toEqual({ n: null, f: null, u: null, b: null });
|
|
});
|
|
});
|