Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Audit main without directing dependency repairs to retired lines

pulse-triage[bot]dbf65f305c29
diff --git a/.github/workflows/dependency-advisory-watch.yml b/.github/workflows/dependency-advisory-watch.yml
index 966a3dbfb0..9d1ff58a42 100644
--- a/.github/workflows/dependency-advisory-watch.yml
+++ b/.github/workflows/dependency-advisory-watch.yml
@@ -6,13 +6,13 @@ name: Dependency Advisory Watch
# exactly that to main, release/v6.4 and release/v6.5 at once, and nothing
# owned the fix. Since 3 Oct 2026 that step only warns for a pull request that
# leaves the lockfile alone, so this watch is where such an advisory fails: it
-# runs the same audit daily against main and every active release line with
+# runs the same audit daily against main with
# NPM_AUDIT_REQUIRE_RESULT=true, fails on any finding, and names the branch,
-# the advisories and the fix in the step summary. Scheduled workflows
-# only run on the default branch. The audit needs only each line's
-# frontend-modern/package.json and package-lock.json, so this job reads those
-# two files with git and never checks out, installs or executes another
-# branch's code in the default branch's context.
+# the advisories and the fix in the step summary. Releases have come only
+# from main since 4 October 2026; retained release branches are not delivery
+# inputs and must not generate backport instructions. The audit reads only
+# main's frontend-modern/package.json and package-lock.json as data, never
+# installing or executing fetched code.
on:
schedule:
- cron: '17 5 * * *'
@@ -26,67 +26,32 @@ concurrency:
cancel-in-progress: false
jobs:
- lines:
- name: List active release lines
- runs-on: ubuntu-24.04
- timeout-minutes: 5
- outputs:
- branches: ${{ steps.lines.outputs.branches }}
- steps:
- - name: Checkout watch helpers
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- with:
- persist-credentials: false
-
- - name: Resolve main and active release lines
- id: lines
- env:
- GH_TOKEN: ${{ github.token }}
- REPOSITORY: ${{ github.repository }}
- run: |
- set -euo pipefail
- heads="$(mktemp)"
- git ls-remote --heads "https://github.com/${REPOSITORY}.git" 'refs/heads/release/v*' > "${heads}"
- # The newest stable's line and newer are active. If the lookup fails,
- # every release line is audited rather than none.
- latest_stable="$(gh api "repos/${REPOSITORY}/releases/latest" --jq '.tag_name' 2>/dev/null || true)"
- branches="$(python3 scripts/dependency_advisory_watch.py lines --heads "${heads}" --latest-stable "${latest_stable}")"
- rm -f "${heads}"
- echo "Newest stable: ${latest_stable:-unknown}; auditing ${branches}"
- python3 scripts/write_github_output.py branches "${branches}"
-
audit:
- name: Audit frontend dependencies (${{ matrix.branch }})
- needs: lines
+ name: Audit frontend dependencies (main)
runs-on: ubuntu-24.04
timeout-minutes: 20
- strategy:
- fail-fast: false
- matrix:
- branch: ${{ fromJSON(needs.lines.outputs.branches) }}
steps:
- name: Checkout watch helpers
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- - name: Read the audited branch's lockfile inputs
+ - name: Read main's lockfile inputs
env:
- BRANCH: ${{ matrix.branch }}
AUDITED: ${{ runner.temp }}/audited
run: |
set -euo pipefail
mkdir -p "${AUDITED}"
- git fetch --no-tags --depth=1 origin "+refs/heads/${BRANCH}:refs/remotes/audited/head"
+ git fetch --no-tags --depth=1 origin '+refs/heads/main:refs/remotes/audited/head'
+ printf 'AUDITED_MAIN_SHA=%s\n' "$(git rev-parse refs/remotes/audited/head)"
for file in package.json package-lock.json; do
git show "refs/remotes/audited/head:frontend-modern/${file}" > "${AUDITED}/${file}"
done
# Same Node.js and audit runner as the required build-and-test Frontend
# job. npm audit reads the lockfile, so no install is needed and no
- # package from the audited branch is fetched or run. The runner always
- # comes from this workflow's own commit, so a release line that predates
- # it is held to the same verdict main's required check applies.
+ # package from main is fetched or run. The runner always comes from
+ # this workflow's own commit, never the fetched main source.
- name: Set up Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
@@ -107,7 +72,7 @@ jobs:
- name: Report advisories and fix
if: ${{ !cancelled() }}
env:
- BRANCH: ${{ matrix.branch }}
+ BRANCH: main
AUDIT_OUTCOME: ${{ steps.audit.outcome }}
run: |
python3 scripts/dependency_advisory_watch.py summary \
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index fbdc4f2cdf..658cc857e0 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -7415,67 +7415,49 @@ and tooling proofs, **not native Tailscale/update/recovery acceptance**. That
requires reviewed publication, infrastructure activation and a terminal hosted
collection through the fixed Delivery dispatcher.
-### Release-line dependency advisory watch (1 October 2026)
-
-On 30 September and 1 October 2026 `GHSA-q2hr-2g5m-vwhr` (`brace-expansion`)
-and `GHSA-p98j-92pf-mc4p` (DOMPurify) were published against unchanged
-`frontend-modern/package-lock.json` graphs. The required *Audit complete
-frontend dependency graph* step in `build-and-test.yml` then failed every pull
-request on `main`, `release/v6.4` and `release/v6.5`. That held the v6.4.6
-preparation pull request and the v6.5 release candidate for days with no owner.
-The scheduled npm audit in `security-scan.yml` only informs, and a scheduled
-workflow runs on the default branch alone, so release lines were never checked
-before a pull request hit them.
+### Main dependency advisory watch (10 October 2026)
-`.github/workflows/dependency-advisory-watch.yml` runs daily and on manual
-dispatch with only `contents: read` on the hosted `ubuntu-24.04` image. It uses
-no secrets, persists no checkout credentials and uploads nothing. Its first job
-lists `main` plus every remote `release/v<major>.<minor>` branch at or newer
-than the line of the release GitHub reports as latest. Patch branches such as
-`release/v6.4.2` and legacy `release/5.1` are never lines. If the latest-release
-lookup fails, every release line is audited instead of none.
-
-The second job is a fail-fast-free matrix over those branches. A scheduled job
-runs in the default branch's cache and token scope, so it never checks out,
-installs or runs another branch's code: each entry fetches the audited branch
-and reads only its `frontend-modern/package.json` and `package-lock.json` as
-data with `git show`, uses no dependency cache (its `actions/setup-node` step
-sets `package-manager-cache: false`, because that pin turns npm caching on by
-itself once `package.json` names npm as its `packageManager`), and repeats the required
-build-and-test audit against that lockfile with the same `actions/setup-node`
-pin and Node.js 24 and `scripts/npm-audit-retry.sh all` with
-`NPM_AUDIT_REQUIRE_RESULT=true`. `npm audit` answers from the lockfile, so the
-verdict is the one the required step reaches after its install. The runner always comes from the workflow's
-own commit, so a line whose build-and-test predates it is held to main's
-verdict, which fails on any finding at any severity just as a plain `npm audit`
-does. `frontend-modern/package-lock.json` is the only lockfile the required
-audit covers, so it is the only one the watch audits. The job fails whenever
-the audit fails. The step summary and one failure annotation name the branch,
-the GHSA identifiers and packages, and the fix: `npm audit fix
---package-lock-only` in `frontend-modern` on that line, then raising the
-matching floors in `frontend-modern/src/security/__tests__/dependencySecurity.test.ts`.
-An unreachable advisory endpoint, or a missing lockfile before any verdict,
-also fails the job but is reported as such and never as an advisory. Only
-validated branch names, package names and GHSA identifiers reach the
-annotation, and registry text in the summary is escaped.
-
-The watch gates nothing directly. The maintainer release-path health timer
-watches it, so a failed run becomes a top-priority Delivery request naming the
-failing line.
-
-Verification: `scripts/tests/test_dependency_advisory_watch.py` covers line
-selection (newest-stable floor, patch and legacy branch exclusion, the
-fail-wide fallback, `main` always present), the summary and annotation for
-advisory, clean, unreachable and install-failure outcomes, escaping of hostile
-registry text, refusal of unexpected branch names, and the workflow contract
-(triggers, read-only hosted shape, matrix wiring, and parity of the Node.js
-pin, install command and audit runner with the required build-and-test step).
-`scripts/check_workflow_trust.py` and actionlint pass. A local run of the
-helper and `npm-audit-retry.sh` against the 1 October 2026 heads selected
-`main`, `release/v6.4` and `release/v6.5`, passed `main`, and failed
-`release/v6.4` (`GHSA-p98j-92pf-mc4p`) and `release/v6.5`
-(`brace-expansion` and DOMPurify advisories). The hosted run is not yet claimed.
+The daily watch was built on 1 October for separately maintained release lines.
+Since 4 October all releases carry main, and those branches are retained history,
+not repair or delivery targets. In run 38027619322 on 10 October, main's complete
+audit passed but the workflow failed only on release/v6.5 and release/v6.6. Its
+summary incorrectly claimed those findings blocked every PR and release and
+recommended landing repairs on the retired lines. The old vulnerability findings
+remain evidence about those old graphs; this scope correction does not clear them
+or prove that shipped software is unaffected or has received main's repairs.
+`.github/workflows/dependency-advisory-watch.yml` runs daily and on manual
+dispatch with only `contents: read` on hosted `ubuntu-24.04`. Its sole audit job
+fetches the fixed main ref and reads only `frontend-modern/package.json` and
+`package-lock.json` as data, recording `AUDITED_MAIN_SHA`. It does not discover
+release branches, query release metadata, check out or execute fetched code,
+install packages, persist checkout credentials, use secrets or upload artifacts.
+The runner comes from the workflow's own checkout. Node.js 24 and the setup-node
+pin still match build-and-test; `package-manager-cache: false` preserves the
+cache-free watch, including setup-node's automatic npm caching behaviour.
+
+The watch still runs `scripts/npm-audit-retry.sh all` with
+`NPM_AUDIT_REQUIRE_RESULT=true`: every finding at any severity fails the job,
+as do unavailable or malformed audit results. It does not weaken the required
+build-and-test dependency audit, source-security floors or qualification.
+The summary names the packages and GHSA identifiers, directs compatibility and
+security proof plus repair to main, and distinguishes source landing from a
+containing release. It accurately distinguishes the strict watch from unchanged-
+graph PRs that only warn. Missing lockfiles/tooling and an unavailable endpoint
+are failures without an invented advisory. Only the fixed main name, validated
+package names and GHSA identifiers reach annotations; registry text is escaped.
+The summary CLI refuses retired release branches and arbitrary branch names.
+
+Verification: `scripts/tests/test_dependency_advisory_watch.py` checks the sole
+fixed-main job, no release discovery, executes its actual input recipe with a
+closed Git stand-in and an adverse branch environment, and verifies the exact
+main identity marker and two manifest reads. It covers main-only repair guidance,
+retired-branch refusal, advisory/clean/unavailable/tooling outcomes, hostile-text
+escaping, hosted/read-only/no-install/cache-free shape and unchanged action pins.
+The real audit runner still fails the same finding the unchanged-graph PR mode
+only warns on. `scripts/check_workflow_trust.py` and actionlint remain validation
+requirements. This is product dependency monitoring, not release preparation,
+qualification, promotion or a claim of an operationally completed watch repair.
### Backend test compilation before CI fan-out
diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.json
index 2091d82412..2a5c615e9b 100644
--- a/docs/release-control/v6/internal/subsystems/registry.json
+++ b/docs/release-control/v6/internal/subsystems/registry.json
@@ -4772,7 +4772,7 @@
},
{
"id": "dependency-advisory-watch",
- "label": "daily release-line dependency advisory watch proof",
+ "label": "daily main dependency advisory watch proof",
"match_prefixes": [],
"match_files": [
".github/workflows/dependency-advisory-watch.yml",
diff --git a/scripts/dependency_advisory_watch.py b/scripts/dependency_advisory_watch.py
index d03c56f8d3..b852befa2f 100644
--- a/scripts/dependency_advisory_watch.py
+++ b/scripts/dependency_advisory_watch.py
@@ -1,16 +1,11 @@
#!/usr/bin/env python3
"""Helpers for the daily dependency advisory watch workflow.
-`lines` turns `git ls-remote --heads` output and the newest stable release tag
-into the JSON list of branches the watch audits: `main` plus every
-`release/v<major>.<minor>` line at or newer than the newest stable's line.
-Without a usable stable tag every release line is kept, so a lookup failure
-widens the watch instead of silently narrowing it.
-
-`summary` reads the output of `scripts/npm-audit-retry.sh` for one branch and
-writes the step summary plus one failure annotation naming the branch, the
-advisories and the fix. Registry-sourced text never reaches the annotation:
-only the validated branch name, package names and GHSA identifiers do.
+`summary` reads the output of `scripts/npm-audit-retry.sh` for main and writes
+the step summary plus one failure annotation naming the advisories and the
+fix. Releases come only from main; retained release branches are not repair
+targets. Registry-sourced text never reaches the annotation: only the fixed
+branch name, validated package names and GHSA identifiers do.
"""
from __future__ import annotations
@@ -22,36 +17,19 @@ import sys
from pathlib import Path
-LINE_RE = re.compile(r"^release/v(\d+)\.(\d+)$")
-STABLE_RE = re.compile(r"^v(\d+)\.(\d+)\.(\d+)$")
GHSA_RE = re.compile(r"GHSA(?:-[23456789cfghjmpqrvwx]{4}){3}")
PACKAGE_RE = re.compile(r"^(?:@[a-z0-9][a-z0-9._~-]*/)?[a-z0-9][a-z0-9._~-]*$")
FINDING_PREFIX = "audit finding "
UNREACHABLE_MARKER = "could not reach the advisory endpoint"
FIX_STEPS = (
- "In frontend-modern on that branch run `npm audit fix --package-lock-only`, "
+ "Review the affected graph on main. In frontend-modern run "
+ "`npm audit fix --package-lock-only`, qualify the resulting graph, "
"then raise the matching floors in "
"`frontend-modern/src/security/__tests__/dependencySecurity.test.ts` "
- "and land both on the branch."
+ "and land both on main. A source fix reaches users only in a containing release."
)
-def release_lines(ls_remote: str, latest_stable: str) -> list[str]:
- lines: dict[tuple[int, int], str] = {}
- for row in ls_remote.splitlines():
- parts = row.split()
- if len(parts) != 2 or not parts[1].startswith("refs/heads/"):
- continue
- branch = parts[1][len("refs/heads/"):]
- match = LINE_RE.fullmatch(branch)
- if match:
- lines[(int(match.group(1)), int(match.group(2)))] = branch
- stable = STABLE_RE.fullmatch(latest_stable.strip())
- floor = (int(stable.group(1)), int(stable.group(2))) if stable else (0, 0)
- active = [lines[key] for key in sorted(lines) if key >= floor]
- return ["main", *active]
-
-
def parse_findings(log: str) -> list[dict]:
findings = []
for row in log.splitlines():
@@ -126,23 +104,22 @@ def render(branch: str, outcome: str, log: str) -> tuple[str, str | None]:
markdown_cell(fix_text))) + " |")
advisories = ", ".join(sorted(identifiers)) or "see job log"
body = (header
- + f"New npm advisories block every pull request and release on `{branch}` through the "
- + "required *Audit complete frontend dependency graph* check in build-and-test.yml.\n\n"
+ + "The strict daily audit found dependency advisories on main. "
+ + "Pull requests that change the graph must pass the required "
+ + "*Audit complete frontend dependency graph* check; unchanged graphs only warn.\n\n"
+ "\n".join(rows)
+ "\n\n**Suggested fix.** " + FIX_STEPS + "\n")
annotation = (f"Frontend dependency advisory on {branch}: {advisories} in "
- f"{', '.join(sorted(set(packages)))}. This blocks every PR and release on {branch}. "
- "The fix is a lockfile advisory floor bump on that line: npm audit fix --package-lock-only "
- "in frontend-modern, then raise the floors in dependencySecurity.test.ts.")
+ f"{', '.join(sorted(set(packages)))}. The strict daily watch failed. "
+ "Review and qualify a lockfile advisory floor bump on main: "
+ "npm audit fix --package-lock-only in frontend-modern, "
+ "then raise the floors in dependencySecurity.test.ts and land both on main.")
return body, annotation
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
commands = parser.add_subparsers(dest="command", required=True)
- lines = commands.add_parser("lines")
- lines.add_argument("--heads", required=True, type=Path, help="git ls-remote --heads output")
- lines.add_argument("--latest-stable", default="", help="newest stable release tag, if known")
summary = commands.add_parser("summary")
summary.add_argument("--branch", required=True)
summary.add_argument("--outcome", required=True)
@@ -150,11 +127,7 @@ def main(argv: list[str] | None = None) -> int:
summary.add_argument("--summary-file", required=True, type=Path)
args = parser.parse_args(argv)
- if args.command == "lines":
- print(json.dumps(release_lines(args.heads.read_text(encoding="utf-8"), args.latest_stable)))
- return 0
-
- if args.branch != "main" and not LINE_RE.fullmatch(args.branch):
+ if args.branch != "main":
print(f"refusing unexpected branch name {args.branch!r}", file=sys.stderr)
return 2
try:
diff --git a/scripts/tests/test_dependency_advisory_watch.py b/scripts/tests/test_dependency_advisory_watch.py
index 6cdd6b6beb..7fad177dc0 100644
--- a/scripts/tests/test_dependency_advisory_watch.py
+++ b/scripts/tests/test_dependency_advisory_watch.py
@@ -24,17 +24,6 @@ watch = importlib.util.module_from_spec(SPEC)
assert SPEC.loader is not None
SPEC.loader.exec_module(watch)
-HEADS = "\n".join((
- "29069d4139ef908862a179e1b0dd05364d895776\trefs/heads/release/5.1",
- "e261cd3eb8c2abed21357721df6506d30e2a0ec8\trefs/heads/release/v6.3.2",
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\trefs/heads/release/v6.3",
- "b50aeb6a8d9e38ab362b23f4ed15a010f675a90f\trefs/heads/release/v6.4",
- "26476f317a68746fd353967470cd8be3bc6b7670\trefs/heads/release/v6.4.2",
- "5f88b2002d1e1085053bf7bf3969aa61cdb0f637\trefs/heads/release/v6.5",
- "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\trefs/heads/release/v6.10",
- "cccccccccccccccccccccccccccccccccccccccc\trefs/heads/release/v6.5-hotfix",
-))
-
FINDING = {
"name": "dompurify", "severity": "moderate", "isDirect": True, "range": "<3.2.8",
"via": [{"source": 1, "name": "dompurify", "title": "DOMPurify `bypass` | <x>",
@@ -56,34 +45,6 @@ def audit_log(*findings: dict) -> str:
return "\n".join(rows) + "\n"
-class ReleaseLinesTest(unittest.TestCase):
- def test_newest_stable_line_and_newer_plus_main(self) -> None:
- self.assertEqual(watch.release_lines(HEADS, "v6.4.5"),
- ["main", "release/v6.4", "release/v6.5", "release/v6.10"])
-
- def test_patch_and_legacy_branches_are_never_lines(self) -> None:
- lines = watch.release_lines(HEADS, "")
- for branch in ("release/5.1", "release/v6.3.2", "release/v6.4.2", "release/v6.5-hotfix"):
- self.assertNotIn(branch, lines)
-
- def test_unknown_or_prerelease_stable_keeps_every_line(self) -> None:
- for latest in ("", "v6.5.0-rc.1", "garbage"):
- with self.subTest(latest=latest):
- self.assertEqual(watch.release_lines(HEADS, latest),
- ["main", "release/v6.3", "release/v6.4", "release/v6.5", "release/v6.10"])
-
- def test_main_is_audited_even_without_release_lines(self) -> None:
- self.assertEqual(watch.release_lines("", "v6.4.5"), ["main"])
-
- def test_cli_emits_json_list(self) -> None:
- with tempfile.TemporaryDirectory() as directory:
- heads = Path(directory) / "heads"
- heads.write_text(HEADS, encoding="utf-8")
- result = subprocess.run([sys.executable, str(SCRIPT), "lines", "--heads", str(heads),
- "--latest-stable", "v6.5.0"], capture_output=True, text=True, check=True)
- self.assertEqual(json.loads(result.stdout), ["main", "release/v6.5", "release/v6.10"])
-
-
class SummaryTest(unittest.TestCase):
def run_summary(self, branch: str, outcome: str, log: str) -> tuple[subprocess.CompletedProcess, str]:
with tempfile.TemporaryDirectory() as directory:
@@ -96,18 +57,24 @@ class SummaryTest(unittest.TestCase):
return result, summary.read_text(encoding="utf-8") if summary.exists() else ""
def test_advisory_names_branch_advisories_and_fix(self) -> None:
- result, summary = self.run_summary("release/v6.4", "failure", audit_log(FINDING, TRANSITIVE))
+ result, summary = self.run_summary("main", "failure", audit_log(FINDING, TRANSITIVE))
self.assertEqual(result.returncode, 0, result.stderr)
- self.assertIn("`release/v6.4`", summary)
+ self.assertIn("`main`", summary)
self.assertIn("GHSA-p98j-92pf-mc4p", summary)
self.assertIn("GHSA-q2hr-2g5m-vwhr", summary)
self.assertIn("npm audit fix --package-lock-only", summary)
self.assertIn("dependencySecurity.test.ts", summary)
annotations = [line for line in result.stdout.splitlines() if line.startswith("::error")]
self.assertEqual(len(annotations), 1)
- self.assertIn("release/v6.4", annotations[0])
+ self.assertIn("main", annotations[0])
self.assertIn("GHSA-p98j-92pf-mc4p, GHSA-q2hr-2g5m-vwhr", annotations[0])
self.assertIn("lockfile advisory floor bump", annotations[0])
+ self.assertIn("qualify the resulting graph", summary)
+ self.assertIn("land both on main", summary)
+ self.assertIn("containing release", summary)
+ self.assertIn("unchanged graphs only warn", summary)
+ self.assertNotIn("block every pull request", summary)
+ self.assertNotIn("blocks every PR and release", annotations[0])
def test_registry_text_is_escaped_and_kept_out_of_annotation(self) -> None:
hostile = dict(FINDING, name="evil\n::warning::x", via=[{"title": "x | <script>", "url": "javascript:"}])
@@ -119,7 +86,8 @@ class SummaryTest(unittest.TestCase):
self.assertNotIn("script", result.stdout)
def test_clean_run_has_no_annotation(self) -> None:
- result, summary = self.run_summary("release/v6.5", "success", "npm audit (all): no vulnerabilities\n")
+ result, summary = self.run_summary("main", "success", "npm audit (all): no vulnerabilities\n")
+ self.assertEqual(result.returncode, 0, result.stderr)
self.assertNotIn("::error", result.stdout)
self.assertIn("No advisories reported.", summary)
@@ -131,7 +99,7 @@ class SummaryTest(unittest.TestCase):
self.assertIn("No advisory was observed", summary)
def test_install_failure_without_audit_is_reported(self) -> None:
- result, _ = self.run_summary("release/v6.5", "skipped", "")
+ result, _ = self.run_summary("main", "skipped", "")
self.assertIn("failed without an advisory finding", result.stdout)
def test_unexpected_branch_name_is_refused(self) -> None:
@@ -139,6 +107,14 @@ class SummaryTest(unittest.TestCase):
self.assertEqual(result.returncode, 2)
self.assertEqual(summary, "")
+ def test_retired_release_branches_cannot_request_backport_guidance(self) -> None:
+ for branch in ("release/v6.5", "release/v6.6"):
+ with self.subTest(branch=branch):
+ result, summary = self.run_summary(branch, "failure", audit_log(FINDING))
+ self.assertEqual(result.returncode, 2)
+ self.assertEqual(summary, "")
+ self.assertEqual(result.stdout, "")
+
class WorkflowContractTest(unittest.TestCase):
text = WORKFLOW_PATH.read_text(encoding="utf-8")
@@ -160,14 +136,51 @@ class WorkflowContractTest(unittest.TestCase):
if str(step.get("uses", "")).startswith("actions/checkout@"):
self.assertIs(step["with"]["persist-credentials"], False)
- def test_matrix_covers_every_listed_branch_without_fail_fast(self) -> None:
+ def test_only_main_is_audited_without_release_discovery(self) -> None:
+ self.assertEqual(set(self.workflow["jobs"]), {"audit"})
audit = self.workflow["jobs"]["audit"]
- self.assertFalse(audit["strategy"]["fail-fast"])
- self.assertEqual(audit["strategy"]["matrix"]["branch"], "${{ fromJSON(needs.lines.outputs.branches) }}")
- read = next(step for step in audit["steps"] if step.get("name") == "Read the audited branch's lockfile inputs")
- self.assertEqual(read["env"]["BRANCH"], "${{ matrix.branch }}")
- self.assertIn('git fetch --no-tags --depth=1 origin "+refs/heads/${BRANCH}:refs/remotes/audited/head"', read["run"])
+ self.assertNotIn("strategy", audit)
+ self.assertNotIn("needs", audit)
+ self.assertNotIn("git ls-remote", self.text)
+ self.assertNotIn("gh api", self.text)
+ self.assertNotIn("GH_TOKEN", self.text)
+ read = next(step for step in audit["steps"] if step.get("name") == "Read main's lockfile inputs")
+ self.assertNotIn("BRANCH", read["env"])
+ self.assertIn("git fetch --no-tags --depth=1 origin '+refs/heads/main:refs/remotes/audited/head'", read["run"])
+ self.assertIn("AUDITED_MAIN_SHA=", read["run"])
self.assertIn("for file in package.json package-lock.json", read["run"])
+ summary = next(step for step in audit["steps"] if step.get("name") == "Report advisories and fix")
+ self.assertEqual(summary["env"]["BRANCH"], "main")
+
+ def test_real_input_recipe_is_fixed_main_and_never_executes_fetched_code(self) -> None:
+ read = next(step for step in self.workflow["jobs"]["audit"]["steps"]
+ if step.get("name") == "Read main's lockfile inputs")
+ with tempfile.TemporaryDirectory() as directory:
+ root = Path(directory)
+ fake_git = root / "git"
+ calls = root / "calls.jsonl"
+ fake_git.write_text(
+ f"#!{sys.executable}\n"
+ "import json, os, sys\n"
+ "args = sys.argv[1:]\n"
+ "with open(os.environ['CALLS'], 'a') as stream: stream.write(json.dumps(args)+'\\n')\n"
+ "if args == ['fetch', '--no-tags', '--depth=1', 'origin', '+refs/heads/main:refs/remotes/audited/head']: pass\n"
+ "elif args == ['rev-parse', 'refs/remotes/audited/head']: print('a'*40)\n"
+ "elif args == ['show', 'refs/remotes/audited/head:frontend-modern/package.json']: print('{}')\n"
+ "elif args == ['show', 'refs/remotes/audited/head:frontend-modern/package-lock.json']: print('{\"lockfileVersion\":3}')\n"
+ "else: sys.exit(19)\n", encoding="utf-8")
+ fake_git.chmod(0o755)
+ result = subprocess.run(["bash", "-c", read["run"]], capture_output=True, text=True,
+ env={**os.environ, "PATH": f"{root}:{os.environ['PATH']}",
+ "AUDITED": str(root / "audited"), "CALLS": str(calls),
+ "BRANCH": "release/v6.6"}, check=False)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(result.stdout, "AUDITED_MAIN_SHA=" + "a" * 40 + "\n")
+ self.assertEqual(json.loads((root / "audited/package.json").read_text()), {})
+ self.assertEqual(json.loads((root / "audited/package-lock.json").read_text()), {"lockfileVersion": 3})
+ commands = [json.loads(row) for row in calls.read_text().splitlines()]
+ self.assertEqual(len(commands), 4)
+ self.assertEqual(commands[0][-1], "+refs/heads/main:refs/remotes/audited/head")
def test_never_checks_out_installs_or_runs_another_branchs_code(self) -> None:
# A scheduled job runs in the default branch's cache and token scope,