feat: mcpm audit --sarif — SARIF 2.1.0 for GitHub code-scanning (D3)#123
Merged
Conversation
Pure src/output/sarif.ts mapper beside the existing --json branch. One SARIF rule per real Finding.type (TS-exhaustive Record — a new type fails the build). Each finding becomes a result anchored file-level to mcpm.yaml (audit scans installed servers, which have no source line — a fabricated line would be a lie), with a logicalLocation naming the server, severity mapped to SARIF error/warning/note, and a stable partialFingerprints so GitHub tracks the same alert across runs. Report-only (never fixes); exit code matches audit (risky→1). README documents the upload-sarif + if: always() code-scanning workflow. __PKG_VERSION__ (tsup define) is typeof-guarded for non-bundled test runs. Verified e2e on the built CLI (real version, 8 rules); 1949 tests green.
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.
What
Wave-1 item D3:
mcpm audit --sarifemits a SARIF 2.1.0 report that GitHub code-scanning ingests (github/codeql-action/upload-sarif).Changes
src/output/sarif.ts(new, pure) —buildSarif(servers, version):Finding.type— a TS-exhaustiveRecord<Finding["type"], …>, so adding a finding type without a rule fails the build (there are 8 types now, not the roadmap's "7" — the union grew)mcpm.yamlwith no region/line (audit scans installed servers — there's no source line, and a fabricated one would be a lie), plus alogicalLocationnaming the servercritical/high→error,medium→warning,low→note)partialFingerprints(server:type:sha256(message)[:12]) so GitHub tracks the same alert across runsaudit --sarif— a report-only branch beside--json. Never fixes (even with--fix); exit code matchesaudit's contract (1when risky).__PKG_VERSION__(tsup define) istypeof-guarded for non-bundled test runs.upload-sarif+if: always()workflow.Scope
Per the roadmap, cut guard-events SARIF (no repo artifact to anchor; that export story is E2).
Tests & verification
sarif.test.ts(6): envelope, rule-per-type catalog, finding→result mapping, severity→level, file-level anchor (asserts noregion), stable/distinct fingerprints, multi-server flatten.audit.test.ts(+2):--sarifemits SARIF + exit 1 when risky (and never touches the store), and a clean scan → 0 results + exit 0 with the full rule catalog.Docs
CHANGELOG
[Unreleased], ROADMAP-ADOPTION (D3 → ✅ SHIPPED), README (audit row + code-scanning snippet), CLAUDE.md decisions log.