Skip to content

ci: cover every workflow with the hardening guards, and fix the gaps they surface - #126

Merged
rng1995 merged 2 commits into
NVIDIA:mainfrom
dberzan:harden/workflow-guards-cover-every-workflow
Oct 20, 2026
Merged

rng1995 merged 2 commits into
NVIDIA:mainfrom
dberzan:harden/workflow-guards-cover-every-workflow

Conversation

@dberzan

@dberzan dberzan commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #125.

tests/test_ci_workflows.py already 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.yml and publish-docs.yml were never loaded, and both had drifted.

workflow every action SHA-pinned permissions: declared persist-credentials: false
ci.yml yes yes 10 / 10
security.yml yes yes 4 / 4
dco.yml yes yes 0 / 1 → 1 / 1
publish-docs.yml no no 0 / 1 → 1 / 1

The workflows

publish-docs.yml is the only workflow that puts a secret in a job environment (FERN_TOKEN), and was the least hardened of the four.

  • actions/checkout@v4 was the single unpinned uses: reference out of 36 in the repository. It now uses 9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0, the SHA already used 14 times here.
  • It had no permissions: block, so the job inherited the repository default GITHUB_TOKEN scope. It now declares contents: read, matching the other three workflows.
  • It had no persist-credentials: false, so the token was written to .git/config and stayed readable by every later step in the job — including npm install and fern generate.
  • npm install -g fern-api resolved its whole transitive tree at run time. It now installs the version fern/fern.config.json pins, derived exactly as ci.yml's docs lane already does, with the same format guard and a pinned setup-node so 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.yml only reads history with git log and git show, so it gets persist-credentials: false too.

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 from test_changed_workflows_* to test_every_workflow_*, since the old names would now be wrong. Three guards are added or widened:

  • every workflow declares permissions:, and no permissions: value anywhere is write-all — including job-level blocks, which override the workflow-level one;
  • action pinning now also covers job-level uses:, i.e. reusable workflows, which have no steps list for the step-level walk to reach;
  • publish-docs.yml never hardcodes the Fern CLI version again.

Granular write scopes (contents: write and 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:

FAILED test_every_workflow_pins_every_action_to_a_commit
FAILED test_every_workflow_does_not_persist_checkout_credentials
FAILED test_every_workflow_declares_least_privilege_permissions

And against a probe workflow that declares permissions: contents: read at the top, escalates one job to permissions: 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.yml is the only workflow that never runs on a pull request — it is push to main only, gated on github.run_number > 1. So the persist-credentials: false change on the publish path cannot be exercised before merge. fern generate --docs authenticates to Fern with FERN_TOKEN rather 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

  • I am familiar with the Contributing Guidelines
  • Added or updated focused tests
  • Updated documentation for user-visible changes — n/a, no user-visible behaviour changes
  • Ran make lint — All checks passed! (also ruff check . as CI runs it)
  • Ran make test — 5460 passed, 18 skipped
  • Ran make build — built the sdist and wheel
  • Did not add credentials, private datasets, or proprietary benchmark content

Also ran the two CI-only gates: scripts/check_oss_boundary.py (passed) and scripts/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

  • No user-visible release note needed
  • Updated CHANGELOG.md

Comment thread tests/test_ci_workflows.py Resolved
Comment thread .github/workflows/publish-docs.yml Resolved

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

dberzan added a commit to dberzan/SkillEvaluator that referenced this pull request Sep 1, 2026
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>
dberzan added a commit to dberzan/SkillEvaluator that referenced this pull request Sep 1, 2026
… 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>
@dberzan

dberzan commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

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 scripts

Confirmed the chain against the registry before changing anything:

fern-api@5.66.1              scripts: {}   hasShrinkwrap: false
  └─ optionalDependencies:   @boundaryml/baml  ^0.219.0
       └─ dependencies:      @scarf/scarf      ^1.3.0      → 1.4.0
            └─ scripts.postinstall: "node ./report.js"

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: --omit=optional is silently ignored for a --global install. Installing fern-api@5.66.1 globally with and without the flag produces identical trees — @scarf/scarf and its postinstall land either way. Reproduced on npm 10.9.9 (what setup-node 22 ships) and 11.12.1. It only takes effect for a local install. So the patch you were reading claimed a property it didn't have.

Now: fern/package.json and fern/package-lock.json are committed, and both workflows run

npm ci --prefix fern --ignore-scripts --omit=optional
./fern/node_modules/.bin/fern <check|generate --docs>

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: --ignore-scripts, and with npm ci being a local install --omit=optional now genuinely applies, leaving fern-api alone in the tree. Calling the binary by path rather than PATH closes the substitution gap too.

Verified end to end rather than reasoned about: the exact command sequence installs one package, and fern check reports 0 errors against this repo. That also settles the question I couldn't answer before — docs validation does not need @boundaryml/baml.

Two notes on the shape, both reversible if you'd rather:

  • The lock adds a second home for the CLI version alongside fern/fern.config.json. A guard asserts package.json, package-lock.json and fern.config.json all agree, so they can't drift — that was the failure this PR already fixed once and I didn't want to reintroduce it.
  • node_modules/ is now in .gitignore; it wasn't before.

P2 — local references

Agreed. uses: ./... skips the SHA requirement after validating the path doesn't escape the repo. Two edges worth naming:

  • My first version exempted ./.github/actions/build@main — ./-prefixed but carrying an @ref, which isn't local syntax. Fixed; a ./ reference with an @ falls through to the SHA check.
  • docker:// is deliberately not exempted. A container tag is mutable, so rejecting it is intended, not an oversight.

Also in here

  • ci.yml's docs lane got the same install. Not really optional: the new guard covers every workflow, and a guard with a carve-out for one file isn't the guard I want. Its exposure is smaller — no secret, contents: read — but it's the same command.
  • docs/README.md, docs/AGENTS.md, docs/developer-guide.mdx told contributors to run the unpinned global install. They now use the same lockfile install.
  • test_every_workflow_declares_least_privilege_permissions → test_every_workflow_declares_explicit_permissions. It only rejects write-all and a missing block, not every broad grant — a granular contents: write is legitimate for a release workflow. The name promised more than the assertion delivered; the assertion is unchanged.

Say the word on any of these and I'll drop them.

Verification

ruff check . clean, 5463 passed, 18 skipped, make build succeeds, plus the two gates that live only in ci.yml — check_oss_boundary.py and check_public_benchmarks.py --require-files tests/golden. Every new or relaxed guard was checked against a throwaway probe: reverting ci.yml to npm install --global fails two of them, and changing fern.config.json's version alone fails the drift guard. Probes aren't committed.

@dberzan

dberzan commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@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 npm ci rather than flags — and that's the part worth your eyes rather than mine.

Flagging here only because I can't re-request a review as an outside contributor.

Happy to rebase onto current main if it helps — the branch is 5 commits behind, no conflicts.

@dberzan
dberzan requested a review from rng1995 September 7, 2026 03:42

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread fern/package.json Resolved
Comment thread tests/test_ci_workflows.py Resolved

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rng1995

rng1995 commented Sep 13, 2026

Copy link
Copy Markdown
Collaborator

@dberzan Please address all review comments to merge the PR.

@dberzan

dberzan commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@chrisknvidia Thanks for catching both — verified and fixed in 4f81e43.

P2 (npm flag substring check): confirmed by reading tests/test_ci_workflows.py directly — the guard checked "--ignore-scripts" in line, and npm ci --ignore-scripts=false (or --no-ignore-scripts) satisfies that substring while doing the opposite. Same issue on the --package-lock-only check. Replaced both with a _npm_flag_active helper that parses npm's actual negation forms (--no-<flag>, --<flag>=false|0) and takes the last occurrence on the line, matching npm's own last-flag-wins behavior. A self-review before pushing found the first version of that helper had the same class of bug (checked negation before the flag, so --no-x --x misreported as inactive; a \b boundary let --ignore-scripts-if-untrusted count as the real flag) — both fixed, with unit tests directly on the helper covering all of this, including the two exact bypass strings from your comment.

P1 (stale Fern CLI pin): fern-api was pinned at 5.66.1 (2026-07-08); bumped to 5.121.0 (current latest, comfortably above the 5.106.0 your org requires) across fern/package.json, fern.config.json, and a regenerated fern/package-lock.json. Added a floor assertion (>= 5.106.0) so a future re-pin below that fails the test suite instead of failing silently at publish time. Verified the real install-and-check sequence works against the new lockfile: npm ci --prefix fern --ignore-scripts --omit=optional && fern check → 0 errors.

Also flagged: test_publish_docs_installs_the_fern_cli_from_the_committed_lockfile — the guard on the job that runs next to FERN_TOKEN — still had the old substring check even after the general guard was fixed. Switched it too, so that job isn't the one guard lagging behind.

Verified: ruff clean, full suite 6,026 passed / 51 skipped, both CI-only gates (check_oss_boundary.py, check_public_benchmarks.py), make build. One unrelated failure in tests/test_harbor_local_mode.py::test_evaluator_python_path_uses_only_selected_runtime_prefix reproduces identically on main — not something this PR touches or introduced.

Branch is current with main as of this push.

Comment thread tests/test_ci_workflows.py Resolved
Comment thread tests/test_ci_workflows.py Resolved
@rng1995

rng1995 commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

@dberzan - Please resolve review comments so that we can merge the PR.

@dberzan

dberzan commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@rng1995 Both findings from the 2026-09-16 review are fixed in e27ff57, pushed with a merge of the current base.

Case-insensitive actions/checkout matching. Confirmed: two call sites matched actions/checkout@ literally, and a step spelled Actions/Checkout@<sha> runs the same action while being invisible to both — including to the persist-credentials: false check the filter exists to enforce. The second site (test_gitleaks_uses_event_specific_full_history_scopes) wasn't in the review; it had the same hole. Both now compare through _is_checkout_step, which case-folds the repository half of uses:. An unpinned uses: actions/checkout now matches too — the pin guard is what rejects that, but until it runs the step still checks out a credentialed workspace.

Failing closed on unrecognized npm forms. Confirmed, and it was the silent kind: cd fern && npm install, env npm install and npm --prefix fern install were not mis-evaluated by the anchored patterns, they were not seen at all. Adding cases to the regex would have left the next unthought-of form equally invisible, so each run: block is now split into the commands a shell would run and each one's argv is inspected, with leading assignments, wrappers (env, sudo, …) and compound-statement keywords stripped. Anything carrying the word npm that does not come out as a plain invocation — bash -c "npm install", an unmodelled wrapper, a line no shell could read — fails the suite rather than passing through it.

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:

doctored workflow before after
Actions/Checkout@<sha>, no persist-credentials missed caught
cd fern && npm install missed caught
env npm install missed caught
npm --prefix fern install missed caught
npm ci --ignore-scripts false missed caught
bash -c "npm install" missed caught (unclassifiable)
curl https://host/doc#install && npm install missed caught

The fifth row is a third form of the bypass fixed in 4f81e43, found by running npm rather than reading its docs: npm consumes a following literal true/false as a boolean flag's value, so npm ci --ignore-scripts false disables the flag that _npm_flag_active reported as active (npm --ignore-scripts false config get ignore-scripts → false). =0, =1 and TRUE npm rejects outright, so the helper now accepts only the two literals npm accepts and treats every other value as off.

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 #, so an install after a URL fragment vanished silently; a quoted punctuation argument was mistaken for a command separator, cutting argv short so a later --no-ignore-scripts went unread; if ...; then npm ci; fi and npm --version both failed as unclassifiable; and the lockfile-install selector accepted npm install --prefix ci, whose option value merely reads as ci, as the reviewed install in the FERN_TOKEN job. The splitter is now a quote-aware scanner rather than shlex's lexer, and all five have regression probes.

Verified: ruff check . clean; full suite 6,425 passed, 51 skipped. The one failure, test_harbor_local_mode.py::test_evaluator_python_path_uses_only_selected_runtime_prefix, reproduces with these changes stashed and on this repository's own main, and is untouched here. Both CI-only gates pass when invoked as ci.yml invokes them — including check_oss_boundary.py --root . --allowlist config/oss_boundary_allowlist.json, which earlier notes on this branch had recorded as failing; that was an artifact of running it without those arguments. python -m build succeeds.

One adjacent gap I did not close here, since you didn't raise it and it would widen this PR: npx is invisible to these guards entirely. npx --yes fern-api@latest check resolves and executes from the registry — exactly what test_no_workflow_resolves_a_node_dependency_tree_from_the_registry exists to prevent — and _npm_commands returns nothing for it. No workflow here uses npx today, so this is preventative rather than a live hole, and it is your call whether it belongs in this PR, a follow-up, or nowhere. Happy to add it if you want it.

I've left both threads open for you to confirm.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@rng1995
rng1995 force-pushed the harden/workflow-guards-cover-every-workflow branch from c6c3b28 to c6f80d7 Compare September 23, 2026 02:37
@rng1995
rng1995 enabled auto-merge (squash) September 23, 2026 02:41
chrisknvidia added a commit to dberzan/SkillEvaluator that referenced this pull request Sep 25, 2026
Signed-off-by: Christopher Kevin <christopherk@nvidia.com>
@rng1995
rng1995 disabled auto-merge September 28, 2026 20:36

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread tests/test_ci_workflows.py Resolved

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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_MENTION now treats the parameter-expansion operators inside ${...} (-, =, +, ?, /) as word boundaries and the closing } as a terminator. NPM_BIN=${UNSET:-npm}; "$NPM_BIN" install and 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/checkout matching 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 chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chrisknvidia

chrisknvidia commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

@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
@dberzan
dberzan force-pushed the harden/workflow-guards-cover-every-workflow branch from 14a3e16 to 47ead34 Compare October 14, 2026 08:42
@dberzan

dberzan commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

@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.
You and @rng1995 are credited as co-authors on the commit.
Checked locally on the new head: ruff check . clean; the workflow and classifier tests pass (84); the OSS-boundary and public-benchmark gates pass; python -m build, twine check --strict and npm ci --prefix fern … && fern check all pass. The full suite has the same failures as plain main (intermittent Harbor process-reaping/timing tests), none introduced here.
The npm guard still rejects every bypass form from the review rounds, including ${NPM:-npm} parameter expansion.
One thing you may want to adjust: the ### Security CHANGELOG entry sits under ## 0.3.0 rather than ## Unreleased. An earlier merge from main carried it there, and it's unchanged from what you approved, so I left it. Happy to move it if you'd like.

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py that main had 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.py and tests/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.

@rng1995
rng1995 merged commit a053d03 into NVIDIA:main Oct 20, 2026
17 checks passed
rng1995 added a commit that referenced this pull request Oct 20, 2026
The Security entries from #126 landed under 0.3.0, but #126 merged
after v0.5.0. Move them unchanged into the 0.6.0 section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
@rng1995 rng1995 mentioned this pull request Oct 20, 2026
11 tasks done
rng1995 added a commit that referenced this pull request Oct 20, 2026
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>
rng1995 added a commit that referenced this pull request Oct 22, 2026
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>
chrisknvidia pushed a commit that referenced this pull request Oct 30, 2026
…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>
chrisknvidia pushed a commit that referenced this pull request Oct 30, 2026
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>
chrisknvidia pushed a commit that referenced this pull request Oct 30, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Workflow hardening guards only cover two of the four workflows

3 participants