mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-24 16:06:34 +00:00
* perf(producer): distributed chunks download only the videos they show A project video under compiled/ that chunks extract their own frames from now goes only to the chunks that show it, like video-sources/ files. A chunk skips the readiness wait for a deferred video it does not show, so it no longer logs media_load_failed for a file it was never given. * fix(producer): cloud site uploads pack the files their id hashes, symlinks included * perf(aws-lambda): chunks read only the byte ranges of a video they need A chunk that extracts its own frames from a deferred project video now reads it from S3 by byte range through a short-lived pre-signed URL, instead of downloading and hashing the whole object first. S3 attests the object's stored SHA-256 before the URL is signed; every other artifact is still downloaded and verified as before. * perf(aws-lambda): upload project files once to a shared content-addressed area * chore(producer): keep planV2 comment share at the base level * fix(engine): verify the TLS certificate of https video inputs and never surface their signed query * fix(aws-lambda): renders re-upload a site's expired files instead of failing * perf(aws-lambda): the plan step probes project videos in place instead of downloading them * fix(engine): https video reads reconnect and time out, and redaction covers wrapped causes Signed-URL reads now pass -rw_timeout, -reconnect and -reconnect_delay_max (both Lambda builds accept them) and ffmpeg also -reconnect_on_network_error, so a transient S3 error or a stalled read fails fast or recovers instead of waiting out the process timeout. Query redaction now descends into error.cause. * fix(aws-lambda): share entry bundles and ratchet package budget * fix(aws-lambda): site ids uploaded before files.json still render A site id from an earlier sites create has only sites/<id>/project.tar.gz. renderToLambda now falls back to that tarball, which the plan step still reads, and when neither key exists it fails before starting with both keys named and the fix (run sites create again). * fix(aws-lambda): renders fail before upload on a stack too old to read sites A stack deployed before files.json sites untars the site file in its plan step and fails after four retries. renderToLambda now reads the state machine definition first and stops with STACK_TOO_OLD and the redeploy command when the plan task does not list SITE_MANIFEST_INVALID, which new SAM and CDK stacks now treat as terminal. The README's upgrade section drops the planProtocol v1 fallback, which hits the same failure. * docs(aws-lambda): document shared content storage and the upgrade path The deploy guide still described the tarball HeadObject short-circuit. It now covers the cas/sha256/ store and its 30-day lifecycle rule, the STACK_TOO_OLD, SITE_FILES_MISSING and SITE_NOT_FOUND errors, that old site ids keep working, and that every project uploads once more after the upgrade. A test keeps a troubleshooting entry for each pre-submit error. * fix(producer): chunks log each video they read by URL, without its query A chunk reading a video straight from the bucket left no trace in its log. It now logs one line per remote source with the path and the URL minus its query string, so signatures never reach the log. * fix(engine): ffmpeg errors never keep part of a signed URL's query A process's stderr tail was trimmed before its URLs were redacted, so a cut inside a signed URL left a query fragment the URL pattern no longer matched, and the fragment reached the error. The stderr tail is now redacted before every trim, and the redactor also strips a signing parameter cut off from its URL. * fix(aws-lambda): comments name the site manifest instead of a file path * fix(engine): stderr redaction survives chunk splits, and every ffmpeg spawn uses it The stderr tail was redacted on each chunk and then cut, so once a cut severed a long URL's scheme, the rest of its signature in the next chunk matched neither pattern. The tail is now kept raw with 2x slack and redacted only when the text is produced, then cut to size. The unused producer audioExtractor (its own spawn, unredacted stderr) is deleted and the parity harness's PCM decode goes through ManagedChildProcess; a test fails on any ffmpeg/ffprobe spawn in engine, producer or aws-lambda that does not. * chore(producer): record the audioExtractor deletion as intended * fix(engine): drop a signature fragment the stderr tail cut from its URL The raw tail is kept at twice the cap, but that cut can itself land inside a signature, and when redaction shrinks the rest below the cap the fragment survived. After a cut, the severed token is dropped before redaction. * refactor(engine): name the severed-token drop instead of commenting it * test(engine): a cut-off URL leaves nothing behind; aws-lambda size budget to measured * fix(producer): chunk URL-read tests use main's frame list; producer size budget to measured * chore(producer): size budget at the measured size, no headroom * chore(producer): size budget back to measured x1.05, the check's own rule
165 lines
6.6 KiB
TypeScript
165 lines
6.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { redactKnownPaths, redactTelemetryString } from "./telemetryRedaction.js";
|
|
|
|
describe("redactTelemetryString", () => {
|
|
it("redacts macOS, Linux, Windows, file URLs, and URL query strings", () => {
|
|
expect(
|
|
redactTelemetryString(
|
|
[
|
|
"/Users/alice/project/video.mp4",
|
|
"/home/ubuntu/project/video.mp4",
|
|
"/workspace/app/video.mp4",
|
|
"C:\\Users\\Alice\\project\\video.mp4",
|
|
"file:///tmp/render/video.mp4",
|
|
"https://example.com/video.mp4?token=secret",
|
|
].join(" "),
|
|
),
|
|
).toBe("[path] [path] [path] [path] [file-url] https://example.com/video.mp4?…");
|
|
});
|
|
|
|
it("redacts a signing parameter cut off from its URL", () => {
|
|
expect(
|
|
redactTelemetryString(
|
|
"z-Signature=supersecret&X-Amz-Credential=AKID x-goog-signature=abc -t 1",
|
|
),
|
|
).toBe("z-Signature=…&X-Amz-Credential=… x-goog-signature=… -t 1");
|
|
});
|
|
|
|
// The redactor used to enumerate roots (/Users, /home, /opt, /tmp, …). Any
|
|
// root outside that list reached telemetry verbatim, which is most of them.
|
|
it.each([
|
|
"/data/media/interview.mov",
|
|
"/mnt2/nfs/share/take3.wav",
|
|
"/srv2/renders/2026/final.mp4",
|
|
"/nix/store/abc123/asset.png",
|
|
])("redacts the non-allowlisted absolute root in %s", (path) => {
|
|
const out = redactTelemetryString(`ffprobe failed reading ${path}`);
|
|
expect(out).not.toContain("/");
|
|
expect(out).toContain("[path]");
|
|
});
|
|
|
|
it("redacts relative paths, including a dash-prefixed one", () => {
|
|
expect(redactTelemetryString("could not open ./assets/-weird-name.mp3")).toBe(
|
|
"could not open [path]",
|
|
);
|
|
expect(redactTelemetryString("could not open ../-out.wav")).toBe("could not open [path]");
|
|
expect(redactTelemetryString("could not open .\\tmp\\-x.aac")).toBe("could not open [path]");
|
|
});
|
|
|
|
it("redacts a bare basename — a caller may pass one instead of a path", () => {
|
|
expect(redactTelemetryString("Invalid data found in my-client-cut.mp4")).toBe(
|
|
"Invalid data found in [file]",
|
|
);
|
|
});
|
|
|
|
// Over-redaction is cheap; these are ordinary in ffprobe stderr and turning
|
|
// them into [path] would make a diagnostic string useless.
|
|
it.each(["N/A", "24/1", "Stream #0:0", "moov atom not found", "48000/1001"])(
|
|
"leaves %s alone",
|
|
(text) => {
|
|
expect(redactTelemetryString(`ffprobe: ${text}`)).toBe(`ffprobe: ${text}`);
|
|
},
|
|
);
|
|
|
|
// A `?` is illegal in a Windows filename, so this is not a query string —
|
|
// the whole token is path, and must not survive by hiding behind a `?`.
|
|
it("consumes the rest of the token once a path is established", () => {
|
|
expect(redactTelemetryString("Navigation failed for C:\\Users\\A\\v.mov?not-a-query")).toBe(
|
|
"Navigation failed for [path]",
|
|
);
|
|
});
|
|
|
|
it("truncates after redacting, so a long path cannot survive by being cut", () => {
|
|
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]",
|
|
);
|
|
});
|
|
});
|
|
|
|
// The segment classes were ASCII `\w`, so a non-Latin path went out verbatim.
|
|
// This redactor also feeds CLI telemetry and producer observation messages,
|
|
// where no known-path list is supplied to compensate.
|
|
describe("non-Latin paths", () => {
|
|
it.each([
|
|
"/数据/客户/秘密视频.mp4",
|
|
"/данные/клиент/видео.mp4",
|
|
"/data/客户/secret.mp4",
|
|
"/Users/alice/проект/видео.mp4",
|
|
])("redacts the absolute path %s", (path) => {
|
|
const out = redactTelemetryString(`ffprobe failed reading ${path}`);
|
|
expect(out).toBe("ffprobe failed reading [path]");
|
|
});
|
|
|
|
it("redacts a non-Latin bare relative path without stranding the first segment", () => {
|
|
// The lookbehind used to be `\w`-based, so a match could start mid-token
|
|
// when the preceding character was non-ASCII: this redacted to `客户[path]`.
|
|
expect(redactTelemetryString("could not open 客户/秘密/视频.mp4")).toBe(
|
|
"could not open [path]",
|
|
);
|
|
});
|
|
|
|
it.each(["./资产/背景.mp3", "../输出/final.wav"])("redacts the relative path %s", (path) => {
|
|
expect(redactTelemetryString(`could not open ${path}`)).toBe("could not open [path]");
|
|
});
|
|
|
|
it("redacts a non-Latin bare basename", () => {
|
|
expect(redactTelemetryString("Invalid data found in 秘密视频.mp4")).toBe(
|
|
"Invalid data found in [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");
|
|
});
|
|
|
|
// This sits on an error path: throwing here turns a reported failure into an
|
|
// unhandled rejection, which is what a non-Error rejection's `undefined`
|
|
// message caused.
|
|
it.each([undefined, null, 42, {}])("returns a string for the non-string input %s", (value) => {
|
|
expect(() => redactKnownPaths(value as unknown as string, ["/tmp/x.mp4"])).not.toThrow();
|
|
});
|
|
});
|