Repository navigation
ci: cover every workflow with the hardening guards, and fix the gaps they surface - #126
Conversation
rng1995
left a comment
There was a problem hiding this comment.
The workflow hardening improves action pinning and token scope, but the Fern installation still executes an unlocked transitive lifecycle script immediately before the secret-bearing publish step, and the new global guard rejects supported local action and reusable-workflow references. Workflow tests passed (13 tests), and both updated action SHAs match their official tags. Requesting changes for the two remaining hardening gaps noted inline.
Maintainer review (rng1995, PR NVIDIA#126, P1) found that pinning fern-api's top-level version does not pin its dependency tree: npm re-resolves every transitive dependency from semver ranges on each install. fern-api@5.66.1 has an optional dependency on @boundaryml/baml@^0.219.0, which depends on @scarf/scarf@^1.3.0, which resolves to 1.4.0 and declares postinstall: node ./report.js. That script still ran in the job immediately before FERN_TOKEN was used. Pass --ignore-scripts on both npm installs (publish-docs.yml and ci.yml's docs-validation lane, which runs the identical command). fern-api declares no scripts of its own and npm links its bin natively, so nothing the CLI needs is skipped -- this alone removes the lifecycle-script execution vector. Also pass --omit=optional, which drops @boundaryml/baml and the eight native binaries it pulls in. This rests on one assumption that cannot be verified in CI: publish-docs.yml only runs on push to main, gated on github.run_number > 1, so it never executes on a pull request. Because BAML is declared optional, fern-api must already tolerate its absence at install time; the residual risk is a lazily-required docs code path. If docs publishing breaks on the merge commit, the rollback is to drop --omit=optional and keep --ignore-scripts, which retains the security property that motivated this change. Signed-off-by: berzan93-prog <224507836+berzan93-prog@users.noreply.github.com>
… refs Two changes to the workflow guards, both from the same review round: Add test_every_workflow_npm_install_ignores_lifecycle_scripts, asserting every npm install line in any workflow's run steps carries --ignore-scripts. It follows the same glob-every-workflow shape as the other guards, so a fifth workflow is covered the day it lands. --omit=optional is deliberately not asserted: it is a judgement about one CLI's optional dependency, not a repository-wide invariant, and asserting it would block a future workflow that legitimately needs optional dependencies. Confirmed non-vacuous by the previous commit: before it, this guard failed against the real, unpatched ci.yml and publish-docs.yml. Relax test_every_workflow_pins_every_action_to_a_commit so a same-repo reference (uses: ./...) no longer needs a commit SHA. GitHub always resolves a local composite action or reusable workflow from the caller's own commit, so nothing about it can float, and the guard previously rejected the only syntax GitHub supports for it (reviewer rng1995, PR NVIDIA#126, P2). A local reference that escapes the repository (./../outside) is still rejected, and docker://image:tag is unaffected -- a mutable container tag is not a local reference and stays rejected. The exemption lives in the guard, not in _all_uses, so a future guard can still assert something about local references specifically. Probed with throwaway workflow files (removed before this commit): ./.github/actions/x failed the guard before this change and passes after; ./../outside and docker://alpine:3.18 failed before and still fail after. Also update the one pre-existing assertion that hardcoded the old install line verbatim. Signed-off-by: berzan93-prog <224507836+berzan93-prog@users.noreply.github.com>
|
Thanks — both were right, and testing the P1 fix instead of assuming it turned up a second problem in my own patch. I've gone with your first option, the lockfile. P1 — lifecycle scriptsConfirmed the chain against the registry before changing anything: My earlier commit said pinning the version stopped the tree floating. That was wrong — npm re-resolves every transitive edge from semver on each run. The first fix was also wrong, in a way worth flagging: Now: That closes both halves of what you wrote. It no longer resolves: every package in the lock carries an exact version and an integrity hash, so a compromised republish can't substitute. It no longer executes: Verified end to end rather than reasoned about: the exact command sequence installs one package, and Two notes on the shape, both reversible if you'd rather:
P2 — local referencesAgreed.
Also in here
Say the word on any of these and I'll drop them. Verification
|
|
@rng1995 — ready for another look whenever you have time. Both comments are addressed in the commits above, with the reasoning in my reply of 1 Sep. I've resolved the local-references thread, since that one is straightforward. I've deliberately left the dependency-tree thread open for you: my second attempt at it took a different approach from the first — a committed lockfile with Flagging here only because I can't re-request a review as an outside contributor. Happy to rebase onto current |
chrisknvidia
left a comment
There was a problem hiding this comment.
Thanks for addressing the two original findings. I rechecked the current head and am requesting changes for two additional blockers: the locked Fern version does not match the version enforced on the authenticated production path, and the new npm guards accept false-valued options that re-enable the prohibited behavior. Please address both findings below, then update from main (currently six commits ahead of this branch) and rerun the required checks.
rng1995
left a comment
There was a problem hiding this comment.
Re-reviewed the current head. The two original findings are addressed, and I resolved the remaining fixed thread. Two later blockers remain reproducible: the lockfile still pins Fern 5.66.1 while the authenticated NVIDIA path requires at least 5.106.0, and the npm guards accept false-valued options that re-enable the behavior they are intended to prohibit. Focused workflow tests, Ruff, the exact lockfile install, fern check, and CI pass. Keeping Changes requested until those two existing threads are addressed.
|
@dberzan Please address all review comments to merge the PR. |
|
@chrisknvidia Thanks for catching both — verified and fixed in 4f81e43. P2 (npm flag substring check): confirmed by reading P1 (stale Fern CLI pin): Also flagged: Verified: Branch is current with |
|
@dberzan - Please resolve review comments so that we can merge the PR. |
|
@rng1995 Both findings from the 2026-09-16 review are fixed in Case-insensitive Failing closed on unrecognized npm forms. Confirmed, and it was the silent kind: Each case was checked by pointing the guards at a doctored copy of the real workflows and watching them fire, then running the same cases against the guards as they stood before this commit:
The fifth row is a third form of the bypass fixed in A self-review before pushing found five defects in the first draft of this change, each reproduced before being fixed: shlex's lexer ends a word at any Verified: One adjacent gap I did not close here, since you didn't raise it and it would widen this PR: I've left both threads open for you to confirm. |
rng1995
left a comment
There was a problem hiding this comment.
@dberzan I re-checked the full current change and verified the earlier findings against the code and regression tests. Both remaining threads are now resolved: mixed-case checkout actions are recognized, and the npm guard catches chained commands, env wrappers, and global options. I found no remaining substantive code blocker.
Local validation: 26 workflow tests passed; Ruff and diff checks passed; a clean Fern install and fern check completed with no errors (one authentication warning).
Approval is pending DCO. All 16 other reported checks pass, but commit e27ff5752cb6cc44fd172f8f85708c54303eafeb lacks a Signed-off-by trailer. Please add your sign-off to that commit and push the corrected history so DCO can pass. Thanks for addressing the review feedback.
c6c3b28 to
c6f80d7
Compare
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
rng1995
left a comment
There was a problem hiding this comment.
Resolved the conflicts with current main in 6d8cd4d, preserving the committed Fern lockfile install, all-workflow hardening guards, and existing main changes. Removed the obsolete hard-coded Fern version floor raised in the latest review while retaining manifest/config/lockfile consistency checks. No remaining substantive code blockers found.
Validation: 73 focused workflow/classifier tests passed; Ruff, repository boundary and benchmark provenance scans, package build, source/distribution boundary scans, and local DCO verification passed. The full suite initially reported 6,953 passed, 18 skipped, 4 deselected, and one failure caused by a subprocess selecting macOS Python 3.9; that test passed when rerun with the Python 3.12 environment on PATH. No unresolved local failures remain. The exact npm ci installation and Fern check passed, with the authentication-only redirects check skipped.
GitHub Actions runs are awaiting separate maintainer authorization; remote CI results are still pending. Approving the reviewed commit.
chrisknvidia
left a comment
There was a problem hiding this comment.
@dberzan The latest re-review found one remaining P2 issue in the npm workflow guard, detailed inline. Please fix it and add a regression test before merging; approval is still pending this fix.
rng1995
left a comment
There was a problem hiding this comment.
@dberzan Thank you for your patience through many review rounds, and for your contribution to SkillEvaluator! Running these guards over every workflow is a solid hardening improvement.
I re-reviewed the current head. Every review finding is now addressed:
- npm selected through shell parameter expansion (last open thread): I pushed the fix in
b4627b3.NPM_MENTIONnow treats the parameter-expansion operators inside${...}(-,=,+,?,/) as word boundaries and the closing}as a terminator.NPM_BIN=${UNSET:-npm}; "$NPM_BIN" installand its sibling forms (${UNSET-npm},${UNSET:=npm},${SET:+npm},${PM/p/npm}, quoted and path forms) now fail closed as "cannot classify". Unit and workflow-level regressions cover them, and${NPM_TOKEN},${NPM_CONFIG_CACHE:-$HOME/.npm}and${PM:-pnpm}still pass, as do the real workflows. - Earlier findings, all still in place at head:
- The Fern lockfile, manifest and config agree, and the obsolete version floor is removed.
- Negated npm flags are rejected by the exact-argv check.
actions/checkoutmatching is case-insensitive.- npm forms the parser can't classify fail closed.
- Same-commit local
uses:references are allowed. - The dependency tree is locked before the step that receives the secret.
Validation: tests/test_ci_workflows.py passes 40/40 and Ruff is clean. All 17 CI checks passed on the previous head; the run on the latest update from main is in progress.
@chrisknvidia, the npm parameter-expansion finding from your last review is fixed in b4627b3. Could you take another look when you have a moment?
Approved.
chrisknvidia
left a comment
There was a problem hiding this comment.
Re-reviewed at 14a3e16: the npm parameter-expansion guard finding is fixed, focused workflow/classifier tests pass, and the current required checks are green. Approved.
|
@dberzan Could you please update this PR branch so it can be merged with Rebase and merge? GitHub currently reports rebaseable=false, although the final tree merges cleanly. A local replay onto current main first conflicts at commit 651a8bb in .github/workflows/publish-docs.yml (the older global Fern install versus the newer workflow). Please preserve the final locked npm ci --prefix fern --ignore-scripts --omit=optional behavior and the reviewed guards while resolving and linearizing the history. This may require a force-push to your fork branch. Please ping us once it is updated so we can recheck the new head, CI, and approvals before merging. Thanks! |
…they surface Install the Fern CLI from a committed lockfile and tighten the workflow guards in tests/test_ci_workflows.py so the gaps they missed fail the suite. Workflows and docs: - Commit fern/package.json and fern/package-lock.json, and install the CLI in ci.yml and publish-docs.yml with `npm ci --prefix fern --ignore-scripts --omit=optional`, running ./fern/node_modules/.bin/fern rather than a binary on PATH. This stops `npm install --global` re-resolving the transitive tree on every run and running lifecycle scripts (such as @scarf/scarf's postinstall) ahead of the step that holds FERN_TOKEN. publish-docs.yml gets a pinned setup-node step. - Bump fern-api from 5.66.1 to 5.121.0 in fern.config.json and the lockfile. - Run `fern check` in the required Python 3.12 job on every run, not only for docs-only PRs. The change classifier now counts only docs/** and fern/docs.yml as docs-only, so Fern dependency and config changes go through the full lane. - Point docs/README.md, docs/AGENTS.md and docs/developer-guide.mdx at the same lockfile install; ignore node_modules/; add a CHANGELOG Security entry. Guards: - Pin job-level reusable-workflow `uses:` as well as step actions. Accept a same-repo ./ reference unless it escapes the repository or carries @ref. - Match actions/checkout case-insensitively when enforcing persist-credentials: false. - Reject write-all in job-level permissions as well as workflow-level. - Split each run: block into shell commands with a quote- and comment-aware scanner, and allow only the reviewed npm command. Fail closed on any npm mention the parser cannot classify (bash -c, wrappers it does not model, npm chosen through ${...} parameter expansion). - Keep fern/package.json, fern/package-lock.json and fern.config.json on one exact, integrity-pinned CLI version with no unreviewed dependencies. Squashed from the reviewed PR NVIDIA#126 history at 14a3e16 onto main so the PR can be merged with Rebase and merge. Signed-off-by: berzan93-prog <224507836+berzan93-prog@users.noreply.github.com> Co-authored-by: Christopher Kevin <christopherk@nvidia.com> Co-authored-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JzLgAD1cTuGWQp71Zv94mH
14a3e16 to
47ead34
Compare
|
@chrisknvidia thanks — done. I've replaced the branch with a single commit on top of the current main (bde533a), so it should now be rebaseable. The tree includes the reviewed content from 14a3e16, plus main's changes since then. The only hand-resolved file is tests/test_ci_workflows.py, which conflicted with v0.5.0: I kept both import sets, both module constants (GITLEAKS_CONFIG and REVIEWED_NPM_COMMAND), main's new gitleaks test, and the PR's case-insensitive test_every_workflow_does_not_persist_checkout_credentials in place of the old checkout test it renames. Every other file is byte-identical to a clean merge of the two. |
rng1995
left a comment
There was a problem hiding this comment.
Re-reviewed at 36c9e5a. Every review thread is resolved, and the change is unchanged from what @chrisknvidia and I approved at 14a3e16:
- The squashed commit 47ead34 is signed off. Its diff across all 13 files is identical to the approved 14a3e16 diff. The only difference is one deleted line in
tests/test_ci_workflows.pythatmainhad already reformatted. - 36c9e5a is a clean merge of current
main: its tree matches an automatic merge of the two, and GitHub reports the branch as rebaseable. tests/test_ci_workflows.pyandtests/test_ci_change_classifier.py: 84 passed.uv run ruff check .is clean.
Non-blocking: as @dberzan pointed out, the ### Security CHANGELOG entry sits under the already-released ## 0.3.0. It belongs under ## Unreleased and can move here or in a follow-up.
I approved the pending fork CI runs for this head.
Approved.
Brings in #126 (workflow hardening guards across every workflow). One conflict, in tests/test_ci_workflows.py: the gitleaks full-history test finds the checkout step with main's _is_checkout_step helper. The branch's gitleaks allowlist pins and its ci.yml verifier-compile step are kept, and #126's guards pass on them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Conflicts: - tests/test_ci_workflows.py: main (#126) dropped the unused DOCS_ONLY_IF constant now that Fern validation runs on every pass; kept that removal and the PR's TIER3_LANE_IF. All of main's new workflow-hardening guards and the PR's metadata_only output/routing assertions are kept. - CHANGELOG.md (auto-merged into the released 0.6.0 section): moved the PR's --previous-skill entry to Unreleased under ### Added; 0.6.0 is unchanged from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
…they surface (#126) * ci: cover every workflow with the hardening guards, and fix the gaps they surface Signed-off-by: berzan93-prog <224507836+berzan93-prog@users.noreply.github.com>
Conflicts: - tests/test_ci_workflows.py: main (#126) dropped the unused DOCS_ONLY_IF constant now that Fern validation runs on every pass; kept that removal and the PR's TIER3_LANE_IF. All of main's new workflow-hardening guards and the PR's metadata_only output/routing assertions are kept. - CHANGELOG.md (auto-merged into the released 0.6.0 section): moved the PR's --previous-skill entry to Unreleased under ### Added; 0.6.0 is unchanged from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Brings in #126 (workflow hardening guards across every workflow). One conflict, in tests/test_ci_workflows.py: the gitleaks full-history test finds the checkout step with main's _is_checkout_step helper. The branch's gitleaks allowlist pins and its ci.yml verifier-compile step are kept, and #126's guards pass on them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Summary
Closes #125.
tests/test_ci_workflows.pyalready encodes two CI hardening invariants — every action pinned to a commit SHA, and no checkout persisting credentials — but both iterated the hardcoded tuple("ci.yml", "security.yml").dco.ymlandpublish-docs.ymlwere never loaded, and both had drifted.permissions:declaredpersist-credentials: falseci.ymlsecurity.ymldco.ymlpublish-docs.ymlThe workflows
publish-docs.ymlis the only workflow that puts a secret in a job environment (FERN_TOKEN), and was the least hardened of the four.actions/checkout@v4was the single unpinneduses:reference out of 36 in the repository. It now uses9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0, the SHA already used 14 times here.permissions:block, so the job inherited the repository defaultGITHUB_TOKENscope. It now declarescontents: read, matching the other three workflows.persist-credentials: false, so the token was written to.git/configand stayed readable by every later step in the job — includingnpm installandfern generate.npm install -g fern-apiresolved its whole transitive tree at run time. It now installs the versionfern/fern.config.jsonpins, derived exactly asci.yml's docs lane already does, with the same format guard and a pinnedsetup-nodeso the lookup does not depend on the runner's ambient Node. Docs are now validated and published by the same CLI version — a hardcoded pin here would have let those two drift, which is the mistake my first attempt made.dco.ymlonly reads history withgit logandgit show, so it getspersist-credentials: falsetoo.The guards
Both existing guards now glob
.github/workflows/rather than naming files, so a workflow added later is covered the day it lands — that is the part that stops this recurring. Both are renamed fromtest_changed_workflows_*totest_every_workflow_*, since the old names would now be wrong. Three guards are added or widened:permissions:, and nopermissions:value anywhere iswrite-all— including job-level blocks, which override the workflow-level one;uses:, i.e. reusable workflows, which have nostepslist for the step-level walk to reach;publish-docs.ymlnever hardcodes the Fern CLI version again.Granular write scopes (
contents: writeand friends) are deliberately still allowed — a release workflow will legitimately need one. The invariant is that the scope is declared and never blanket.The guards are not vacuous
Against the workflows as they stood before the first commit, three fail:
And against a probe workflow that declares
permissions: contents: readat the top, escalates one job topermissions: write-all, and references a reusable workflow at@main, two fail. Before the last commit that same probe passed all thirteen — which is how those two holes were found.One thing to decide knowingly
publish-docs.ymlis the only workflow that never runs on a pull request — it ispushtomainonly, gated ongithub.run_number > 1. So thepersist-credentials: falsechange on the publish path cannot be exercised before merge.fern generate --docsauthenticates to Fern withFERN_TOKENrather than over git, so this should be inert, but you know Fern's internals better than I do. If you would rather land the rest first and that line separately, say so and I will split it.Verification
make lint—All checks passed!(alsoruff check .as CI runs it)make test—5460 passed, 18 skippedmake build— built the sdist and wheelAlso ran the two CI-only gates:
scripts/check_oss_boundary.py(passed) andscripts/ci/check_public_benchmarks.py --require-files tests/golden(passed, 2 files). Python 3.13.12, macOS 15 (arm64),uv sync --extra all --extra dev.Release Impact
CHANGELOG.md