You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c740b98
Browse filesBrowse the repository at this point in the historyBrowse files
fix(output): handle findings object + locations/rules in SARIF, wire into ci (#155)
The SARIF formatter only accepted a top-level JSON array or a {type,data}
wrapper, so `findings -o sarif` failed because the findings command emits
`{"findings":[...],"total":N}`. It also emitted only ruleId/level/message,
with no `locations[]` (consumers couldn't place findings) and no `rules[]`
driver section (so ruleId references dangled).
Changes:
- internal/output/sarif.go: unwrap the {findings,total} object shape (plus
the existing array and {type,data} wrapper); emit a `locations[]` entry
from common location keys (filePath/file/path + startLine/line/lineNumber
for code, uri/url for DAST); emit distinct `rules[]` under
tool.driver.rules so references resolve. Defensive against missing fields.
Expose SARIFBytes() for reuse.
- cmd/cli/cmd/root.go: include `sarif` in the --output flag usage string.
- cmd/cli/cmd/ci.go:
- `ci report` gains a --format flag (markdown default, or sarif).
- `ci gate` now counts via the response `total` field instead of the
limit-truncated items array, so reported counts are accurate.
- `ci gate` is fail-closed: any scanner request error fails the gate
(exit non-zero) rather than only failing when all requests error.
- internal/output: table-driven SARIF tests covering the {findings,total}
object, locations, rules, dedup, and missing-field defensiveness.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments