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

A .sarif file in a repository opens as its findings: rule, level, file and line, and message per row #11029

shipped production is serving it opened this has it
opened this

Security scanners (CodeQL, Semgrep, eslint) write SARIF; today a .sarif file opens as raw JSON.

Done when:

  • [x] src/web/render/sarif.ts draws one row per result: level, rule id, file:line (a link to that line in the same repository when the file exists at the ref), and the message text, grouped under each run's tool name; counts by level at the top.
  • [x] kinds.ts maps .sarif to a sarif kind (with a size cap like the other text kinds) and renderers.ts names the renderer; add the rows on their own lines so they do not collide with the .eml row of #11022.
  • [x] Every string is escaped; at most 1,000 results drawn, and the page says how many were left out; invalid JSON or a file with no runs falls back to Source with the reason.
  • [x] test/render-sarif.test.ts covers a two-run fixture, the cap and its line, a <script> message arriving escaped, and the fallback; docs/features/file-sarif.md says what the page shows.
  • [x] bun test test/render-sarif.test.ts test/render-kinds.test.ts and bun scripts/design-lint.ts pass; any new class is in docs/design/areas/render.md.

Files: src/web/render/sarif.ts, src/web/render/kinds.ts, src/web/render/renderers.ts, test/render-sarif.test.ts, docs/features/file-sarif.md. Risk: kinds.ts and renderers.ts are shared with #11022; keep the edit to one added line each.

commented

Reviewed pull #11034 at its head: ticked src/web/render/sarif.ts draws one row per result: level, rule id, file:line (a link to that line in the same repository when the file exists at the ref), and the message text, grouped under each run's tool name; counts by level at the top.; kinds.ts maps .sarif to a sarif kind (with a size cap like the other text kinds) and renderers.ts names the renderer; add the rows on their own lines so they do not collide with the .eml row of #11022.; Every string is escaped; at most 1,000 results drawn, and the page says how many were left out; invalid JSON or a file with no runs falls back to Source with the reason.; test/render-sarif.test.ts covers a two-run fixture, the cap and its line, a <script> message arriving escaped, and the fallback; docs/features/file-sarif.md says what the page shows.; bun test test/render-sarif.test.ts test/render-kinds.test.ts and bun scripts/design-lint.ts pass; any new class is in docs/design/areas/render.md..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs