* ci: add advisory lockfile supply-chain audit Adds a fast, focused workflow that scans every checked-in npm and cargo lockfile on PRs touching one. Default behaviour is advisory: only public indicator-of-compromise strings, versions on the public known-malicious list, and structurally broken lockfiles fail the build. Structural anomalies (missing integrity hashes, non-default registry, etc.) surface as :⚠️: annotations without gating merges, so reviewers see the audit result inline on every PR without changing the existing install behaviour. Also commits the two missing npm lockfiles the audit needs: studio/package-lock.json (Tauri CLI holder for desktop release) and studio/backend/core/data_recipe/oxc-validator/package-lock.json (oxc-parser runtime for the data-recipe validator). studio/setup.sh, studio/setup.ps1, build.sh, and pyproject.toml are intentionally left alone so the existing install path keeps working unchanged. Audit script behaviour: default mode -> exits 1 only on blocked-known-malicious, known-ioc-string, malformed-lockfile, missing-lockfile, unreadable-lockfile, or missing-toml-parser --strict -> promotes every finding to blocking (opt-in) Adds a try/except around lockfile reads so a permissions error prints a finding instead of crashing CI with a raw traceback. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test(security): update cargo regression test for advisory mode `scripts/lockfile_supply_chain_audit.py` now classifies `non-registry-cargo-source` as an advisory finding by default (returns exit 0 with a `:⚠️:` annotation) rather than unconditionally blocking with exit 1. Update the existing `test_malicious_cargo_lockfile_refused` to pass --strict so it keeps verifying the "refuse to install" behavior it is named for, and add a second test that pins the default-mode behavior: advisory finding emitted, exit code 0. * audit: escape Finding for GH Actions annotations `:⚠️:` and `::error::` workflow commands truncate the annotation message at the first newline unless the message is %-encoded per the workflow-commands spec. Since `Finding.__str__` returns three lines (kind+path, package, detail), the package and detail fields were being dropped from the GitHub Actions UI. Add a `_gha_escape()` helper that applies the spec'd escapes (`%` -> `%25`, then `\r` -> `%0D`, then `\n` -> `%0A`; the `%` replacement must happen first so the subsequent escapes are not double-encoded), wrap every Finding rendered into a workflow command with it, and pin both the helper and the end-to-end single-line emission with two new regression tests. Caught by gemini-code-assist on PR #5604. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
79 lines
2.9 KiB
YAML
79 lines
2.9 KiB
YAML
# SPDX-License-Identifier: AGPL-3.0-only
|
|
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
|
|
#
|
|
# Fast, focused supply-chain audit of every checked-in lockfile.
|
|
#
|
|
# Runs scripts/lockfile_supply_chain_audit.py on PRs that touch any
|
|
# npm or cargo lockfile, on push to main, and on a daily schedule so
|
|
# newly-published IOCs surface even when no PR opens.
|
|
#
|
|
# Default behavior is "advisory": only public indicator-of-compromise
|
|
# strings, known-malicious pinned versions, and structurally broken
|
|
# lockfiles fail the build. Structural anomalies (missing integrity,
|
|
# non-default registry, etc.) are emitted as GitHub Actions warnings
|
|
# but do not block merges. This deliberately keeps the noise floor
|
|
# low while still failing the moment a checked-in lockfile starts
|
|
# pointing at known-bad bytes.
|
|
#
|
|
# This workflow is intentionally separate from security-audit.yml:
|
|
# - security-audit.yml is the umbrella job (pip-audit + npm audit +
|
|
# cargo audit + OSV + Semgrep + secret scanning + SBOM + ...);
|
|
# it takes ~25 minutes and runs only when dep manifests change.
|
|
# - lockfile-audit.yml is a ~30 second pure-Python parse + grep on
|
|
# the lockfiles themselves; it runs on every PR that even nudges
|
|
# a lockfile so reviewers always see the audit result inline.
|
|
|
|
name: Lockfile supply-chain audit
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'studio/frontend/package-lock.json'
|
|
- 'studio/backend/core/data_recipe/oxc-validator/package-lock.json'
|
|
- 'studio/package-lock.json'
|
|
- 'studio/src-tauri/Cargo.lock'
|
|
- 'scripts/lockfile_supply_chain_audit.py'
|
|
- '.github/workflows/lockfile-audit.yml'
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'studio/frontend/package-lock.json'
|
|
- 'studio/backend/core/data_recipe/oxc-validator/package-lock.json'
|
|
- 'studio/package-lock.json'
|
|
- 'studio/src-tauri/Cargo.lock'
|
|
- 'scripts/lockfile_supply_chain_audit.py'
|
|
- '.github/workflows/lockfile-audit.yml'
|
|
schedule:
|
|
- cron: '37 5 * * *'
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
audit:
|
|
name: lockfile supply-chain audit
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Verify audit script parses
|
|
run: python3 -c "import ast; ast.parse(open('scripts/lockfile_supply_chain_audit.py').read())"
|
|
|
|
- name: Run lockfile supply-chain audit
|
|
# Default mode: only known-malicious pinned versions, known IOC
|
|
# strings, and structurally broken lockfiles fail the build.
|
|
# Missing-integrity and other structural anomalies are emitted
|
|
# as ::warning:: annotations and do not gate merges.
|
|
run: python3 scripts/lockfile_supply_chain_audit.py
|