mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-10 22:20:14 +00:00
fix(core,producer): redact bare relative paths and the known input path
The generic scrub still missed a relative path with no `./` prefix: `customer/acme-secret/video.mp4` and `assets/bgm.mp3` reached telemetry completely unredacted, because the absolute rule needs a leading slash and the `./` rule needs the dot. Adds a rule for them that still leaves `N/A`, `24/1` and `48000/1001` alone. Shape matching is a net with holes by construction, so audioPadTrim now also redacts the exact path it put in the argv, plus its basename, before the generic scrub runs. It built the argv, so it does not have to guess. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d04569e37f
commit
e79ab3ab31
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { redactTelemetryString } from "./telemetryRedaction.js";
|
||||
import { redactKnownPaths, redactTelemetryString } from "./telemetryRedaction.js";
|
||||
|
||||
describe("redactTelemetryString", () => {
|
||||
it("redacts macOS, Linux, Windows, file URLs, and URL query strings", () => {
|
||||
@@ -65,4 +65,52 @@ describe("redactTelemetryString", () => {
|
||||
const out = redactTelemetryString(`/data/${"x".repeat(500)}/a.mp4`, 40);
|
||||
expect(out).not.toContain("xxx");
|
||||
});
|
||||
|
||||
// Named explicitly in review: a relative path with NO `./` prefix was
|
||||
// missed by both the absolute rule (needs a leading slash) and the `./`
|
||||
// rule (needs the dot), so it reached telemetry completely unredacted.
|
||||
it.each([
|
||||
"customer/acme-secret/video.mp4",
|
||||
"assets/bgm.mp3",
|
||||
"projects/client-name/cut/final.mov",
|
||||
"a\\b\\c.wav",
|
||||
])("redacts the bare relative path %s", (path) => {
|
||||
const out = redactTelemetryString(`Invalid data found when processing ${path}`);
|
||||
expect(out).toBe("Invalid data found when processing [path]");
|
||||
});
|
||||
|
||||
it("redacts a dash-prefixed bare basename", () => {
|
||||
expect(redactTelemetryString("could not open -customer-secret-intro.mp4")).toBe(
|
||||
"could not open [file]",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("redactKnownPaths", () => {
|
||||
// Shape matching has holes by construction. A caller that built the argv
|
||||
// knows the exact path, so it can name it instead of hoping a regex does.
|
||||
it("redacts an exact path a regex would not recognise as one", () => {
|
||||
const weird = "acme_secret_project";
|
||||
expect(redactKnownPaths(`ffprobe: ${weird}: Invalid data`, [weird])).toBe(
|
||||
"ffprobe: [path]: Invalid data",
|
||||
);
|
||||
});
|
||||
|
||||
it("redacts the basename too — ffprobe often reports only that", () => {
|
||||
const out = redactKnownPaths("moov atom not found in secret-cut.mp4", [
|
||||
"/data/x/secret-cut.mp4",
|
||||
]);
|
||||
expect(out).toContain("[path]");
|
||||
expect(out).not.toContain("secret-cut");
|
||||
});
|
||||
|
||||
it("leaves the message alone when no path was supplied", () => {
|
||||
expect(redactKnownPaths("moov atom not found", [])).toBe("moov atom not found");
|
||||
});
|
||||
|
||||
// Guards against a one/two-character basename turning every occurrence of
|
||||
// that letter into [path].
|
||||
it("ignores paths too short to be distinctive", () => {
|
||||
expect(redactKnownPaths("a stream at a rate", ["a"])).toBe("a stream at a rate");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user