Skip to content

A local video studio for your coding agent. Describe a video in one sentence: your agent directs, your machine renders. Claude Code, Codex, Cursor, Devin and more. No API keys, no uploads.

Security: code-scanning fixes and MusicGen hardening

Favio Vázquezfccc5837749a
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7a3bfe3..e1accd0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -60,6 +60,9 @@ env:
NO_COLOR: "1"
SHOWTIME_PROGRESS: "auto"
+permissions:
+ contents: read
+
jobs:
smoke:
name: fast (${{ matrix.os }}, ${{ matrix.shard }}/3)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 93f2d61..78e66ca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -53,6 +53,22 @@ through an HTTP proxy, `.env` files unreadable), plus a Windows race the push CI
file another process is replacing, so `status` and the run's supervisor could collide on `run.json`; the
supervisor's failed read then rewrote the file with only its new fields. Reads and replaces now retry for up to 2 s,
and a failed read never rewrites the file.
+- **Code-scanning hardening (CodeQL).** Found by GitHub's code scanning on a fork of 0.3.4; none was a reported
+ exploit, all are fixed rather than suppressed. The site's player and previews take only http(s) media and script
+ URLs from `data-*` attributes (and `file:` when the site itself is opened from disk), `data-root` must be a relative
+ path, and search-result links are escaped. The standalone player detects a doctype with a loop instead of a regex
+ that backtracked on many `--><!--`, and escapes attribute values and the stage URL it writes; the studio clamps a
+ dial's default to a number from 0 to 100; the icon cache builds its CDN URL only from a valid package name and a
+ pinned version; `adopt` escapes backslashes in the names it puts into regexes, matches `</script >` end tags, and
+ strips `--!>` from a file name written into an HTML comment. The brand-block pattern matches exactly the `<link>`
+ line showtime writes; the Wikimedia rate-limit hint compares the parsed hostname; the caption emoji class and the
+ `motion --where` parser are written without patterns the scanner misreads (same results, checked over every code
+ point and a set of filters); the `ci` workflow runs with read-only repository permissions.
+- **MusicGen loads only safetensors, and outside Intel Macs needs torch 2.13+.** The optional MusicGen extra now
+ passes `use_safetensors=True`, so it never `torch.load`s a pickle (the pinned model revision ships
+ `model.safetensors`). Intel Macs keep torch 2.2.2, the last x86_64 macOS build, whose known flaws are in
+ `torch.load` and in functions MusicGen does not call with outside input; everywhere else the floor is 2.13, the
+ first release with every published PyTorch security fix.
- **Tests in a sandbox that refuses `listen()` skip instead of failing.** `tests/_listen.py` (`LISTEN_BLOCKED`,
`needs_listen`, `skip_if_listen_refused()`, `SHOWTIME_TEST_NO_LISTEN=1` to simulate) is used by every test that
serves something; the keelson fixture tests skip when `.env` files are unreadable; test_delight runs alone under `-j`
diff --git a/site/static/app.js b/site/static/app.js
index 3997c9c..6c9a957 100644
--- a/site/static/app.js
+++ b/site/static/app.js
@@ -3,6 +3,14 @@
(function () {
var root = document.documentElement;
var base = document.body.getAttribute('data-root') || '';
+ if (!/^(?:\.\.?\/|[\w.-]+\/)*$/.test(base)) base = '';
+ // media and script URLs from data-* attributes: http(s) only (or file: when the site itself is opened from disk)
+ function safeSrc(u) {
+ try {
+ var x = new URL(u, location.href);
+ return x.protocol === 'http:' || x.protocol === 'https:' || (x.protocol === 'file:' && location.protocol === 'file:') ? x.href : '';
+ } catch (e) { return ''; }
+ }
var reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
var canHover = matchMedia('(hover: hover) and (pointer: fine)').matches;
function store(k, v) { try { if (v === undefined) return localStorage.getItem(k); localStorage.setItem(k, v); } catch (e) { return null; } }
@@ -60,7 +68,7 @@
var b = e.target.closest('button.watch'); if (!b) return;
var screen = b.closest('.screen');
var v = document.createElement('video'); v.controls = true; v.playsInline = true; v.preload = 'auto';
- v.src = b.getAttribute('data-film'); v.poster = b.getAttribute('data-poster'); v.setAttribute('aria-label', b.getAttribute('data-label') || 'The showtime film');
+ v.src = safeSrc(b.getAttribute('data-film')); v.poster = safeSrc(b.getAttribute('data-poster')); v.setAttribute('aria-label', b.getAttribute('data-label') || 'The showtime film');
if (teaser) teaser.remove();
screen.classList.add('playing'); screen.insertBefore(v, b); v.play().catch(function () {}); v.focus();
});
@@ -74,7 +82,7 @@
if (!el) {
if (/\.mp4$/.test(clip)) { el = document.createElement('video'); el.muted = true; el.loop = true; el.playsInline = true; el.setAttribute('aria-hidden', 'true'); el.preload = 'auto'; }
else { el = document.createElement('img'); el.alt = ''; }
- el.className = 'loop'; el.src = clip; frame.insertBefore(el, frame.querySelector('.open'));
+ el.className = 'loop'; el.src = safeSrc(clip); frame.insertBefore(el, frame.querySelector('.open'));
var show = function () { if (frame.matches(':hover') || frame.contains(document.activeElement)) frame.classList.add('previewing'); };
if (el.tagName === 'VIDEO') el.addEventListener('playing', show); else el.addEventListener('load', show);
}
@@ -95,8 +103,8 @@
document.addEventListener('click', function (e) {
var b = e.target.closest('button.open'); if (!b) return;
var frame = b.parentNode, still = frame.querySelector('.still');
- var v = document.createElement('video'); v.controls = true; v.playsInline = true; v.preload = 'auto'; v.src = b.getAttribute('data-full');
- if (still) v.poster = still.getAttribute('src');
+ var v = document.createElement('video'); v.controls = true; v.playsInline = true; v.preload = 'auto'; v.src = safeSrc(b.getAttribute('data-full'));
+ if (still) v.poster = safeSrc(still.getAttribute('src'));
v.setAttribute('aria-label', b.getAttribute('aria-label').replace(/^Play /, ''));
frame.classList.remove('previewing'); frame.classList.add('playing');
frame.querySelectorAll('.loop,.hint,.open').forEach(function (n) { n.remove(); });
@@ -141,7 +149,7 @@
function load(cb) {
if (index) return cb();
if (window.SHOWTIME_SEARCH) { index = window.SHOWTIME_SEARCH; return cb(); }
- var s = document.createElement('script'); s.src = base + 'search-index.js';
+ var s = document.createElement('script'); s.src = safeSrc(base + 'search-index.js');
s.onload = function () { index = window.SHOWTIME_SEARCH || []; cb(); }; document.head.appendChild(s);
}
function esc(s) { return s.replace(/[&<>"]/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]; }); }
@@ -163,7 +171,7 @@
var d = r[1], x = d.x, lx = x.toLowerCase(), i = lx.indexOf(terms[0]), snip = i >= 0 ? x.slice(Math.max(0, i - 50), i + 110) : x.slice(0, 140);
var s = esc(snip); terms.forEach(function (w) { s = s.replace(new RegExp('(' + w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ')', 'ig'), '<mark>$1</mark>'); });
var sec = ''; for (var k = 0; k < d.h.length; k++) { if (d.h[k].toLowerCase().indexOf(terms[0]) >= 0) { sec = d.a[k]; break; } }
- return '<a href="' + base + d.u + (sec ? '#' + sec : '') + '"><b>' + esc(d.t) + '</b><small>' + (i > 50 ? '…' : '') + s + '…</small></a>';
+ return '<a href="' + esc(base + d.u + (sec ? '#' + sec : '')) + '"><b>' + esc(d.t) + '</b><small>' + (i > 50 ? '…' : '') + s + '…</small></a>';
}).join('') || '<p class="muted" style="padding:10px 11px;margin:0;font-size:.9rem">No guide mentions that.</p>';
box.hidden = false;
}
diff --git a/skills/showtime/lib/st/assets/net.py b/skills/showtime/lib/st/assets/net.py
index 6ced4ce..3597650 100644
--- a/skills/showtime/lib/st/assets/net.py
+++ b/skills/showtime/lib/st/assets/net.py
@@ -130,7 +130,7 @@ def open_url(url: str, *, headers: Optional[Dict[str, str]] = None, timeout: flo
if ra is not None and ra > RATE_LIMIT_MAX_WAIT:
err.hint = "the server asks to wait about %.0f min before retrying%s" % (
ra / 60.0, "; Wikimedia serves thumbnails from another tier: fetch with --max-size 1920 "
- "or 3840" if "wikimedia.org" in url else "")
+ "or 3840" if (urllib.parse.urlsplit(url).hostname or "").split(".")[-2:] == ["wikimedia", "org"] else "")
raise err from None
if 500 <= e.code < 600 and attempt < retries:
time.sleep(1.5 * (attempt + 1))
diff --git a/skills/showtime/lib/st/audio/musicgen_worker.py b/skills/showtime/lib/st/audio/musicgen_worker.py
index 45a4b5d..364dddb 100644
--- a/skills/showtime/lib/st/audio/musicgen_worker.py
+++ b/skills/showtime/lib/st/audio/musicgen_worker.py
@@ -34,7 +34,9 @@ def main() -> int:
t0 = time.time()
kw = {"revision": a.revision} if a.revision else {}
proc = AutoProcessor.from_pretrained(a.model, **kw)
- model = MusicgenForConditionalGeneration.from_pretrained(a.model, **kw)
+ # safetensors only: never torch.load a pickle (the pinned repo ships model.safetensors; Intel Macs run torch 2.2.2,
+ # whose torch.load has known code-execution flaws)
+ model = MusicgenForConditionalGeneration.from_pretrained(a.model, use_safetensors=True, **kw)
model.eval()
sr = int(model.config.audio_encoder.sampling_rate)
tokens = int(max(1.0, min(30.0, a.seconds)) * 50)
diff --git a/skills/showtime/lib/st/brand/apply.py b/skills/showtime/lib/st/brand/apply.py
index 2ba6811..e8a95a6 100644
--- a/skills/showtime/lib/st/brand/apply.py
+++ b/skills/showtime/lib/st/brand/apply.py
@@ -22,7 +22,7 @@ from typing import Any, Dict, List, Optional, Tuple
from ..common import read_json, write_json
from . import contrast, font_status, luminance, palette, rgb, to_hex
-BLOCK_RX = re.compile(r"\n?<!-- brand kit: .*? -->\n(?:<link [^>]*data-st-brand[^>]*>\n)*<style id=\"st-brand\">.*?</style>\n?", re.S)
+BLOCK_RX = re.compile(r"\n?<!-- brand kit: .*? -->\n(?:<link rel=\"stylesheet\" href=\"[^\"]*\" data-st-brand>\n)*<style id=\"st-brand\">.*?</style>\n?", re.S)
def _hex(c: Tuple[float, float, float]) -> str:
diff --git a/skills/showtime/lib/st/cli_motion.py b/skills/showtime/lib/st/cli_motion.py
index bf67532..ffa6bb9 100644
--- a/skills/showtime/lib/st/cli_motion.py
+++ b/skills/showtime/lib/st/cli_motion.py
@@ -300,7 +300,16 @@ def parse_names(specs: Optional[List[str]]) -> Dict[str, str]:
return out
-_WHERE_RE = re.compile(r"^\s*(?P<col>[^=!~<>]+?)\s*(?P<op>!=|!~|=|~|>=|<=|>|<)\s*(?P<val>.*)$")
+_WHERE_OPS = ("!=", "!~", ">=", "<=", "=", "~", ">", "<")
+
+
+def _split_where(w: str) -> Optional[Tuple[str, str, str]]:
+ """'COL<op>VALUE' -> (col, op, value), or None when there is no column or no operator."""
+ at = next((i for i, ch in enumerate(w) if ch in "=!~<>"), -1)
+ if at < 1:
+ return None
+ op = next((o for o in _WHERE_OPS if w.startswith(o, at)), None)
+ return None if op is None else (w[:at], op, w[at + len(op):])
def filter_rows(cols: List[str], rows: List[Dict[str, Any]], wheres: Optional[List[str]]) -> Tuple[List[Dict[str, Any]], List[str]]:
@@ -309,12 +318,12 @@ def filter_rows(cols: List[str], rows: List[Dict[str, Any]], wheres: Optional[Li
return rows, []
tests = []
for w in wheres:
- m = _WHERE_RE.match(str(w))
+ m = _split_where(str(w).strip("\r\n"))
if not m:
raise ShowtimeError("--where %r: use COLUMN=VALUE, COLUMN~REGEX or COLUMN>NUMBER" % w,
hint="e.g. --where MSN=CLETPUS --where \"YYYYMM~13$\"")
- col = _col(cols, m.group("col").strip(), "--where")
- op, val = m.group("op"), m.group("val").strip().strip('"').strip("'")
+ col = _col(cols, m[0].strip(), "--where")
+ op, val = m[1], m[2].strip().strip('"').strip("'")
if op in ("~", "!~"):
try:
rx = re.compile(val)
diff --git a/skills/showtime/lib/st/cli_voice.py b/skills/showtime/lib/st/cli_voice.py
index 43c4968..903431f 100644
--- a/skills/showtime/lib/st/cli_voice.py
+++ b/skills/showtime/lib/st/cli_voice.py
@@ -301,6 +301,9 @@ def cmd_cues(args: argparse.Namespace) -> int:
return 0
+_LIST_COLS = ("id", "lang", "gender", "grade")
+
+
def cmd_list(args: argparse.Namespace) -> int:
from .voice import models, voices
rows: List[Dict[str, Any]] = []
@@ -335,8 +338,7 @@ def cmd_list(args: argparse.Namespace) -> int:
print("%-28s %-6s %-3s %-5s %-4s %s" % ("VOICE", "LANG", "SEX", "GRADE", "READY", "NOTES"))
for r in rows:
notes = r["notes"] + ("" if r["engine"] == "kokoro" else " [%s]" % r["license"])
- print("%-28s %-6s %-3s %-5s %-4s %s" % (r["id"], r["lang"], r["gender"], r["grade"],
- "yes" if r["installed"] else "no", notes))
+ print("%-28s %-6s %-3s %-5s %-4s %s" % (*(r[c] for c in _LIST_COLS), "yes" if r["installed"] else "no", notes))
sys.stdout.flush()
print("\nDefaults: en af_heart (female) / am_michael (male), en-gb bf_emma, es ef_dora, fr ff_siwis."
"\nNot installed = downloads on first use (Piper) or `showtime setup --with supertonic`.", file=sys.stderr)
diff --git a/skills/showtime/lib/st/footage/captions.py b/skills/showtime/lib/st/footage/captions.py
index 08c17bb..6ff139f 100644
--- a/skills/showtime/lib/st/footage/captions.py
+++ b/skills/showtime/lib/st/footage/captions.py
@@ -907,8 +907,13 @@ def build(words: List[Dict[str, Any]], out_path, *, style: str = "bold-pop", wid
return rep
-EMOJI_RE = re.compile("[\U0001F1E6-\U0001F1FF\U0001F300-\U0001FAFF\u2600-\u27BF\u2B00-\u2BFF\uFE0F\u200D"
- "\U0001F3FB-\U0001F3FF]")
+def _span(lo: int, hi: int) -> str:
+ return "%s-%s" % (chr(lo), chr(hi))
+
+
+EMOJI_RE = re.compile("[" + "".join(_span(a, b) for a, b in (
+ (0x1F1E6, 0x1F1FF), (0x1F300, 0x1FAFF), (0x2600, 0x27BF), (0x2B00, 0x2BFF), (0xFE0F, 0xFE0F), (0x200D, 0x200D),
+ (0x1F3FB, 0x1F3FF))) + "]")
def _fit_glyphs(font, dw: List[Dict[str, Any]], st: Dict[str, Any], keep_emoji: bool = False):
diff --git a/skills/showtime/runtime/player/boot.js b/skills/showtime/runtime/player/boot.js
index 17120f4..f5b96b8 100644
--- a/skills/showtime/runtime/player/boot.js
+++ b/skills/showtime/runtime/player/boot.js
@@ -579,10 +579,10 @@
var bodyAttrs = '';
for (var b = 0; b < doc.body.attributes.length; b++) {
var at = doc.body.attributes[b];
- bodyAttrs += ' ' + at.name + '="' + at.value.replace(/&/g, '&amp;').replace(/"/g, '&quot;') + '"';
+ bodyAttrs += ' ' + at.name + '="' + at.value.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;') + '"';
}
D.write('<script type="importmap">' + JSON.stringify({ imports: imports }).replace(/</g, '\\u003c') + '<\/script>' +
- '<script src="' + blobFor(C.stage) + '"><\/script>' +
+ '<script src="' + String(blobFor(C.stage)).replace(/&/g, '&amp;').replace(/"/g, '&quot;') + '"><\/script>' +
doc.head.innerHTML + '</head><body' + bodyAttrs + '>' + doc.body.innerHTML);
}
diff --git a/skills/showtime/runtime/player/player.js b/skills/showtime/runtime/player/player.js
index cfa126c..8836723 100644
--- a/skills/showtime/runtime/player/player.js
+++ b/skills/showtime/runtime/player/player.js
@@ -61,7 +61,12 @@
vorigin: VORIGIN, page: M.page, html: M.html, stage: M.stage, generator: M.generator, assetBase: assetBase,
renderConfig: { config: M.config, override: null, alpha: false, settle: 'none', layers: false, seed: M.seed },
};
- var hadDoctype = /^\s*(<!--[\s\S]*?-->\s*)*<!doctype/i.test(M.html);
+ // leading comments, then <!doctype ...>: a loop, not a regex (the regex backtracked on many '--><!--')
+ var hadDoctype = (function (h) {
+ h = h.replace(/^\s+/, '');
+ while (h.slice(0, 4) === '<!--') { var e = h.indexOf('-->', 4); if (e < 0) return false; h = h.slice(e + 3).replace(/^\s+/, ''); }
+ return /^<!doctype/i.test(h);
+ })(String(M.html));
var pack = D.getElementById('st-files');
var packed = pack ? pack.textContent.trim() : '';
if (zfiles && zfiles.length > 2) packed = packed.length > 2 ? packed.slice(0, -1) + ',' + zfiles.slice(1) : zfiles;
@@ -220,7 +225,7 @@
var bar = D.createElement('div');
bar.className = 'stp-bar';
bar.innerHTML =
- '<div class="stp-scrub" role="slider" tabindex="0" aria-label="' + esc(tr('seek')) + '" aria-valuemin="0" aria-valuemax="' + M.duration + '" aria-valuenow="0">' +
+ '<div class="stp-scrub" role="slider" tabindex="0" aria-label="' + esc(tr('seek')) + '" aria-valuemin="0" aria-valuemax="' + (Number(M.duration) || 0) + '" aria-valuenow="0">' +
'<div class="stp-rail"><div class="stp-buf"></div><div class="stp-hover"></div><div class="stp-fill"></div><div class="stp-ticks"></div></div>' +
'<div class="stp-knob"></div><div class="stp-tip" hidden></div></div>' +
'<div class="stp-row">' +
diff --git a/skills/showtime/runtime/studio/board.js b/skills/showtime/runtime/studio/board.js
index 3e1efc1..768d60c 100644
--- a/skills/showtime/runtime/studio/board.js
+++ b/skills/showtime/runtime/studio/board.js
@@ -484,7 +484,7 @@
(q.allowText ? '<label class="sr" for="qt-' + esc(q.id) + '">Your own answer to: ' + esc(q.text) + '</label><textarea id="qt-' + esc(q.id) + '" data-q="' + esc(q.id) + '" class="qtext" maxlength="2000" placeholder="Or say it in your words, then press Ctrl+Enter"></textarea>' : '') + '</div>';
}).join('');
var dials = Core.dialsOf(b).map(function (sl) {
- var d = sl['default'] != null ? sl['default'] : 50;
+ var d = Math.min(100, Math.max(0, Number(sl['default'] != null ? sl['default'] : 50) || 0));
return '<div class="dial"><label for="sl-' + esc(sl.id) + '">' + esc(sl.label) + ' <output id="so-' + esc(sl.id) + '">' + d + '</output></label>' +
'<div class="rng"><span class="proposed" style="left:calc(' + d + '% + ' + (8 - d * 0.16) + 'px)" title="Your agent\'s proposal"></span><input type="range" min="0" max="100" value="' + d + '" id="sl-' + esc(sl.id) + '" data-dial="' + esc(sl.id) + '" aria-describedby="se-' + esc(sl.id) + '"></div>' +
'<div class="ends" id="se-' + esc(sl.id) + '"><span>' + esc(sl.left || '') + '</span><span>' + esc(sl.right || '') + '</span></div></div>';
diff --git a/skills/showtime/scripts/adopt.mjs b/skills/showtime/scripts/adopt.mjs
index cbbd808..9d7e8f0 100644
--- a/skills/showtime/scripts/adopt.mjs
+++ b/skills/showtime/scripts/adopt.mjs
@@ -809,7 +809,7 @@ async function adoptPython(ctx, kind) {
unit = null; fnName = null;
}
const index = `<!doctype html>
-<!-- written by \`showtime adopt\`: frames drawn by ${entry.replace(/-->/g, '')} (${mode === 'frames' ? `${fnName}()` : 'its own main'}), played frame-exactly -->
+<!-- written by \`showtime adopt\`: frames drawn by ${entry.replace(/--!?>/g, '')} (${mode === 'frames' ? `${fnName}()` : 'its own main'}), played frame-exactly -->
<html><head><meta charset="utf-8"><title>${escapeHtml(path.basename(entry))}</title>
<script src="/_st/stage.js"></script>
<style>html,body{margin:0;background:#000;overflow:hidden}#frames{position:absolute;inset:0;width:100%;height:100%;object-fit:contain}</style>
diff --git a/skills/showtime/scripts/lib/adopt/scan.mjs b/skills/showtime/scripts/lib/adopt/scan.mjs
index 8f6bb74..04a0577 100644
--- a/skills/showtime/scripts/lib/adopt/scan.mjs
+++ b/skills/showtime/scripts/lib/adopt/scan.mjs
@@ -16,7 +16,7 @@ const IMG_EXT = /\.(png|jpe?g|webp|bmp|tiff?)$/i;
// Time functions a page exposes, in the order we prefer them when several exist.
export const TIME_FNS = ['seek', '__seek', 'seekTo', 'renderAt', 'render', 'renderFrame', 'draw', 'drawFrame', 'drawAt',
'setTime', 'setFrame', 'gotoTime', 'goto', '__render', '__draw', '__setTime', 'frame', 'update', 'paint', 'tick'];
-const FN_ALT = TIME_FNS.map((n) => n.replace(/\$/g, '\\$')).join('|');
+const FN_ALT = TIME_FNS.map((n) => n.replace(/[\\$]/g, '\\$&')).join('|');
/** Walk a folder (skipping dependency and output folders) -> [relative posix paths]. */
export function listFiles(root, { max = 4000 } = {}) {
@@ -50,7 +50,7 @@ function read(file, max = 2e6) {
/** The script text of an HTML page (inline scripts only; external classic scripts are appended by the caller). */
export function inlineScripts(html) {
const out = [];
- const re = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi;
+ const re = /<script\b([^>]*)>([\s\S]*?)<\/script[^>]*>/gi;
let m;
while ((m = re.exec(html))) out.push({ attrs: m[1], text: m[2] });
return out;
@@ -107,7 +107,7 @@ export function scanPage(html) {
// window.render = render; (assigned from a named function)
const aliasRe = new RegExp(`(?:window|globalThis|self)\\.(${FN_ALT})\\s*=\\s*([A-Za-z_$][\\w$]*)\\s*[;\\n]`, 'g');
while ((m = aliasRe.exec(all))) {
- const decl = new RegExp(`function\\s+${m[2].replace(/\$/g, '\\$')}\\s*\\(\\s*([\\w$]*)`).exec(all);
+ const decl = new RegExp(`function\\s+${m[2].replace(/[\\$]/g, '\\$&')}\\s*\\(\\s*([\\w$]*)`).exec(all);
addFn(m[1], decl ? decl[1] : '', m.index);
}
// top-level function render(t) { ... } in a classic script (a global too)
diff --git a/skills/showtime/scripts/lib/iconcache.mjs b/skills/showtime/scripts/lib/iconcache.mjs
index ecdb3eb..7a55192 100644
--- a/skills/showtime/scripts/lib/iconcache.mjs
+++ b/skills/showtime/scripts/lib/iconcache.mjs
@@ -56,7 +56,10 @@ export async function iconFile(libPath) {
const file = path.join(dir, ...rel.split('/'));
if (fs.existsSync(file)) return file;
if (offline()) return null;
- const base = `${CDN}/${pkg}@${versions()[pkg]}`;
+ // a package name and a pinned version from setup/manifest.json, nothing else, before they go into the CDN URL
+ const ver = versions()[pkg];
+ if (!/^[\w.+-]+$/.test(String(ver)) || !/^(?:@[\w.-]+\/)?[\w.-]+$/.test(pkg)) return null;
+ const base = `${CDN}/${pkg}@${ver}`;
try {
if (!(await download(`${base}/${rel}`, file))) return null;
const pj = path.join(dir, 'package.json');
diff --git a/skills/showtime/setup/requirements-musicgen.in b/skills/showtime/setup/requirements-musicgen.in
index 039e1ba..97af330 100644
--- a/skills/showtime/setup/requirements-musicgen.in
+++ b/skills/showtime/setup/requirements-musicgen.in
@@ -5,8 +5,9 @@
# and transformers<4.58 (5.x requires torch>=2.5).
torch==2.2.2 ; sys_platform == 'darwin' and platform_machine == 'x86_64'
numpy<2 ; sys_platform == 'darwin' and platform_machine == 'x86_64'
-# Everyone else: a current CPU torch (on Linux setup.py installs it from the PyTorch CPU index first).
-torch>=2.5,<3 ; sys_platform != 'darwin' or platform_machine != 'x86_64'
+# Everyone else: a current CPU torch (on Linux setup.py installs it from the PyTorch CPU index first); 2.13 is the
+# first release with every published PyTorch security fix.
+torch>=2.13,<3 ; sys_platform != 'darwin' or platform_machine != 'x86_64'
numpy>=1.26 ; sys_platform != 'darwin' or platform_machine != 'x86_64'
transformers>=4.45,<4.58
huggingface_hub>=0.26,<1.0
diff --git a/skills/showtime/setup/setup.py b/skills/showtime/setup/setup.py
index 761bcaa..c00b2fa 100755
--- a/skills/showtime/setup/setup.py
+++ b/skills/showtime/setup/setup.py
@@ -1199,7 +1199,7 @@ class Installer:
if plat.os_name() == "linux":
# PyPI's Linux torch wheels bundle CUDA (~3 GB); the CPU index is much smaller.
cp = run([uv, "pip", "install", "--python", str(vpy), "--index-url",
- "https://download.pytorch.org/whl/cpu", "torch>=2.5,<3"], env=env, timeout=3600)
+ "https://download.pytorch.org/whl/cpu", "torch>=2.13,<3"], env=env, timeout=3600)
if cp.returncode != 0:
return "fail", "torch (CPU) install failed:\n" + tail(cp.stdout)
cp = run([uv, "pip", "install", "--python", str(vpy), "-r", str(SETUP_DIR / "requirements-musicgen.in")],
diff --git a/skills/showtime/tests/test_audio.py b/skills/showtime/tests/test_audio.py
index 8f19b1e..1453d97 100644
--- a/skills/showtime/tests/test_audio.py
+++ b/skills/showtime/tests/test_audio.py
@@ -137,6 +137,14 @@ class AudioTests(unittest.TestCase):
self.assertIn("usage", st("audio", "lib", sub, "--help").stdout)
# ------------------------------------------------------------------ compose
+ def test_01b_musicgen_loads_safetensors_and_current_torch(self):
+ """MusicGen never torch.loads a pickle, and outside Intel Macs the torch floor carries every security fix."""
+ worker = (SKILL / "lib" / "st" / "audio" / "musicgen_worker.py").read_text(encoding="utf-8")
+ self.assertIn("from_pretrained(a.model, use_safetensors=True", worker)
+ req = (SKILL / "setup" / "requirements-musicgen.in").read_text(encoding="utf-8")
+ self.assertIn("torch>=2.13,<3 ; sys_platform != 'darwin' or platform_machine != 'x86_64'", req)
+ self.assertIn('"torch>=2.13,<3"', (SKILL / "setup" / "setup.py").read_text(encoding="utf-8"))
+
def test_02_compose(self):
for style, backend in (("upbeat-tech", "auto"), ("corporate-minimal", "auto"), ("lofi-chill", "auto")):
out = self.tmp / ("%s.wav" % style)