unsloth/scripts
Daniel Han 70a090fd26 studio: harden lockfile supply-chain audit followups for #5604
Three regressions surfaced after #5604 landed. All addressed here with
matching pytest coverage.

1. Default mode no longer blocks on `unsupported-lockfile-version`. A
   lockfile downgraded to v1 (or bumped to an unsupported future
   version) silently passes default CI because the auditor's structural
   walk only runs on v2/v3, so `blocked-known-malicious` /
   `known-ioc-string` findings cannot be produced. v1 downgrade is a
   documented supply-chain attack shape; restoring it to BLOCKING_KINDS.

2. `UNSLOTH_LOCKFILE_AUDIT_SKIP` warnings interpolated the raw env var
   value into `:⚠️:` workflow commands without `_gha_escape()`,
   so a value containing `\n::error::...` was emitted as a second
   physical workflow-command line (GH Actions parses workflow commands
   per physical line). Routing both branches through `_gha_escape()`
   collapses any control char onto a single annotation line.

3. The two workflows that consume `studio/package-lock.json` --
   `studio-tauri-smoke.yml` and `release-desktop.yml` -- did not invoke
   `scripts/lockfile_supply_chain_audit.py` before their `npm install`
   steps. Lifecycle scripts in a compromised lockfile would run before
   the audit could refuse the lockfile, defeating the script's
   "pre-install" guarantee. `release-desktop.yml` additionally has
   `contents: write`, so the gap had real publish-attacker blast
   radius. Both workflows now run the audit before any `npm install`
   or `npm ci`.

Tests
-----
- test_unsupported_lockfile_version_blocks_default: v1 lockfile must
  exit 1 in default mode.
- test_blocking_kinds_contains_unsupported_lockfile_version: direct
  module-level pin against future regressions.
- test_skip_env_warning_escapes_workflow_command_injection: both
  skip-env branches must escape `\n` / `%` so no injected physical
  workflow-command line is produced.
- test_audit_runs_before_npm_install_in_consumer_workflows: regex
  ordering check on the `run:` lines in the two consumer workflows so
  a future reorder cannot silently bring back the pre-install gap.

16/16 pytest pass; default-mode audit still rc=0 on real lockfiles.
2026-05-22 13:00:02 +00:00
..
data CI: scope GITHUB_TOKEN permissions, add MLX CI, unblock ~60 skipped tests (#5312) 2026-05-11 03:19:13 -07:00
check_frontend_dep_removal.py ci: deterministic check for studio/frontend dep removals (#5478) 2026-05-16 05:46:22 -07:00
check_new_install_scripts.py security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
enforce_kwargs_spacing.py security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
install_gemma4_mlx.sh security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
install_qwen3_6_mlx.sh security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
lint_workflow_triggers.py security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
lockfile_supply_chain_audit.py studio: harden lockfile supply-chain audit followups for #5604 2026-05-22 13:00:02 +00:00
notebook_to_python.py security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
notebook_validator.py security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
run_ruff_format.py Formatting & bug fixes (#3563) 2025-11-07 06:00:22 -08:00
scan_npm_packages.py security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
scan_packages.py security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
stamp_studio_release.py security: NOT affected by Mini Shai-Hulud (May-12 wave) -- forward-looking hardening only (#5397) 2026-05-13 04:58:12 -07:00
uninstall.ps1 Move uninstall scripts into scripts/ and fix references (#5644) 2026-05-20 04:42:03 -07:00
uninstall.sh Move uninstall scripts into scripts/ and fix references (#5644) 2026-05-20 04:42:03 -07:00
verify_comment_only_diff.py studio: drop unused max_grad_value schema + route plumbing (#5424) 2026-05-14 05:43:58 -07:00