mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-05 00:56:23 +00:00
* fix(skills): clear Snyk findings and harden supply-chain surface
Address the security-audit findings on the published skills with no change to
any skill's behaviour.
- media-use: resolve.test.mjs runs resolve.mjs via execFileSync with an argv
array instead of execSync(`node … "${tmp}" …`), removing the command-injection
(CWE-78) sink that drove the Snyk Fail.
- music-to-video: replace dynamic `element.innerHTML = <var>` with a setSvg()
helper (DOMParser image/svg+xml + importNode, text fallback) in the
intro-kinetic-cascade and logo-split-lockup-pulse frame templates, clearing the
DOM-XSS (CWE-79) Snyk Fail. Renders identical SVG.
- pr-to-video: fetch-people-avatars.mjs refuses any avatar URL that is not https
on a GitHub avatar host (SSRF guard) and only writes under the project dir
(path-traversal guard); best-effort, always-exit-0 behaviour is unchanged.
- embedded-captions: pin `uvx --from whisperx==3.8.6` (overridable via
$WHISPERX_VERSION) so transcription no longer resolves "latest" at runtime.
- gsap: add Subresource Integrity (integrity + crossorigin) to the 8 render-time
CDN GSAP <script> tags across embedded-captions, music-to-video,
faceless-explainer, pr-to-video and product-launch-video.
- hyperframes-animation / hyperframes-creative: document package-loader's
defense-in-depth and note that the installLine strings are display-only.
Verified: media-use resolve (12/12), probe injection (1/1) and manifest (19/19)
tests pass; avatar host-allowlist checks pass; all changed JS passes node --check
and oxfmt.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* docs(skills): clarify product-launch-video vs website-to-video routing
Sharpen the router's product-vs-site decision in hyperframes/SKILL.md: the
split is now "is the site selling a product?" — yes (SaaS / app / product /
company site) → /product-launch-video (a promo; the default for any commercial
URL, even if the site is only named); no, or the user just wants the site shown
as-is (portfolio / blog / docs / personal / event) → /website-to-video (a tour).
Updates the workflow table, the disambiguation bullet, and both workflows'
Input/Output blurbs to match.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* style(skills): satisfy oxfmt in the two music-to-video templates
The CI Format job runs `oxfmt --check .`, which also formats embedded <script> in .html. Reflow the setSvg() blocks added for the DOM-XSS fix to oxfmt's wrapping — no logic change. Regenerate the music-to-video manifest hash to match.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(skills): sanitize SVG in music-to-video templates (real CWE-79 fix)
Addresses @Magi's review: the previous setSvg() only swapped the sink
(innerHTML → DOMParser + importNode) but did NOT sanitize, so active SVG
content still executed on insertion into the live document. Verified in
headless Chrome that the old shape fired both an svg `onload` handler and an
inline `<script>`.
setSvg() now runs a default-deny cleanSvg() over the parsed tree before it ever
enters the document: only an allow-list of inert drawing elements
(svg/g/path/line/rect/circle/… ) and presentation attributes
(d/fill/stroke/viewBox/…) survives. Every other element (`<script>`, `<image>`,
`<use>`, `<foreignObject>`, `<a>`, `<animate>`, …), every `on*` handler, and
href/xlink:href/style are stripped — on the root node too. Non-SVG or malformed
input still falls back to textContent.
Trusted content (the bundled icon library + the default spark/cloud marks)
renders byte-identically; only hostile markup in vars.icon / leftMark / rightMark
is neutralized.
Browser-verified (headless Chrome, both templates' helper):
old setSvg → fired ["script","onload"]
new setSvg → fired [] · trusted icon still renders · 0 danger nodes · 0 on* attrs
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
158 lines
6.0 KiB
JavaScript
158 lines
6.0 KiB
JavaScript
#!/usr/bin/env node
|
|
// Step 1 — contributor avatar fetch (NETWORK; orchestrator-invoked).
|
|
//
|
|
// The counterpart to ingest.mjs: ingest is a pure offline transform, THIS is the
|
|
// one network step on the people front. It reads the people list ingest produced
|
|
// and downloads each contributor's GitHub avatar into assets/<login>.png,
|
|
// then rewrites people.json with `avatarFetched` flags so downstream (story-design)
|
|
// knows which avatars actually exist.
|
|
//
|
|
// Avatars + a credits/shipped-by scene are the ONE place the faceless default is
|
|
// relaxed. They are an OPTIONAL enhancement, so this script is best-effort:
|
|
// - a missing/deleted user, a network blip, an offline run → log + skip
|
|
// - it ALWAYS exits 0 (a failed avatar must never block the build)
|
|
//
|
|
// Network is constrained on purpose: only https GitHub avatar hosts are fetched
|
|
// (SSRF guard), and bytes are only ever written under the project dir (no path
|
|
// traversal), so a tampered people.json can't redirect the fetch or the write.
|
|
//
|
|
// Reads:
|
|
// --people <path> capture/extracted/people.json (from ingest.mjs)
|
|
// Writes:
|
|
// assets/<login>.png one per contributor whose avatar resolved
|
|
// (rewrites people.json in place with avatarFetched: true/false)
|
|
//
|
|
// Flags: --project-dir . --timeout 8000 (ms per request)
|
|
// Avatars are written to <project-dir>/<person.avatarFile>, where avatarFile is
|
|
// the project-root-relative "assets/<login>.png" — the SAME assets/ dir the frame
|
|
// workers reference and assemble-index stages (lib/assets.mjs). Anchor on the
|
|
// project root so the path stays under the project's assets/.
|
|
//
|
|
// Usage (orchestrator already cd'd into PROJECT_DIR, so --project-dir defaults to "."):
|
|
// node fetch-people-avatars.mjs --people ./capture/extracted/people.json
|
|
|
|
import { existsSync, mkdirSync, readFileSync, writeFileSync, statSync } from "node:fs";
|
|
import { resolve, join, dirname, sep } from "node:path";
|
|
|
|
const argv = process.argv.slice(2);
|
|
const flag = (name, def) => {
|
|
const i = argv.indexOf(`--${name}`);
|
|
return i >= 0 && i + 1 < argv.length ? argv[i + 1] : def;
|
|
};
|
|
|
|
const peoplePath = resolve(flag("people", "./capture/extracted/people.json"));
|
|
const projectDir = resolve(flag("project-dir", "."));
|
|
const TIMEOUT = parseInt(flag("timeout", "8000"), 10);
|
|
|
|
// SSRF guard: avatars only ever come from GitHub's avatar hosts, so refuse any
|
|
// other URL rather than fetching whatever string people.json happens to carry.
|
|
// `github.com/<login>.png` 302s to avatars.githubusercontent.com (redirect stays
|
|
// on-host, controlled by GitHub).
|
|
const AVATAR_HOSTS = new Set(["avatars.githubusercontent.com", "github.com", "www.github.com"]);
|
|
function isAllowedAvatarUrl(u) {
|
|
let parsed;
|
|
try {
|
|
parsed = new URL(u);
|
|
} catch {
|
|
return false;
|
|
}
|
|
if (parsed.protocol !== "https:") return false;
|
|
const host = parsed.hostname.toLowerCase();
|
|
return AVATAR_HOSTS.has(host) || host.endsWith(".githubusercontent.com");
|
|
}
|
|
|
|
// Path guard: the written file must stay inside the project dir, so a crafted
|
|
// avatarFile ("../../etc/…") can't escape via join().
|
|
function isUnderProject(p) {
|
|
const r = resolve(p);
|
|
return r === projectDir || r.startsWith(projectDir + sep);
|
|
}
|
|
|
|
// Soft-exit helper — avatars are optional, so every early-out is exit 0.
|
|
function softExit(msg) {
|
|
console.log(`• fetch-avatars: ${msg}`);
|
|
process.exit(0);
|
|
}
|
|
|
|
if (!existsSync(peoplePath)) softExit(`no people.json at ${peoplePath} — skipping (no avatars)`);
|
|
|
|
let doc;
|
|
try {
|
|
doc = JSON.parse(readFileSync(peoplePath, "utf8"));
|
|
} catch (e) {
|
|
softExit(`people.json unreadable (${e.message}) — skipping`);
|
|
}
|
|
|
|
const people = Array.isArray(doc.people) ? doc.people : [];
|
|
if (!people.length) softExit("no contributors in people.json — skipping");
|
|
|
|
async function fetchOne(person) {
|
|
const { login, avatarUrl } = person;
|
|
if (!login || !avatarUrl) return "skip";
|
|
if (!isAllowedAvatarUrl(avatarUrl)) {
|
|
person.avatarFetched = false;
|
|
console.log(` (skip avatar @${login}: not a GitHub avatar URL)`);
|
|
return "fail";
|
|
}
|
|
// avatarFile is project-root-relative ("assets/<login>.png"); anchor on the
|
|
// project root so it stays under the project's assets/ dir.
|
|
const dest = join(projectDir, person.avatarFile || `assets/${login}.png`);
|
|
if (!isUnderProject(dest)) {
|
|
person.avatarFetched = false;
|
|
console.log(` (skip avatar @${login}: avatar path escapes the project dir)`);
|
|
return "fail";
|
|
}
|
|
mkdirSync(dirname(dest), { recursive: true });
|
|
// Idempotent: a non-empty file from a prior run is reused (re-runs are free).
|
|
if (existsSync(dest) && statSync(dest).size > 0) {
|
|
person.avatarFetched = true;
|
|
return "cached";
|
|
}
|
|
const ctrl = new AbortController();
|
|
const timer = setTimeout(() => ctrl.abort(), TIMEOUT);
|
|
try {
|
|
const res = await fetch(avatarUrl, {
|
|
signal: ctrl.signal,
|
|
redirect: "follow", // github.com/<login>.png redirects to avatars.githubusercontent.com
|
|
headers: { "User-Agent": "hyperframes-pr-to-video" },
|
|
});
|
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
if (!buf.length) throw new Error("empty body");
|
|
writeFileSync(dest, buf);
|
|
person.avatarFetched = true;
|
|
return "ok";
|
|
} catch (e) {
|
|
person.avatarFetched = false;
|
|
console.log(` (skip avatar @${login}: ${e.message})`);
|
|
return "fail";
|
|
} finally {
|
|
clearTimeout(timer);
|
|
}
|
|
}
|
|
|
|
let ok = 0;
|
|
let cached = 0;
|
|
let fail = 0;
|
|
// Sequential keeps it simple and gentle on github.com; the list is tiny (a PR's
|
|
// contributors), so latency is not a concern.
|
|
for (const person of people) {
|
|
const r = await fetchOne(person);
|
|
if (r === "ok") ok++;
|
|
else if (r === "cached") cached++;
|
|
else if (r === "fail") fail++;
|
|
}
|
|
|
|
// Persist avatarFetched flags so story-design can reference only real avatars.
|
|
try {
|
|
writeFileSync(peoplePath, JSON.stringify(doc, null, 2) + "\n");
|
|
} catch (e) {
|
|
console.log(` (warn: could not rewrite people.json flags: ${e.message})`);
|
|
}
|
|
|
|
console.log(
|
|
`✓ fetch-avatars: ${ok + cached}/${people.length} avatar(s) in assets/` +
|
|
` (${ok} new, ${cached} cached, ${fail} failed)`,
|
|
);
|
|
process.exit(0);
|