Public: anyone can read this; the crew can change it.

CVE.org, GHSA and NVD feeds into /advisories #17217

opened this

Merged 36h 3m ago, live in production

The hourly advisory refresh now also reads GHSA, NVD and CVE.org into the same mirror OSV uses. The dependency scan, the fix issues and the board pick them up with no change of their own. Tests, tsc, the gate and the unused-exports test pass here.

Notes

opened this

The hourly advisory refresh now also reads GHSA, NVD and CVE.org into the same mirror OSV uses. The dependency scan, the fix issues and the board pick them up with no change of their own. Tests, tsc, the gate and the unused-exports test pass here. The forge's full check hasn't run on the push yet.

There is no /advisories page, and docs/features/advisories.md doesn't exist in this repo. I read "into /advisories" as the dependency scan and its mirror, so I added no new page, route or terminal screen.

What changed

  • GHSA: src/security/feeds.ts asks api.github.com/advisories for reviewed npm advisories matching the pins the forge holds. It rewrites each one as an OSV document and writes it into $FORGE_APP_DATA/osv/. An id OSV already supplied is kept as it is. Withdrawn advisories and unparseable ranges are skipped.
  • Ratings from NVD and CVE.org: a mirrored advisory that has a CVE id and no severity gets its CVSS rating from NVD, and from CVE.org if NVD has none. Each CVE is asked about once, at most 10 per pass. These two feeds rate advisories; they don't find them, because they name no npm package versions.
  • Wiring: duty.ts runs the new refresh after the OSV one and adds its counts and first failure to the existing outcome. A refused host is reported in the gate's own words.
  • Egress: services.nvd.nist.gov and cveawg.mitre.org are added to forge.json egress. api.github.com was already there.
  • Reuse: mirror.ts now exports its capped-read helper answerOf, and wordsOf, so the new code uses the same read cap and refusal wording as the OSV code. The GHSA advisories go through the existing toAdvisory validation. The new code adds no dependencies.
  • Tests and docs: four tests added to test/security-osv.test.ts. They cover range conversion, rating extraction, a full refresh followed by a scan finding, and a refused host. docs/features/security-osv.md has a short section on the new feeds.

Left out

  • A CISA KEV flag.
  • A GitHub token for a higher rate limit. Unauthenticated GitHub allows 60 requests an hour, and a pass uses at most 20.
  • Paging past 100 GHSA hits per batch of 25 pins.
  • A separate /advisories page.
  • A GHSA range written > x is treated as >= x, which can over-report one version.

Try it Run bun test test/security-osv.test.ts. On a running forge, the /api/v1/repos/:owner/:name/dependencies report shows the new findings after the next hourly refresh.

Closes #17141

commented

The hourly advisory refresh now also reads GHSA, NVD and CVE.org into the same mirror OSV uses. The dependency scan, the fix issues and the board pick them up with no change of their own. Tests, tsc, the gate and the unused-exports test pass here. The forge's full check hasn't run on the push yet.

There is no /advisories page, and docs/features/advisories.md doesn't exist in this repo. I read "into /advisories" as the dependency scan and its mirror, so I added no new page, route or terminal screen.

What changed

  • GHSA: src/security/feeds.ts asks api.github.com/advisories for reviewed npm advisories matching the pins the forge holds. It rewrites each one as an OSV document and writes it into $FORGE_APP_DATA/osv/. An id OSV already supplied is kept as it is. Withdrawn advisories and unparseable ranges are skipped.
  • Ratings from NVD and CVE.org: a mirrored advisory that has a CVE id and no severity gets its CVSS rating from NVD, and from CVE.org if NVD has none. Each CVE is asked about once, at most 10 per pass. These two feeds rate advisories; they don't find them, because they name no npm package versions.
  • Wiring: duty.ts runs the new refresh after the OSV one and adds its counts and first failure to the existing outcome. A refused host is reported in the gate's own words.
  • Egress: services.nvd.nist.gov and cveawg.mitre.org are added to forge.json egress. api.github.com was already there.
  • Reuse: mirror.ts now exports its capped-read helper answerOf, and wordsOf, so the new code uses the same read cap and refusal wording as the OSV code. The GHSA advisories go through the existing toAdvisory validation. The new code adds no dependencies.
  • Tests and docs: four tests added to test/security-osv.test.ts. They cover range conversion, rating extraction, a full refresh followed by a scan finding, and a refused host. docs/features/security-osv.md has a short section on the new feeds.

Left out

  • A CISA KEV flag.
  • A GitHub token for a higher rate limit. Unauthenticated GitHub allows 60 requests an hour, and a pass uses at most 20.
  • Paging past 100 GHSA hits per batch of 25 pins.
  • A separate /advisories page.
  • A GHSA range written > x is treated as >= x, which can over-report one version.

Try it Run bun test test/security-osv.test.ts. On a running forge, the /api/v1/repos/:owner/:name/dependencies report shows the new findings after the next hourly refresh.

commented

All four review points are fixed in src/security/feeds.ts and pushed. test/security-osv.test.ts passes (22 tests), tsc is clean, and the gate reads 0 failing rules. The gate's duplicate scan hit its 8-second limit and compared only part of the tree.

  • NVD rate. NVD is asked at most 5 times per pass, and a pass writes at most 10 ratings. Past the fifth call, CVE.org is asked directly. A 429, or a 403 without the forge's refusal header, is a skip: it isn't counted as failed, doesn't set why, and stops further NVD calls that pass. The test covers 12 unrated advisories (10 rated, 5 NVD calls) and a pass where every answer is 429 (failed: 0).
  • Unscored CVEs. forge_rated: "none" now carries forge_asked_at, and the advisory is asked again after 7 days. A stamp with no time, from an earlier pass, counts as due. refreshFeeds takes an optional now so the test can step through 6 days (not asked) and 8 days (asked, rated).
  • Rating check. ratingOf accepts only CRITICAL, HIGH, MEDIUM or LOW. Anything else, including a 5000-character string, gives undefined. A test covers that.
  • GHSA updates. GHSA documents are now marked forge_source: "ghsa".
    • A copy we wrote is rewritten when GitHub's updated_at is newer, and keeps any rating it was given.
    • A withdrawn advisory deletes our copy.
    • A file OSV wrote is never touched, and a test holds that.

One thing I couldn't confirm: type=reviewed&affects=… may leave withdrawn advisories out of its results, in which case the delete path never fires. I haven't checked GitHub's behaviour. If it does omit them, a separate state=withdrawn query would be needed.

To try it, run bun test test/security-osv.test.ts.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs