Repository navigation
ci(security): scan bun.lock with osv-scanner and report to code scanning - #628
Merged
Merged
Conversation
GitHub's dependency graph does not resolve bun.lock: its SBOM lists 36 of the 206 packages the lock pins, so Dependabot alerts are blind to most of this repo's dependencies. Add .github/workflows/osv-scanner.yml (push to main, pull requests, weekly, dispatch). It runs osv-scanner v2.7.0 (sha256-verified release binary), which reads bun.lock natively (206 packages), uploads SARIF to code scanning under category "osv-scanner", and fails if bun.lock ever drops out of the scan. scripts/osv-gate.ts then fails the job on a HIGH/CRITICAL finding (CVSS >= 7.0, or an unscored advisory labelled HIGH/CRITICAL) that osv-scanner.toml does not accept; every waiver there must carry an ignoreUntil date and a reason, and a lapsed waiver blocks again. osv-scanner.toml starts empty: the scan is clean today and no risk is accepted. Tests: scripts/osv-gate.test.ts (gate rules, allowlist format, the CLI's exit codes, the workflow's permissions and pins); the existing supply-chain-pins test covers the new workflow's SHA pins and its job-scoped write grant. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gascity-infra-agent
Bot
requested a review
from julianknutsen
as a code owner
November 5, 2026 04:41
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
|
This PR has been added to the review queue. Track progress: https://factory.gascity.com/city/maintainer-city/runs/gcg--9223372036832388256 |
…out scripts Review fixes for the osv-scanner workflow: - OSV MAL-* records (the OpenSSF malicious-packages feed) carry no CVSS score and no severity label, so the gate classed a known-malicious package as UNSCORED and passed it. A group with a MAL-* id or alias now rates MALICIOUS and blocks; a waiver can still accept a false positive. Checked against a real osv-scanner 2.7.0 report (flatmap-stream 0.1.1, MAL-2025-20690). - The scan job holds security-events: write and hands its token to `bun install` as NODE_AUTH_TOKEN. The gate needs only smol-toml, so the install now runs with --ignore-scripts: no dependency lifecycle script runs under that token. The workflow test pins the flag. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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
GitHub's dependency graph does not resolve
bun.lock. The repository SBOM lists 36 packages, whilebun.lockpins 206, so Dependabot alerts cannot see most of this repo's dependencies. Dependabot'sbunecosystem does version updates only, not security updates.This PR adds
.github/workflows/osv-scanner.yml. It runs on pushes to main, on pull requests, weekly (Monday 05:17 UTC) and on manual dispatch.bun.locknatively and finds all 206 packages. The step fails ifbun.lockever drops out of the scan.osv-scanner, so OSV findings become code-scanning alerts. That is the coverage the dependency graph should have given. The upload is skipped on fork PRs.scripts/osv-gate.tsfails the job on a HIGH or CRITICAL finding thatosv-scanner.tomldoes not accept. HIGH or CRITICAL means CVSS >= 7.0, or, for an unscored advisory, a HIGH or CRITICAL label.ignoreUntildate and areason. A waiver accepts a finding through any id or alias. Once its date passes it accepts nothing, so the scan does not flap on accepted risks and turns red again when a waiver lapses.osv-scanner.tomlstarts empty, because no risk is accepted today.bun audit. The step inci.ymlstays. It checks the npm advisory feed on each PR; this workflow adds the OSV database, the scheduled re-check and the alerts.Review fixes (max-effort review, 2026-11-05, commit 546cdbf)
MAL-*records (the OpenSSF malicious-packages feed) carry no CVSS score and no severity label, so the gate classed a known-malicious package as UNSCORED and let it pass. A finding with aMAL-*id or alias is now ratedMALICIOUSand blocks; a waiver can still accept a false positive. This was checked against a real osv-scanner 2.7.0 report (flatmap-stream 0.1.1,MAL-2025-20690): before the fix that row was listed below the gate, after it the row blocks.security-events: writeand passes its token tobun installasNODE_AUTH_TOKEN. The gate needs only smol-toml, so the install now runs with--ignore-scripts, and the workflow test pins that flag.osv-gate.test.tsnow has 20 tests. A mutation pass removed the 7.0 threshold, the expiry comparison, alias matching, the label fallback, the input checks, the exit codes, theMAL-*rule and--ignore-scripts; the tests caught all 14 mutants. The PR's CI is green on 546cdbf, and the install log showsbun install --frozen-lockfile --ignore-scriptsfollowed by the gate'sNo unaccepted HIGH/CRITICAL finding.CVEs
This PR fixes no CVE. It closes a coverage gap from round 4. The 2026-11-04 cve.now cross-check found registry clean (its two hits were false matches), but noted that Dependabot is blind to
bun.lock.Verification
Scanned bun.lock file and found 206 packages, with no vulnerabilities. The gate exited 0. The scan step was also run verbatim in a scratch copy.bun test scripts/osv-gate.test.ts scripts/supply-chain-pins.test.tspasses: 40 tests.osv-gate.test.tscovers the gate rules: the 7.0 threshold, the label fallback, matching by alias, and a waiver that still accepts on its expiry day but not the day after.supply-chain-pins.test.tscovers the new workflow's SHA pins and confirms there is no top-level write.ci.ymlnow also assertsscripts/osv-gate.test.tsexists, like the other test files it guards.blacksmith-*runner-label notice thatci.ymlalso gets, because this repo has no actionlint config.Rollout
Merge. The first push to main uploads the baseline SARIF, and alerts appear under Security > Code scanning with the tool
osv-scanner. Nothing is deployed.Rollback
Revert this PR. To also clear the alerts, delete the
osv-scanneranalyses:Follow-up (not in this PR)
.github/dependabot.ymluses thenpmecosystem on a bun repo, so version PRs touchpackage.jsonbut notbun.lock. Switching it topackage-ecosystem: bunwould keep the lock in step.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.