Repository navigation
Conversation
Install @usebruno/cli with npm's --min-release-age so the CLI and its transitive dependencies must have been published at least cooldown-days ago (default 2, 0 disables). This limits exposure to freshly published, possibly compromised releases. Bump setup-node from Node 22 to 24: Node 22 bundles npm 10.9.x, and --min-release-age only exists from npm 11.10.0. Node 24 bundles npm 11.19.1. Caveats: - A pinned bru-version published within the cooldown window fails to install rather than falling back to an older version. - The action now runs on Node 24, so report.js and bru itself run on Node 24 for every consumer. - cooldown-days is passed straight to npm without validation; behaviour with a non-numeric value is untested.
Resolve bru-version to a concrete @usebruno/cli version and, when this action ships a lockfile for it, install that pre-resolved dependency tree with `npm ci --ignore-scripts` instead of resolving dependencies at run time. GitHub's dependency graph / Dependabot alerts scan every lockfile. - 36 lockfiles in lockfiles/<version>/: all 24 stable 3.x and 4.x releases (3.0.0 to 4.3.0), plus every 1.x and 2.x release with at least 500 downloads in the last week per npm's per-version stats: 1.20.0, 1.30.0, 1.33.0, 1.34.1, 1.38.3, 1.40.0 (~95% of 1.x downloads) and 2.8.0, 2.8.1, 2.13.2, 2.14.2, 2.15.0, 2.15.1 (~83% of 2.x downloads). Every package resolves from registry.npmjs.org. Generated with npm 11.19.1 using --package-lock-only --ignore-scripts and a 2-day --min-release-age. - lib/resolve-version.js maps bru-version to a version the way npm does: exact versions (with or without a leading v), ranges (^3, ~4.2, 4.x) and dist-tags (latest), applying the cooldown-days cutoff. A tag picks the newest version <= the tag past the cooldown; a range prefers `latest` when it satisfies. Adds semver as an action dependency. - Resolved versions without a lockfile (other 0.x/1.x/2.x releases, or newer than the newest lockfile) fall back to `npm install -g --min-release-age` with a ::warning::, so no existing bru-version value stops working. - Locked installs go into $RUNNER_TEMP and are added to $GITHUB_PATH. - Smoke tests: ranges, a v-prefixed version and ^1 install from lockfiles, 2.1.0 uses the fallback, and a nonexistent version fails before bru runs. Caveats: - `latest` still means npm's latest dist-tag, minus the cooldown. Until a lockfile is added for a new release, it is installed via the unlocked fallback. - Lockfiles for old versions lock today's compatible dependencies, not the tree that shipped with that release. 1.20.0 and 2.8.0 were checked locally to install and pass a request against the test collection. - Adds ~6.6 MB that every consumer downloads with the action. - --ignore-scripts skips protobufjs's install script, which bru does not need at runtime. The unlocked fallback still runs install scripts, as before. - Resolution now needs `npm view` against the registry before install (previously npm install did this implicitly).
- scripts/add-version.sh <version>...: generates lockfiles/<version>/
with npm --package-lock-only --ignore-scripts and a release-age
cooldown (COOLDOWN_DAYS, default 2). Works in a temp dir, checks the
locked CLI version and that every package is from registry.npmjs.org,
and needs FORCE=1 to regenerate an existing version.
- scripts/missing-versions.sh: lists every stable version >= MIN_VERSION
(default 3.0.0) past the cooldown that has no lockfile, including
backports to older lines (e.g. 3.5.4 after 4.3.0).
- add-bruno-version.yml: daily (and manual) workflow that opens one
draft PR per missing version on branch bruno-lockfile/<version>, with
a human-review checklist, and requests review from the
LOCKFILE_REVIEWERS repo variable. It never enables auto-merge.
- A version that fails to lock or push doesn't stop the others; the
run fails at the end listing the failed versions.
- A failed reviewer request (e.g. a team, which GITHUB_TOKEN can't
resolve) is a warning, not a failure.
- A branch left without a PR by an earlier failed run gets its PR
opened on the next run. A branch whose PR was closed is not
proposed again, which is how a version is declined.
- CONTRIBUTING.md: document the cooldown, how to add/regenerate versions,
the workflow, and the repo settings that make human approval mandatory.
Caveats:
- Human review is only guaranteed once the repo has branch protection
requiring an approving review plus Code Owners review for
/lockfiles/. Draft + requested reviewers alone can be bypassed by an
admin, or by the github-actions bot approving (the "create and approve
pull requests" setting allows both).
- add-version.sh needs npm >= 11.10.0 for --min-release-age; the
workflow uses Node 24 for that.
- PRs opened with GITHUB_TOKEN don't trigger other workflows, so smoke
tests must be run manually.
- 1.x/2.x releases are not proposed automatically (MIN_VERSION).
Deleting a 3.x+ lockfile without closing a PR for it means it is
proposed again.
- The workflow script was exercised locally against a bare repo with a
stubbed gh; it has not yet run on GitHub Actions.
Mark tests/, .github/, scripts/ and CONTRIBUTING.md as export-ignore so they are left out of the tarball GitHub generates for a ref, which is what the runner downloads when a workflow uses this action. None are needed at runtime; lib/ and lockfiles/ are, so they stay. Notes: - This only affects archives. The folders are still visible when cloning or browsing the repo and still count toward repo size. GitHub reads .github/workflows from the repo, not the archive, so CI is unaffected. - Our own smoke tests use the checked-out working tree (uses: ./), so they are unaffected. - scripts/ comes from the optional generator commit; the line is harmless if that commit is dropped. - lockfiles/ (~6.5 MB uncompressed) is most of the archive and can't be excluded, since the action installs from it. - GHES installs that copy actions with actions-sync may not honour export-ignore, and it is unverified how actions/publish-action packages releases. - Check what consumers receive with: git archive HEAD | tar -t
Replace the `@v1.0.0` row in the Versioning table, which claimed a tag is immutable, with the full commit SHA of the v1.0.0 release (104e180, which upstream's v1.0.0 and v1 tags point at). Git tags can be moved, so only a SHA pin is immutable. Also explain why, and show the `@<sha> # vX.Y.Z` form, which Dependabot and Renovate keep up to date. Caveat: the SHA has to be bumped in this README by hand on each release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Install
@usebruno/clifrom committed, scannable lockfiles instead of resolving its dependency tree on every run, and add a release-age cooldown for anything that still resolves at run time. No existingbru-versionvalue stops working.Why
The action currently runs
npm install -g @usebruno/cli@<version>on every job. That resolves Bruno's whole dependency tree (about 500 packages for 4.x) at run time. A compromised release of any transitive dependency would reach every consumer within minutes of being published.With lockfiles, consumers get a fixed, reviewable dependency tree that can't change between runs. GitHub's dependency graph and Dependabot alerts cover every lockfile in the repo, so known vulnerabilities become visible instead of hidden inside a run-time install. Being visible doesn't mean the versions are free of vulnerabilities; see Known vulnerabilities in locked versions.
Weaknesses addressed
--ignore-scriptsstops dependency install scripts running on consumers' runners.scripts/add-version.shrejects git, tarball and file sources.npm cichecks every package against the sha512 hash committed in the lockfile, not against hashes the registry supplies at install time.npm auditcan now see the exact tree each version installs. This PR doesn't fix the vulnerabilities it reveals (see below).The unlocked fallback (1.x/2.x releases without a lockfile, and new releases until their lockfile is merged) only gets the CWE-506 cooldown benefit.
What changes for consumers
bru-versionis resolved to a concrete version the way npm resolves it: exact versions (with or without a leadingv), ranges such as^3,~4.2and4.x, and dist-tags such aslatest.npm ci --ignore-scriptsinto$RUNNER_TEMP. Dependencies are not resolved at run time.npm install -g, now with--min-release-age, and prints a::warning::.cooldown-daysinput, default2. Bruno and its dependencies must have been published at least this many days ago.0disables it.--min-release-age.Changes
cooldown-daysinput and the Node 24 bump.lib/resolve-version.jsresolves versions, usingsemver.CONTRIBUTING.md.scripts/add-version.shandscripts/missing-versions.sh.CONTRIBUTING.mdlists the branch-protection and CODEOWNERS settings that make human review mandatory.export-ignorefortests/,.github/,scripts/andCONTRIBUTING.md, so consumers only download what the action needs at runtime.@v1.0.0as immutable, but tags can be moved. It now shows@104e180c2e7219a915dc48b6979ddbafe0940fcd # v1.0.0, the commit upstream'sv1.0.0tag points at.Each commit message lists its own caveats in full.
Trade-offs
--ignore-scriptsskipsprotobufjs's install script, whichbrudoesn't need at runtime.npm install -gpicked up dependency fixes within semver ranges on every run. A lockfile only picks them up when it's regenerated (FORCE=1 scripts/add-version.sh <version>).Known vulnerabilities in locked versions (out of scope)
Every lockfile in this PR has known vulnerabilities. This PR doesn't introduce them: the old
npm install -gpath installs the same vulnerable packages, because most of them are pinned exactly in@usebruno/cli's ownpackage.json. The lockfiles make them visible, and Dependabot will raise alerts for them once this is merged.Fixing them means upgrading Bruno releases or overriding versions Bruno pins, which is out of scope here. Output of
npm audit --package-lock-onlyon each lockfile:npm audit fixdoesn't help much. On 4.3.0 it only gets from 10 high to 8, and it does that by downgrading the@azurepackages. The rest need new Bruno releases.Recommendation for consumers: use the newest 4.x release. Older versions have lockfiles so existing pins keep working, not because they're considered safe. These findings should also be raised with the main Bruno project, since the exact pins are theirs.
Testing
^3→ 3.5.3,v4.2.1→ 4.2.1 and^1→ 1.40.0, installed from lockfiles2.1.0through the unlocked fallbackbrurunslatestgh, covering a version that fails to lock, a reviewer request that fails, and a branch left without a PR.Reviewer checklist
LOCKFILE_REVIEWERSvariable, add CODEOWNERS for/lockfiles/, and require Code Owners review onmain.@v1consumers get the lockfiles, and update the pinned SHA in the README's Versioning section.Apologies if the above is a lot, there's quite a few process assumptions baked in, I'm not 100% sold on the automation of getting lockfiles added, but it's hopefully okay enough to get working for now.