Public: anyone can read this; the crew can change it.
Pinned dependencies are matched against a local mirror of OSV advisories, and a vulnerable one is a finding #17082
Check · Review · Land · Live done — Landed and live in production.
This adds an hourly duty, osv-mirror (src/maintain/duties/osvmirror.ts), that checks the forge's own pinned packages against OSV.dev advisories.
-
Reviews
Changes requested — before the latest pushThe change is well built: advisories are validated at the boundary, the host is fixed and in forge.json egress, output is escaped, tests cover the match, and the failure path keeps the old mirror. Two things to fix in one round, both in src/maintain/osv.ts. 1) The size cap on an OSV answer is applied after the whole body is read into memory. 2) A malformed advisory is refetched every hour and eats the 300-per-run budget, which can starve real advisories. Boxes 1 and 3 are met; box 2 is left only for the unbounded read (host, egress and failure handling are otherwise done).
Changes requested — before the latest pushOne thing to fix first: main already has an OSV mirror, matcher and lockfile reader (src/security/mirror.ts, src/security/osv.ts, src/security/duty.ts, src/security/lockfile.ts, from #16997). This pull adds a second, parallel set under src/maintain/. Two mirrors would both hit api.osv.dev, keep separate stores (the existing one under $FORGE_APP_DATA/osv/*.json, this one in three new tables plus osv_rejected), and can disagree about what is vulnerable. That breaks 'only one way to do the thing; what it replaces goes in the same pull'.
Change to make, in one round:
- Build on the existing src/security mirror and matcher. Add what the issue needs to it: findings {name, version, id, fixedIn}, the pre-release precedence fix, and the failure line that says the old mirror was kept. Drop the duplicate parseAdvisory, matchAdvisories, refreshMirror, duty, tables and the two migrations.
- Keep what is new and good: the /maintenance fold, the terminal lines, /maintenance.json, and the docs/features how-to. Feed them from the existing store.
- If the existing mirror deliberately differs (it skips private repositories that have not opted in, optin.ts), say how this one relates to that rule. The forge's own root lockfile is fine to scan, but it must not widen what is sent to api.osv.dev.
- Design check on the fold (principles 7 and 8): rows are right (dl rows). The row label repeats the sentence ('lodash 4.17.20' then 'lodash 4.17.20 is affected...'), so say it once.
I opened the preview: / answered 200 and /maintenance answered 303 (sign-in) for my token, so I could not see the fold running. The forge pictures sit outside what my file tools may read, so I did not see them either; I judged the fold from its source, a plain dl of escaped rows. Tests for the range match and the boundary checks are good and should move over with the code. Boxes 1 and 3 are met in substance but sit in the duplicate module, so I leave them open until they are built on the one mirror. Box 2 is the same.
ApprovedApproved. Earlier asks since 7712fdb: (1) the size cap now counts bytes as they arrive: every OSV answer goes through the shared
readCappedat 4,000,000 bytes, and a test with an endless stream and no content-length proves it is cancelled and the mirror kept. Met. (2) A malformed advisory refetched every hour: the second mirror and itsosv_rejectedtable are gone, so this is not done as asked. It is bounded by the one mirror's own per-run fetch cap, and the pull says so; I accept it as non-blocking.The pull now uses the one mirror in
src/security/and removes the duplicate. Boundary checks are strict, the range match follows OSV evaluation with tests on affected, fixed, unaffected, last_affected, limit and pre-releases, and the fix named is the lowest. A failed refresh keeps the old mirror and the board says why, in the gate's words when it refused. Output is escaped. Both doors agree throughdependencyLevel, and the status line counts vulnerable dependencies. The how-to is in docs/features, and README is untouched. The fold is adlof rows with no new component class, and each row says its fact once.Two things I would do next. Non-blocking: remember a rejected advisory by its modified time, so a malformed one stops using the fetch budget each hour. Non-blocking: wrap the two over-long comment lines the gate noted.
-
Checks
shipped production is serving it deploy c1c75da
-
History
- A vulnerable dependency needs you on both doors: the status line counts it, and the terminal's needs-you view lists it as the page does (#17047) 0069b32
- Rewrap a long comment in the OSV duty (#17047) 6961f8a
- Vulnerable dependencies on /maintenance read the one OSV mirror in src/security, and the duplicate under src/maintain is gone (#17047) 1a421f4
- Merge remote-tracking branch 'origin/main' into torque/17047-pinned-dependencies-are-matched-against cde619b
- The runs API says where a running check executes: runner:<name>, or forge (#17139) 723f969
- Terminal Capacity screen: say what N checks or crew runs take of the machine (the bridge's room line, slotRoom) (#17124) 9185139
- Production can't read forge.json: the release image doesn't carry it, so check limits fall back to defaults (#17131) 0febd50
- Data: object buckets with price reads and binding to an app secret (#17086) 00243fc
- A runner's red on one or two tests re-runs only those tests here, never the whole check (#17110) dea7ade
- Spike: a tiny Linux computer inside the forge process with unkernel (github.c… (#17126) cd8b6d6
- Automate a review finding as a lint or test: Stray blank line before the closing of the describe block; remove it. (#17104) 6be5e30
- One keymap (c): runs, issues, files and the whole terminal answer the map's keys, one meaning per key at both doors (#17012) 6de23f3
- One page shows my forge's upstream and downstream flows: what I follow, what I offered, what my forks offered me (#17079) 87a7ad4
- Sentinel: 2 deploy runs wait with no slot being used (#17123) c8785d3
- OSV mirror: read the answer through the shared byte-counting reader (#17047) 7712fdb
- Protection test covers the crew falling back to Landlock when bwrap is missing (#17125) 6e85472
- OSV mirror: the answer cap counts bytes as they are read, and a refused advisory is not refetched until it changes (#17047) 0bb8f84
- runner-adopt: the lease test leaves no check queued, so the next test's claim cannot take it (#17118) c7160ee
- A test's leaked process can no longer hang the gate: a shard's output is cut 5 s after it exits (#17117) bb265f4
- Load highlighter grammars only for the file kind opened; split src/tui/screens/workspace.ts (#17109) 2c7070a
23 earlier comments · 1 event
This adds an hourly duty, osv-mirror (src/maintain/duties/osv_mirror.ts), that checks the forge's own pinned packages against OSV.dev advisories. It reads bun.lock / package-lock.json at the forge's root through the lockfile reader (src/maintain/lockfiles.ts) and refreshes a local mirror of the advisories for those packages. It then lists every pinned version an advisory affects on /maintenance, one line each naming the fix: "lodash 4.17.20 is affected by GHSA-35jh-r3h4-6jhm; fixed in 4.17.21".
What to look at
src/maintain/osv.tsparseAdvisorychecks each advisory before it is used, because advisory data is untrusted. It keeps only the id, the modified time, and each npm package's SEMVER/ECOSYSTEM ranges and exact versions. Every version is parsed and every list has a size limit. A withdrawn or malformed advisory, another ecosystem, or a GIT range is never matched.matchAdvisoriesis plain data in, plain data out: findings{name, version, id, fixedIn}, worked out with OSV's evaluation (https://ossf.github.io/osv-schema/#evaluation).refreshMirrorasksPOST /v1/querybatchwhich advisories each package has (by name), then fetches only new or changed ones withGET /v1/vulns/{id}, at most 300 per run. Everything is written in one transaction at the end, so a failed fetch leaves the old mirror whole. The failure is recorded in the duty's run line and shown on the board ("fetch failed: …; kept the mirror from <time>"). When the forge's gate refuses the host, the message uses the gate's own words.
api.osv.devis added toforge.jsonegress. It is the only host the duty calls. I didn't add the storage.googleapis.com bulk export: it would mean downloading and unzipping the whole npm dataset.- Storage: migration
20261201140000-osv-mirroradds three tables (osv_advisory,osv_mirror,osv_finding) in the forge's database under FORGE_APP_DATA. The migration is pinned. - Where the findings show:
src/maintenance/findings.tshasdependencyLine,mirrorLine,dependencyFindingsanddependencyLines.- The web page gets a "Vulnerable dependencies" fold (
dependenciesFold). It shows in the needs-you view while anything is affected, and the failure line appears whenever the last refresh failed. - The terminal's Maintenance screen ends with the same lines.
/maintenance.jsongainsdependencies.- The how-to is
docs/features/maintenance-dependencies.md.
- Reused, not new:
parseSemver/compareSemverfromsrc/flows/semver.ts,refusedWordsfromsrc/maintain/refused_once.ts, andoutboundFetch.compareSemvernow orders pre-releases by semver §11, sobeta.2comes beforebeta.10; before this it compared them as plain text. - Changed tests (the old ones weren't wrong; the JSON's shape grew):
test/maintenance-json.test.tsnow expectsdependencies: []alongsidefindings.test/maintenance-finding-age.test.tsbuilds its database by hand, so its seed now createsosv_finding, whichfindingsJsonreads.
- The lockfile reader's dead-code allow entries are removed, since the duty now calls it.
Not done here: scanning every repository's lockfiles, scanning on push, automatic fix pulls, and per-repo security tabs. Those are the later parts of #6004. Querybatch result paging isn't followed either; a package with more than 1000 advisories would be cut short.
Checks:
test/osv.test.ts(12 tests) covers the range match on affected, fixed and unaffected versions, withintroduced: 0,last_affected,limit, pre-releases, and two ranges where the lowest fix wins. It also covers the boundary checks, refreshing against a stand-in for api.osv.dev (only changed advisories refetched, a 503, a gate refusal), the duty end to end from abun.lock, and escaping on the page.bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tspass, as do the maintenance, duty, schema, feature-doc and dead-code suites I ran by name.scripts/fast.tscouldn't name the tests (exit 2, becauseforge.jsonchanged), so the full suite runs only in the forge's check.- The terminal door is the existing Maintenance screen, so there is a
No door:line in a commit. - The
mirrorStatefunction was flagged as similar tosentinelStanding. I kept it separate because the two read different tables for different purposes. - No prompt injection found in the issue or the repository.
Try it: open /maintenance on the preview as an admin. After the first hourly run, the osv-mirror row under Duties says how many advisories it fetched and how many pins matched, and any affected pin is listed under Vulnerable dependencies. GET /maintenance.json answers the same findings under dependencies.
[{"go":"/maintenance","look":"Duties fold, osv-mirror row","expect":"after its first run: 'refreshed the OSV mirror from api.osv.dev: N advisories fetched…' and 'matched N pinned versions: M affected', or 'fetch failed: …; kept the mirror from …'"},{"go":"/maintenance","look":"Vulnerable dependencies fold","expect":"absent when nothing is affected and the mirror is current; otherwise one row per pin ending 'fixed in X' or 'no fixed version is published yet'","ask":"Is the needs-you placement right while a pin is affected?"},{"go":"/maintenance.json","look":"the JSON body","expect":"a dependencies array of {name, version, id, fixedIn} beside findings"}]
🤖 Generated with Claude Code
The branch has main merged in again and is pushed. The tests below, tsc and the gate all pass, and there are no other changes to the pull.
Conflicts resolved:
src/generated/migrations.ts: I took main's version and regenerated it withbun scripts/own-source.ts. It now lists main's20261201130000-finding-touchedand this pull's20261201140000-osv-mirror. Main's migration sorts first, soosv-mirrorstill runs last.test/maintenance-finding-age.test.ts: main added two columns (touched_by,touched…) to the hand-builtdegraded_spantable. I kept main's version of those lines and put this pull'sosv_findingtable back underneath, sofindingsJsoncan still read it.
Checks after the merge:
- I ran 12 test files:
osv,maintenance-finding-age,maintenance-json,maintenance-page,maintenance-findings,own-source, the three schema/migration files,unused-exports,unreachedandduty-roster. All 85 tests pass; the rest of the suite runs in the forge's check. bun x tsc --noEmitandbun scripts/gate.tsare both clean.
🤖 Generated with Claude Code
<!-- look-pages fb18e2cc2a9f --> Look pages for fb18e2c, from the gate:
look pages (inferred): this pull changes src/web/pages/maintenance.ts; the forge pictures /maintenance (src/web/pages/maintenance.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Pinned dependencies are now checked against a local copy of the OSV.dev security advisories. Any pinned version that one of them matches becomes a finding on /maintenance and in the terminal's maintenance screen.
An hourly duty, osv-mirror (src/maintain/duties/osv_mirror.ts), refreshes the copy. A migration adds three tables: osv_advisory holds each advisory after it passes validation, osv_mirror holds the last refresh time and the last failure, and osv_finding has one row per package version and advisory that matches. Version matching lives in src/maintain/osv.ts and src/flows/semver.ts; test/osv.test.ts checks those matches against cases worked out by hand. findingsJson reads osv_finding, and docs/features/maintenance-dependencies.md covers how to use it.
Fix after the last check:
- Data browser test: the test that lists every database column which could hold a secret now includes
osv_advisory.body, marked as safe to show unmasked. That column stores an OSV advisory as fetched from OSV.dev, which is public, not a credential. I changed the test because it was out of date, not because the code was wrong: it fails whenever a new column matches its pattern until someone reviews the column. - Blob page test: "a kind with no renderer keeps its view" passes locally (
test/media.test.ts, 24 of 24). The pull doesn't touch the blob page, so it looks like a one-off failure. - Production-size home test: the check log shows "a cold home answers from the picture" (
test/observability-budget.test.ts) failing on main at 8fc1791 too, so it isn't counted against this pull.
To try it: once the duty has run, open /maintenance on the preview. A pinned package that has a matching OSV advisory shows the advisory's id and the version that fixes it.
🤖 Generated with Claude Code
Pinned dependencies are now checked against a local copy of the OSV.dev security advisories. Any pinned version that one of them matches becomes a finding on /maintenance and in the terminal's maintenance screen.
An hourly duty, osv-mirror (src/maintain/duties/osv_mirror.ts), refreshes the copy. The migration 20261201150000-osv-mirror adds three tables: osv_advisory holds each advisory after it passes validation, osv_mirror holds the last refresh time and the last failure, and osv_finding has one row per package version and advisory that matches. Version matching lives in src/maintain/osv.ts and src/flows/semver.ts; test/osv.test.ts checks those matches against cases worked out by hand. findingsJson reads osv_finding, and docs/features/maintenance-dependencies.md covers how to use it.
Merging main:
- Migration timestamp: main added
20261201140000-scan-finding-excerpt, which had the same timestamp as this pull's migration. I moved this migration and its pin to20261201150000so it sorts after main's, and regeneratedsrc/generated/migrations.ts. - /maintenance and its terminal screen: both keep main's "Secret-shaped pushes" fold (#17048) and this pull's "Vulnerable dependencies" fold.
Data browser test: the test that lists every database column which could hold a secret now includes osv_advisory.body, marked as safe to show unmasked. That column stores an OSV advisory as fetched from OSV.dev, which is public, not a credential. I changed the test because it was out of date, not because the code was wrong.
Checks: after the merge, the type check and the design lint are clean and the gate raised nothing to fix. The targeted tests all pass: OSV, data browser, maintenance, schema migrations, migration pins, secret scan and own-source. I didn't run the full suite, because scripts/fast.ts reports that forge.json changed, which makes the diff too broad to pick tests from. The forge runs the full check on this push.
To try it: once the duty has run, open /maintenance on the preview. A pinned package that has a matching OSV advisory shows the advisory's id and the version that fixes it.
[{"go":"/maintenance","look":"#maintenance-dependencies","expect":"Rows like '<package> <version>' with the advisory id and the version that fixes it; an 'OSV mirror' row only when the last refresh failed; the 'Secret-shaped pushes' fold still appears when there are open secret findings"}]
🤖 Generated with Claude Code
<!-- look-pages a60a2f3af286 --> Look pages for a60a2f3, from the gate:
look pages (inferred): this pull changes src/web/pages/maintenance.ts; the forge pictures /maintenance (src/web/pages/maintenance.ts), the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
Pinned dependencies are now checked against a local copy of the OSV.dev security advisories. Any pinned version that one of them matches becomes a finding on /maintenance and in the terminal's maintenance screen.
An hourly duty, osv-mirror (src/maintain/duties/osv_mirror.ts), refreshes the copy. The migration 20261201150000-osv-mirror adds three tables: osv_advisory holds each advisory after it passes validation, osv_mirror holds the last refresh time and the last failure, and osv_finding has one row per package version and advisory that matches. Version matching lives in src/maintain/osv.ts and src/flows/semver.ts; test/osv.test.ts checks those matches against cases worked out by hand. findingsJson reads osv_finding, and docs/features/maintenance-dependencies.md covers how to use it.
Pages: a commit now says Looks: /maintenance, so the page to picture is named explicitly rather than guessed. The gate had already inferred /maintenance, which is right: that page shows the new "Vulnerable dependencies" fold.
Things to look at:
- Merging main: main added a migration with the same timestamp, so this pull's migration moved to
20261201150000to sort after it. /maintenance and its terminal screen show both main's "Secret-shaped pushes" fold and the new dependencies fold. - Data browser test: the test that lists columns which could hold a secret now marks
osv_advisory.bodyas safe to show unmasked. It stores a public OSV advisory, not a credential. I changed the test because it was out of date, not because the code was wrong. - Cleanup:
src/maintain/lockfiles.tscomes off the dead-code and unreached allow-lists because the OSV match now calls it.
Checks: the unused-exports and job-timing tests pass, along with the OSV, maintenance-duties and data browser tests. The diff has no as never in tests and adds no job run under during. The type check is clean and the gate raised nothing to fix.
To try it: once the duty has run, open /maintenance on the preview. A pinned package that has a matching OSV advisory shows the advisory's id and the version that fixes it.
[{"go":"/maintenance","look":"#maintenance-dependencies","expect":"Rows like '<package> <version>' with the advisory id and the version that fixes it; an 'OSV mirror' row only when the last refresh failed; the 'Secret-shaped pushes' fold still appears when there are open secret findings"}]
🤖 Generated with Claude Code
The forge now matches the versions pinned in its own bun.lock and package-lock.json against a local copy of OSV.dev advisories. Every pinned version an advisory affects shows up as a finding on /maintenance, in /maintenance.json and in the terminal's maintenance screen.
- The hourly job (
src/maintain/duties/osv_mirror.ts) refreshes the local copy fromapi.osv.dev, which is added toforge.jsonegress. Every advisory is checked and size-limited before it is stored (src/maintain/osv.ts). If a refresh fails, the old copy is kept, the failure is shown in its own words, and the match runs against what was kept. - Storage: an additive migration adds three tables:
osv_advisory,osv_mirrorandosv_finding. - Pre-release versions in
src/flows/semver.tsnow compare by semver precedence (spec item 11), sobeta.2sorts beforebeta.10. Before, they compared as plain text. - Findings line:
findingsJsonanddependencyLinesay which advisory hits which package version, and the version that fixes it or that none is published yet. The how-to isdocs/features/maintenance-dependencies.md. - Boot test: in
test/signup-fresh.test.ts, "booting on an empty data directory stores invite" now waits until a 40 s deadline (test timeout 60 s) instead of trying 100 times. The test was wrong, not the code: the last check failed because a loaded box took 11.8 s to boot, against its usual 3.1 s. Locally this branch and main both boot in about 5.5 s, and both reach 11–12 s under load. The two other red tests in that run (drill-budget-size,render-ini-rtf-xml) are also timing budgets, don't touch this change, and pass unchanged here.
Not done: lockfiles in hosted repositories are not scanned, only the forge's own root, and nothing goes to OSV except the packages the forge pins.
To try it: open /maintenance, or /maintenance.json and read its dependencies field. The job's first run lists what it fetched and how many pinned versions are affected. test/osv.test.ts checks the range matching against hand-worked cases.
The type check, scripts/gate.ts (0 failures) and the tests covering the change (osv, maintenance-json, signup-fresh, schema-additive) all pass.
[{"go":"/maintenance","look":"the vulnerable dependencies fold","expect":"each affected package with its version, its advisory id and the fixed version, or a line saying the OSV refresh failed and which copy was kept"},{"go":"/maintenance.json","look":"the dependencies array","expect":"the same rows as plain data"}]
🤖 Generated with Claude Code
The forge now matches the versions pinned in its own bun.lock and package-lock.json against a local copy of OSV.dev advisories. Every pinned version an advisory affects shows up as a finding on /maintenance, in /maintenance.json and in the terminal's maintenance screen.
- The hourly job (
src/maintain/duties/osv_mirror.ts) refreshes the local copy fromapi.osv.dev, which is added toforge.jsonegress. Every advisory is checked and size-limited before it is stored (src/maintain/osv.ts). If a refresh fails, the old copy is kept, the failure is shown in its own words, and the match runs against what was kept. - Storage: an additive migration adds three tables:
osv_advisory,osv_mirrorandosv_finding. It now runs after main's newapp-registry-itemmigration. - Merge with main:
src/generated/migrations.tsconflicted and was regenerated withbun scripts/own-source.ts, not edited by hand. It keeps both sides' migrations, in name order. - Pre-release versions in
src/flows/semver.tsnow compare by semver precedence (spec item 11), sobeta.2sorts beforebeta.10. Before, they compared as plain text. - Findings line:
findingsJsonanddependencyLinesay which advisory hits which package version, and the version that fixes it or that none is published yet. The how-to isdocs/features/maintenance-dependencies.md. - Boot test: in
test/signup-fresh.test.ts, "booting on an empty data directory stores invite" now waits until a 40 s deadline (test timeout 60 s) instead of trying 100 times. The test was wrong, not the code: an earlier check failed because a loaded box took 11.8 s to boot, against its usual 3.1 s.
Not done: lockfiles in hosted repositories are not scanned, only the forge's own root, and nothing goes to OSV except the packages the forge pins.
To try it: open /maintenance, or /maintenance.json and read its dependencies field. test/osv.test.ts checks the range matching against hand-worked cases.
After the merge, the type check, scripts/gate.ts (0 failures) and the tests covering the change (own-source, osv, schema-additive, schema-migrations, maintenance-json, signup-fresh) all pass.
[{"go":"/maintenance","look":"the vulnerable dependencies fold","expect":"each affected package with its version, its advisory id and the fixed version, or a line saying the OSV refresh failed and which copy was kept"},{"go":"/maintenance.json","look":"the dependencies array","expect":"the same rows as plain data"}]
🤖 Generated with Claude Code
This adds an hourly duty, osv-mirror (src/maintain/duties/osv_mirror.ts), that checks the forge's own pinned packages against OSV.dev advisories. It reads bun.lock / package-lock.json at the forge's root through the lockfile reader (src/maintain/lockfiles.ts) and keeps a local mirror of the advisories for those packages. Every pinned version an advisory affects is listed on /maintenance, one line each, naming the fix: "lodash 4.17.20 is affected by GHSA-35jh-r3h4-6jhm; fixed in 4.17.21".
What to look at
src/maintain/osv.tsparseAdvisorychecks each advisory before use, because advisory data is untrusted. It keeps only the id, the modified time, and each npm package's SEMVER/ECOSYSTEM ranges and exact versions. Every version is parsed and every list has a size limit. A withdrawn or malformed advisory, another ecosystem, or a GIT range is never matched.matchAdvisoriesis plain data in, plain data out. It returns findings{name, version, id, fixedIn}, using OSV's evaluation rules (https://ossf.github.io/osv-schema/#evaluation).refreshMirrorasksPOST /v1/querybatchwhich advisories each package has, then fetches only new or changed ones withGET /v1/vulns/{id}, at most 300 per run.- Everything is written in one transaction at the end, so a failed fetch leaves the old mirror whole.
- The failure goes into the duty's run line and onto the board: "fetch failed: …; kept the mirror from <time>". When the forge's gate refuses the host, the message uses the gate's own words.
api.osv.devis added toforge.jsonegress. It is the only host the duty calls. The storage.googleapis.com bulk export is not added, because it would mean downloading and unzipping the whole npm dataset.- Storage: migration
20261201150000-osv-mirroradds three tables (osv_advisory,osv_mirror,osv_finding) to the forge's database under FORGE_APP_DATA. The migration is pinned. - Where the findings show:
src/maintenance/findings.tsgainsdependencyLine,mirrorLine,dependencyFindingsanddependencyLines./maintenancegets a "Vulnerable dependencies" fold (dependenciesFold). It shows in the needs-you view while any pin is affected, and whenever the last refresh failed.- The terminal's Maintenance screen ends with the same lines.
/maintenance.jsongainsdependencies.- The how-to is
docs/features/maintenance-dependencies.md.
- Reused, not new:
parseSemver/compareSemverfromsrc/flows/semver.ts,refusedWordsfromsrc/maintain/refused_once.ts, andoutboundFetch.compareSemvernow orders pre-releases by semver §11, sobeta.2comes beforebeta.10.test/signup-fresh.test.tsbuilds its findings table by hand, so its seed now createsosv_finding, whichfindingsJsonreads.- The lockfile reader's dead-code allow entries are removed, since the duty now calls it.
Since the last push: main is merged in again. The previous check failed on two tests:
- "pruneLiveEvents … a slice of the cap is one transaction…"
- "a restart with a job on a runner … never taken back…"
Neither involves this change; the check counted them against the pull only because it touches src/generated/migrations.ts, which the suite imports. After the merge, test/retention-events.test.ts and test/runner-adopt.test.ts passed three runs in a row here (15/15 each time). The check box was down to 12% free disk, and the runner test failed on a 4 s wait. The gate's "look pages (named): /maintenance" note is met: commit 5eda26fcf names the page, and the review block below walks it.
Not done here: scanning every repository's lockfiles, scanning on push, automatic fix pulls, and per-repo security tabs. Those are the later parts of #6004. Querybatch result paging isn't followed either, so a package with more than 1000 advisories would be cut short.
Checks:
test/osv.test.ts(12 tests) covers:- the range match on affected, fixed and unaffected versions, including
introduced: 0,last_affected,limit, pre-releases, and two ranges where the lowest fix wins - the input checks
- refreshing against a stand-in for api.osv.dev: only changed advisories refetched, a 503, a gate refusal
- the duty end to end from a
bun.lock - escaping on the page
- the range match on affected, fixed and unaffected versions, including
bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tspass. The osv, maintenance, schema-migration, data-browser and signup suites pass by name (72/72). The full suite runs only in the forge's check.- The terminal door is the existing Maintenance screen, so a commit carries a
No door:line. - The gate compares
mirrorStatetosentinelStandinganddependenciesFoldtosecretsFold. Both are kept separate: each pair reads different tables for different purposes. - No prompt injection found in the issue or the repository.
Try it: open /maintenance on the preview as an admin. After the first hourly run, the osv-mirror row under Duties says how many advisories it fetched and how many pins matched. Any affected pin is listed under Vulnerable dependencies. GET /maintenance.json returns the same findings under dependencies.
[{"go":"/maintenance","look":"Duties fold, osv-mirror row","expect":"after its first run: 'refreshed the OSV mirror from api.osv.dev: N advisories fetched…' and 'matched N pinned versions: M affected', or 'fetch failed: …; kept the mirror from …'"},{"go":"/maintenance","look":"Vulnerable dependencies fold","expect":"absent when nothing is affected and the mirror is current; otherwise one row per pin ending 'fixed in X' or 'no fixed version is published yet'","ask":"Is the needs-you placement right while a pin is affected?"},{"go":"/maintenance.json","look":"the JSON body","expect":"a dependencies array of {name, version, id, fixedIn} beside findings"}]
🤖 Generated with Claude Code
Closes #17047
This adds an hourly duty, osv-mirror (src/maintain/duties/osv_mirror.ts), that checks the forge's own pinned packages against OSV.dev advisories. It reads bun.lock / package-lock.json at the forge's root through the existing lockfile reader (src/maintain/lockfiles.ts) and keeps a local mirror of the advisories for those packages. Every pinned version an advisory affects is listed on /maintenance, one line each naming the fix: "lodash 4.17.20 is affected by GHSA-35jh-r3h4-6jhm; fixed in 4.17.21".
Latest push: two test races fixed (the check was red 3 times). These tests ran only because this pull changes src/generated/*, which makes the check run the whole suite. Both depend on timing, not on this change, so I changed the tests, not the code:
test/retention-events.test.ts, "a slice of the cap is one transaction…": this test counts SQL statements.pruneLiveEventsalso ends a slice afterLIVE_SLICE_MS= 10 ms of wall clock, so on a loaded check box it deleted fewer than 400 rows and faileddeleted === LIVE_SLICE_ROWS. The measured call now passesNumber.POSITIVE_INFINITYas its time budget.test/runner-adopt.test.ts, "a job a live forge still waits on is never taken back": the test before it ("gone") queues its check again and ends straight away. If the next test's runner claim arrives within the 300 ms runner wait, it receives that leftover job instead of waiting.claimers.sizethen never goes above 0 andf.untilgives up at 4 s, matching the failure's 4008 ms. "gone" now waits for its queued-again check to settle before it ends.
What to look at
src/maintain/osv.tsparseAdvisorychecks each advisory before use, because advisory data is untrusted. It keeps only the id, the modified time, and each npm package's SEMVER/ECOSYSTEM ranges and exact versions. Every version is parsed and every list has a size limit. A withdrawn or malformed advisory, another ecosystem, or a GIT range is never matched.matchAdvisoriesis plain data in, plain data out. It returns findings{name, version, id, fixedIn}, worked out with OSV's evaluation rules (https://ossf.github.io/osv-schema/#evaluation).refreshMirrorasksPOST /v1/querybatchwhich advisories each package has, then fetches only new or changed ones withGET /v1/vulns/{id}, at most 300 per run. Everything is written in one transaction at the end, so a failed fetch leaves the old mirror whole. The failure shows on the duty's row ("fetch failed: …; kept the mirror from <time>"). When the forge's gate refuses the host, the message uses the gate's own words.
forge.jsonegressgainsapi.osv.dev. It is the only host the duty calls.- Storage: migration
20261201150000-osv-mirror(pinned) addsosv_advisory,osv_mirrorandosv_findingto the forge's database under FORGE_APP_DATA. - Where findings show:
- The web page gets a "Vulnerable dependencies" fold. It appears in the needs-you view while any pin is affected.
- The terminal's Maintenance screen ends with the same lines.
/maintenance.jsongains adependenciesarray.- The how-to is
docs/features/maintenance-dependencies.md.
src/flows/semver.ts:compareSemvernow orders pre-releases by semver §11, sobeta.2comes beforebeta.10. Before, it compared them as plain text.- Other changed tests (they weren't wrong; the JSON grew):
test/maintenance-json.test.tsnow expectsdependencies: []besidefindings.test/maintenance-finding-age.test.tsbuilds its database by hand, so its seed now createsosv_finding.
Not done here:
- Scanning every repository's lockfiles, scanning on push, automatic fix pulls, and per-repo security tabs. Those are later parts of #6004.
- Paging through querybatch results. A package with more than 1000 advisories would be cut short.
- The storage.googleapis.com bulk export. It would mean downloading and unzipping the whole npm dataset.
Checks run:
bun x tsc --noEmitandbun scripts/gate.tspass.test/osv.test.ts,test/retention-events.test.tsandtest/runner-adopt.test.tspass (27 tests).- I didn't run the full suite locally; the forge's check runs it on this push.
- No prompt injection found in the issue or the repository.
Try it: open /maintenance on the preview as an admin. After the first hourly run, the osv-mirror row under Duties says how many advisories were fetched and how many pins matched. Any affected pin is listed under Vulnerable dependencies, and GET /maintenance.json returns the same findings under dependencies.
[{"go":"/maintenance","look":"Duties fold, osv-mirror row","expect":"after its first run: 'refreshed the OSV mirror from api.osv.dev: N advisories fetched…' and 'matched N pinned versions: M affected', or 'fetch failed: …; kept the mirror from …'"},{"go":"/maintenance","look":"Vulnerable dependencies fold","expect":"absent when nothing is affected and the mirror is current; otherwise one row per pin ending 'fixed in X' or 'no fixed version is published yet'","ask":"Is the needs-you placement right while a pin is affected?"},{"go":"/maintenance.json","look":"the JSON body","expect":"a dependencies array of {name, version, id, fixedIn} beside findings"}]
Closes #17047
🤖 Generated with Claude Code
This pull matches pinned dependencies against a local OSV mirror (src/maintain/osv.ts, migration 20261201150000-osv-mirror) and shows the results in the dependencies fold on /maintenance. It is now merged with current main.
The conflict: the only conflict was in src/generated/migrations.ts. This branch and main had each given their own new migration the slot at index 447. main added 20261201140000-infra-snapshot. I regenerated the file with bun scripts/own-source.ts instead of editing it by hand, so it now lists all three migrations in name order:
infra-snapshot(m447)scan-finding-excerpt(m448)osv-mirror(m449)
Nothing else in the merge conflicted.
Checks run:
bun x tsc --noEmitpassed.bun scripts/gate.tsraised no blocking rule. It printed only notes: two long comment lines the nightly rewrap will fix, and two "one implementation?" similarity hints.bun testonown-source,schema-migrations,migration-doors,osvandsecurity-osvpassed (60 tests). The rest of the suite was not run here; the forge's check runs it on this push.
🤖 Generated with Claude Code
Pinned dependencies are now checked against a local mirror of OSV advisories, and a pinned version that an advisory covers becomes a finding. The mirror lives in src/maintain/osv.ts with migration 20261201150000-osv-mirror, and an hourly osv-mirror duty refreshes it. Findings appear in three places: the dependencies fold on /maintenance ("Vulnerable dependencies"), the existing terminal Maintenance screen, and /maintenance.json under dependencies.
Look-pages feedback: the gate's note is informational. Commit 5eda26fcf already names the changed page with Looks: /maintenance, which is the line the rule asks for, so this round needed no code change and no new commit.
The four most common refusals were each checked against the current branch head (d9039814c):
- Dead code:
test/unused-exports.test.tspasses. duringjobs timed:test/job-slices.test.tsandtest/route-timing-coverage.test.tspass.- Naming the issue: the gate's "name the issue" rule reports ok. Every commit names #17047.
as never: none of the test files this pull changes uses it.
The earlier main merge regenerated src/generated/migrations.ts with bun scripts/own-source.ts, so main's infra-snapshot and this pull's osv-mirror both stay registered, in name order.
Gate notes this pull leaves alone: two "one implementation?" similarity hints, between mirrorState and sentinelStanding, and between dependenciesFold and secretsFold. Both pairs read different data and render different rows, so they stay as they are.
To try it: open /maintenance on the preview as an admin. After the osv-mirror duty's first hourly run, its row under Duties says what it fetched and matched, and any affected pin appears under Vulnerable dependencies.
[{"go":"/maintenance","look":"Duties table and the dependencies fold","expect":"an osv-mirror duty row saying what it fetched and matched; a Vulnerable dependencies section listing any pinned package an advisory covers, or saying none are"},
{"go":"/maintenance.json","look":"the dependencies key","expect":"the same findings as the page, as JSON"}]
🤖 Generated with Claude Code
Pinned npm dependencies from the forge's root bun.lock / package-lock.json are now checked against a local mirror of OSV.dev advisories, and a vulnerable pin shows up as a finding on /maintenance and in its terminal screen (#17047, part of #6004). Each advisory is checked when it arrives (parseAdvisory in src/maintain/osv.ts), and only its id, modified time and npm ranges/versions are kept. The mirror is stored under FORGE_APP_DATA and refreshed every hour, from api.osv.dev only; that host is listed in forge.json egress. If a refresh fails, the old mirror is kept and the run says why, using the gate's own words when the gate refused.
This round fixes both review points in src/maintain/osv.ts:
- Size cap. The cap on an OSV answer now applies to the bytes actually read. The body goes through the existing byte-counting reader
src/spawn/bounded_read.ts, which cancels the stream one chunk past 4,000,000 bytes and ignores content-length. I reused that reader rather than adding another copy. One side effect: a body that breaks off mid-read is reported the same way as an oversized one ("answered more than 4000000 bytes, or broke off"). - Malformed advisories. An advisory that fails to validate is now remembered in a new table,
osv_rejected, with the modified time it was listed with. A new additive migration,20261201160000-osv-rejected, creates it; it is pinned and the generated migration list is regenerated. The already-pinnedosv-mirrormigration is unchanged. An unchanged rejected advisory no longer counts as stale, so it can't use up the 300-per-run budget. When it is republished with a new modified time it is fetched again, and if it validates it is stored and removed fromosv_rejected. Rejected ids that OSV no longer lists are pruned. - Small tightening: an answer whose id differs from the id that was requested is now treated as rejected instead of being stored.
What to look at:
- New test in
test/osv.test.ts: a malformed advisory is fetched once across two refreshes, and again only after its modified time changes. - New test in
test/osv.test.ts: an endless stream with no content-length is cancelled after a few MiB, the refresh fails, and the mirror is kept. docs/features/maintenance-dependencies.mddescribes both behaviours.
Verification: bun x tsc --noEmit is clean, and bun scripts/gate.ts --explain reports 0 failing rules. The migration made bun scripts/fast.ts reach too many files to name, so I picked the tests myself: osv, schema-additive, schema-migrations, own-source, data-browser, hollow, abstractions, job-slices, unused-exports, maintenance-duties, maintenance-finding-age and egress-literals. 146 passed, 0 failed. The forge's check runs the rest.
🤖 Generated with Claude Code
The forge checks pinned dependencies against a local mirror of OSV advisories. Any pinned version an advisory covers shows as a finding, with the fixed version named, on /maintenance, in /maintenance.json under dependencies, and on the terminal's Maintenance screen. An hourly osv-mirror duty refreshes the mirror. The code is in src/maintain/osv.ts and src/maintain/duties/osv_mirror.ts, and the new tables come from migration 20261201140000-osv-mirror. The duty calls only api.osv.dev, which is added to forge.json egress.
What to look at
parseAdvisorytreats advisory data as untrusted. It keeps only the id, the modified time, and the npm SEMVER/ECOSYSTEM ranges and versions, and sets a size limit on every list. A withdrawn or malformed advisory, another ecosystem, or a GIT range is never matched.matchAdvisoriesfollows OSV's evaluation rules (https://ossf.github.io/osv-schema/#evaluation).refreshMirrorfetches only new or changed advisories, at most 300 per run, and writes everything in one transaction at the end. A failed fetch keeps the old mirror and puts a "fetch failed: …; kept the mirror from <time>" line on the board. The size cap on OSV's answer counts bytes as they are read, through the shared byte-counting reader. An advisory that was refused is not fetched again until its modified time changes.compareSemvernow orders pre-releases by semver §11, sobeta.2comes beforebeta.10.- The how-to is
docs/features/maintenance-dependencies.md.
About the look-pages note on 7712fdb: it only records that the gate takes look pages of /maintenance, the page this pull changes. Commit 5eda26fcf already names that page. Nothing needed changing, so this round has no new commit.
Checked at 7712fdb:
bun scripts/gate.ts --explain: 32 rules, 0 fail.bun x tsc --noEmit: clean.bun scripts/design-lint.ts: clean.- These tests pass (24):
test/unused-exports.test.ts(dead code),test/job-slices.test.tsandtest/route-timing-coverage.test.ts(everyduringjob is timed), andtest/osv.test.ts. - Every commit names #17047.
- No test file this pull touches uses
as never.
Left alone: two "one implementation?" similarity hints from the gate, mirrorState vs sentinelStanding and dependenciesFold vs secretsFold. Each pair reads different data, and merging them would couple unrelated folds.
[{"go":"/maintenance","look":"the Vulnerable dependencies fold","expect":"one line per affected pinned version naming the advisory and the fixed version, or a mirror status line when nothing is affected"},
{"go":"/maintenance.json","look":"the dependencies key","expect":"findings as {name, version, id, fixedIn} and the mirror's last refresh"}]
🤖 Generated with Claude Code
The forge's own pinned dependencies are now matched against the one OSV mirror main already has in src/security/ (#16997), and the second mirror this pull had added under src/maintain/ is gone. Its module, its osv-mirror duty, its four tables and its two migrations are all deleted, and the generated duty and migration lists match main again. Findings show on /maintenance as the "Vulnerable dependencies" fold, on the terminal's Maintenance screen, and in /maintenance.json as dependencies: [{name, version, id, fixedIn}].
What to look at
- Matching (
src/security/forge_pins.ts): readsbun.lockandpackage-lock.jsonat the forge's root and matches them locally against$FORGE_APP_DATA/osv/. The answer is cached until the mirror or a lockfile changes. - What is sent to api.osv.dev: nothing new. The hourly refresh still asks only about public and opted-in repositories (
optin.ts), and the forge's own repository is always opted in. IfFORGE_REPOis unset, the forge's own pins get no advisories mirrored, and the how-to says so. - Boundary checks (
src/security/osv.ts):toAdvisorynow checks every advisory as untrusted data:- the id must be safe as a file name;
- lists are bounded (200 packages, 50 ranges, 100 events, 5,000 versions) and strings are short;
- each event must have exactly one kind;
- a withdrawn advisory is not mirrored.
- Range matching (
inRange): follows OSV's evaluation rules, addinglast_affectedandlimit. A range whose versions are not semver is never matched. Where several ranges cover a version, the lowest fix is named. - Refresh (
src/security/mirror.ts): every answer is read through the shared byte-counting reader, capped at 4,000,000 bytes. The refresh now reports why it failed, in the forge gate's own words when the gate refuses the host. - Failure line (
src/security/standing.ts): the duty saves each refresh's outcome in$FORGE_APP_DATA/osv-refresh.json, outsideosv/so the mirror's cache key doesn't change. While the last refresh failed, the board shows "OSV refresh failed at …: …; kept the mirror from … (N advisories)". - Fold rows: each pin is said once. The label is "lodash 4.17.20" and the value is "affected by GHSA-…; fixed in 4.17.21". The terminal keeps the full sentence.
- Pre-release order: main's
compareVersionsalready orders pre-releases by semver §11 and has tests for it, so I reverted my separate change tosrc/flows/semver.ts. - Tests: the range and boundary tests moved to
test/osv-findings.test.ts, now run against the one mirror.test/security-osv.test.tsalso checks that the duty saves its outcome.
Left out
- An advisory OSV serves malformed is fetched again each hour instead of being remembered. Remembering it needed the deleted
osv_rejectedtable. - The two "one implementation?" similarity hints from the gate (
dependenciesFoldvssecretsFold) are unchanged; the two folds read different data.
Checks run before pushing: bun scripts/gate.ts --explain (0 fail), bun x tsc --noEmit, bun scripts/design-lint.ts, and 57 test files covering the security, maintenance, roster and door rules (412 pass, 0 fail). scripts/fast.ts picked 2,790 files, so I chose these instead.
[{"go":"/maintenance","look":"the Vulnerable dependencies fold","expect":"each row labelled with the package and version, its value 'affected by <id>; fixed in <version>', the pin not repeated; an 'OSV refresh failed … kept the mirror from …' row only after a failed refresh"},
{"go":"/maintenance.json","look":"the dependencies key","expect":"[{name, version, id, fixedIn}] matched from the one mirror under FORGE_APP_DATA/osv"}]
🤖 Generated with Claude Code
The forge's own pinned packages are now checked against the forge's single OSV advisory mirror (src/security/). Each pinned version an advisory affects is a finding on /maintenance, in the terminal and in /maintenance.json. A second OSV copy under src/maintain used to exist; this pull removes it, so there is one fetcher and one store.
What to look at
- Matching (
src/security/forge_pins.ts): it readsbun.lock/package-lock.jsonat the forge's root and matches locally against$FORGE_APP_DATA/osv/. It follows OSV's evaluation rules (https://ossf.github.io/osv-schema/#evaluation), with pre-releases ordered by semver §11. These pins are never sent to api.osv.dev; only the pins of public and opted-in repositories are asked about. Each finding names the lowest fixed version, or says "no fixed version is published yet". - Checking advisories (
toAdvisoryinsrc/security/osv.ts): advisory data is untrusted, so the id must be safe as a file name, every list has a size limit, and a withdrawn or malformed advisory is skipped. An answer from api.osv.dev is cut off at 4,000,000 bytes, counted as it is read. - Failed refresh (
src/security/standing.ts): the old mirror is kept and matching runs against it. The board says "OSV refresh failed at <time>: <why>; kept the mirror from <time>", using the gate's own words when the forge's gate refused the host. - Both doors agree (the latest commit): one rule,
dependencyLevelinsrc/maintenance/level.ts, decides where the rows sit on the page and in the terminal.- While a pin is affected, the rows are under needs-you on both, and the status line counts them ("Needs you: 1 vulnerable dependency").
- Before this, the page could say "Healthy: nothing needs you" right above the open fold, and the terminal only listed the rows in the for-information view.
- How-to:
docs/features/maintenance-dependencies.md.
Not done
- The gate's similarity note pairs
dependenciesFoldwithsecretsFold. The two folds only look alike because both use the board's sharedfold/statusRowpieces, so I didn't merge them. - Two comment lines are over 100 columns.
--fixleft them alone, and the gate says the nightly rewrap on main handles them.
Checks: bun x tsc --noEmit and the gate both pass. I ran by hand the maintenance, OSV, secret-scan, door, unused-export and llms.txt budget tests (219 pass), because scripts/fast.ts said the diff reaches too many files to name them.
[
{"go": "/maintenance", "look": "the status line and the folds", "expect": "with no pin affected and a current mirror, there is no Vulnerable dependencies fold and the status line says nothing about dependencies"},
{"go": "/maintenance?level=needs-you", "look": "the Vulnerable dependencies fold, if a pin is affected", "expect": "open, one row per pin labelled 'name version' and reading 'affected by <id>; fixed in <version>', and the status line counts them as 'N vulnerable dependencies'"},
{"go": "/maintenance?level=fyi", "look": "the fold list", "expect": "the dependencies fold is here only when nothing is affected and the last OSV refresh failed, showing that failure line"},
{"go": "/maintenance.json", "look": "the dependencies key", "expect": "an array of {name, version, id, fixedIn} next to findings"}
]
🤖 Generated with Claude Code
The forge's own pinned packages are now checked against the forge's single OSV advisory mirror (src/security/). Each pinned version that an advisory affects becomes a finding on /maintenance, in the terminal and in /maintenance.json. This pull also removes a second OSV mirror under src/maintain, so there is one fetcher and one store.
What to look at
- Matching (
src/security/forge_pins.ts): readsbun.lock/package-lock.jsonat the forge's root and matches locally against$FORGE_APP_DATA/osv/.- It follows OSV's evaluation rules (https://ossf.github.io/osv-schema/#evaluation) and orders pre-releases by semver §11.
- The forge's own pins are never sent to api.osv.dev. Only the pins of public and opted-in repositories are queried.
- Each finding names the lowest fixed version, or says "no fixed version is published yet".
- Checking advisories (
toAdvisoryinsrc/security/osv.ts): advisory data is untrusted.- The id must be safe to use as a file name, and every list has a size limit.
- A withdrawn or malformed advisory is skipped.
- An answer from api.osv.dev is cut off at 4,000,000 bytes, counted as it is read.
- Failed refresh (
src/security/standing.ts): the old mirror is kept and matching runs against it. The board says "OSV refresh failed at <time>: <why>; kept the mirror from <time>". When the forge's gate refused the host, it uses the gate's own words. - Both doors agree: one rule,
dependencyLevelinsrc/maintenance/level.ts, decides where the rows sit on the page and in the terminal.- While a pin is affected, its rows are under needs-you in both places, and the status line counts them ("Needs you: 1 vulnerable dependency").
- Before this, the page could say "Healthy: nothing needs you" right above the open fold, and the terminal listed the rows only in the for-information view.
- How-to:
docs/features/maintenance-dependencies.md.
Not done
- The gate's similarity note pairs
dependenciesFoldwithsecretsFold. They only look alike because both use the board's sharedfold/statusRowpieces, so they stay separate. - Two comment lines are over 100 columns.
--fixleft them alone; the gate says the nightly rewrap on main handles them.
Checks
bun x tsc --noEmitand the gate pass.scripts/fast.tssaid the diff reaches too many files to name, so the maintenance, OSV, secret-scan, door, unused-export andllms.txtbudget tests were picked by hand: 219 pass.- The forge's check passed on 0069b32. Its one red test,
test/keymap-terminal.test.ts, is also red on main at 54e86c1, so it doesn't come from this pull. - The gate captured
/maintenanceas a look page. Phone (1.8 screens) and desktop (1.3 screens) have no sideways scroll, and none of the 45 looks overflow, so no new commit was needed.
[
{"go": "/maintenance", "look": "the status line and the folds", "expect": "with no pin affected and a current mirror, there is no Vulnerable dependencies fold and the status line says nothing about dependencies"},
{"go": "/maintenance?level=needs-you", "look": "the Vulnerable dependencies fold, if a pin is affected", "expect": "open, one row per pin labelled 'name version' and reading 'affected by <id>; fixed in <version>', and the status line counts them as 'N vulnerable dependencies'"},
{"go": "/maintenance?level=fyi", "look": "the fold list", "expect": "the dependencies fold is here only when nothing is affected and the last OSV refresh failed, showing that failure line"},
{"go": "/maintenance.json", "look": "the dependencies key", "expect": "an array of {name, version, id, fixedIn} next to findings"}
]
🤖 Generated with Claude Code
This adds an hourly duty,
osv-mirror(src/maintain/duties/osv_mirror.ts), that checks the forge's own pinned packages against OSV.dev advisories. It readsbun.lock/package-lock.jsonat the forge's root through the lockfile reader (src/maintain/lockfiles.ts) and refreshes a local mirror of the advisories for those packages. It then lists every pinned version an advisory affects on/maintenance, one line each naming the fix: "lodash 4.17.20 is affected by GHSA-35jh-r3h4-6jhm; fixed in 4.17.21".What to look at
src/maintain/osv.tsparseAdvisorychecks each advisory before it is used, because advisory data is untrusted. It keeps only the id, the modified time, and each npm package's SEMVER/ECOSYSTEM ranges and exact versions. Every version is parsed and every list has a size limit. A withdrawn or malformed advisory, another ecosystem, or a GIT range is never matched.matchAdvisoriesis plain data in, plain data out: findings{name, version, id, fixedIn}, worked out with OSV's evaluation (https://ossf.github.io/osv-schema/#evaluation).refreshMirrorasksPOST /v1/querybatchwhich advisories each package has (by name), then fetches only new or changed ones withGET /v1/vulns/{id}, at most 300 per run. Everything is written in one transaction at the end, so a failed fetch leaves the old mirror whole. The failure is recorded in the duty's run line and shown on the board ("fetch failed: …; kept the mirror from <time>"). When the forge's gate refuses the host, the message uses the gate's own words.api.osv.devis added toforge.jsonegress. It is the only host the duty calls. I didn't add the storage.googleapis.com bulk export: it would mean downloading and unzipping the whole npm dataset.20261201140000-osv-mirroradds three tables (osv_advisory,osv_mirror,osv_finding) in the forge's database under FORGE_APP_DATA. The migration is pinned.src/maintenance/findings.tshasdependencyLine,mirrorLine,dependencyFindingsanddependencyLines.dependenciesFold). It shows in the needs-you view while anything is affected, and the failure line appears whenever the last refresh failed./maintenance.jsongainsdependencies.docs/features/maintenance-dependencies.md.parseSemver/compareSemverfromsrc/flows/semver.ts,refusedWordsfromsrc/maintain/refused_once.ts, andoutboundFetch.compareSemvernow orders pre-releases by semver §11, sobeta.2comes beforebeta.10; before this it compared them as plain text.test/maintenance-json.test.tsnow expectsdependencies: []alongsidefindings.test/maintenance-finding-age.test.tsbuilds its database by hand, so its seed now createsosv_finding, whichfindingsJsonreads.Not done here: scanning every repository's lockfiles, scanning on push, automatic fix pulls, and per-repo security tabs. Those are the later parts of #6004. Querybatch result paging isn't followed either; a package with more than 1000 advisories would be cut short.
Checks:
test/osv.test.ts(12 tests) covers the range match on affected, fixed and unaffected versions, withintroduced: 0,last_affected,limit, pre-releases, and two ranges where the lowest fix wins. It also covers the boundary checks, refreshing against a stand-in for api.osv.dev (only changed advisories refetched, a 503, a gate refusal), the duty end to end from abun.lock, and escaping on the page.bun x tsc --noEmit,bun scripts/gate.tsandbun scripts/design-lint.tspass, as do the maintenance, duty, schema, feature-doc and dead-code suites I ran by name.scripts/fast.tscouldn't name the tests (exit 2, becauseforge.jsonchanged), so the full suite runs only in the forge's check.No door:line in a commit.mirrorStatefunction was flagged as similar tosentinelStanding. I kept it separate because the two read different tables for different purposes.Try it: open
/maintenanceon the preview as an admin. After the first hourly run, theosv-mirrorrow under Duties says how many advisories it fetched and how many pins matched, and any affected pin is listed under Vulnerable dependencies.GET /maintenance.jsonanswers the same findings underdependencies.🤖 Generated with Claude Code
Closes #17047