Skip to content

feat(reporters): file output, rdjson/sonar formats, SARIF safeguards + remediation#263

Merged
dgenio merged 3 commits into
mainfrom
claude/issue-triage-grouping-n86ff1
Jun 19, 2026
Merged

feat(reporters): file output, rdjson/sonar formats, SARIF safeguards + remediation#263
dgenio merged 3 commits into
mainfrom
claude/issue-triage-grouping-n86ff1

Conversation

@dgenio

@dgenio dgenio commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Linked issues

Closes #233
Closes #237
Closes #244
Closes #227
Closes #238

Summary of changes

A single coherent change to the reporter / output layer (vibeguard/reporters/ + the CLI output dispatch), landing five related issues that share the same code area and implementation path.

Type of change

  • New feature (file output, two new formats, SARIF cap)
  • New or updated detection rule (remediation metadata on sourcemaps/secrets)
  • Documentation
  • Tests
  • CI / build / packaging (generated workflow)

How verified

  • python -m pytest tests/1072 passed (+~50 new)
  • ruff check vibeguard/ tests/ benchmarks/All checks passed
  • ruff format --check vibeguard/ tests/ benchmarks/140 files already formatted
  • python -m mypy vibeguard/Success: no issues found in 62 source files (with types-PyYAML installed; the bare-mypy yaml-stub note is the pre-existing environment artifact)
  • make docs-check, make bench-precision-check, make check-versionsall clean (no rule-metadata or precision drift; remediation adds no findings)
  • Manual (via the vibeguard entrypoint): --report sarif=… --report rdjson=… writes both from one scan; --sonar --output - streams to stdout; --output without a format flag, an unwritable path, mixing --report with a format flag, and a bad/unknown --report spec all exit 2; generated workflow renders and is valid YAML with --output.

Docs impact

  • README / docs updated — README output examples; docs/output-schemas.md §4–§8 (remediation, SARIF cap, rdjson, sonar, file output); docs/github-actions.md (file output + large-repo guidance)
  • docs/rules.md not regenerated — rule metadata is unchanged (remediation is per-finding data, not registry metadata); make docs-check confirms no drift.

Scope / risk

  • New CLI surface (--output, --report, --rdjson, --sonar, output.sarif_max_results) — added to the stability contract; mutual-exclusion and error paths are tested.
  • Additive JSON change: every finding now serializes "remediation": null by default. Consumers that ignore unknown/null fields are unaffected; the JSON golden was regenerated for this. SARIF and Markdown goldens are byte-identical. (Per the requester: no backward-compat constraint.)
  • New formats only emit when mechanically safe — remediation is attached to high-confidence cohorts (source-map / committed-env), and only replace-span/add-line become SARIF fixes. A wrong auto-fix is worse than none.
  • New runtime dependencies: none. Apply-side fix logic is intentionally out of scope (belongs to the vibeguard fix work).

Checklist

  • Tests pass locally (pytest)
  • Lint and format clean (make lint and make format-check)
  • Type check clean (make typecheck) — clean with types-PyYAML; only the known pre-existing yaml-stub note otherwise
  • No secrets committed
  • Linked issues above
  • PR title follows conventional commits

🤖 Generated with Claude Code

https://claude.ai/code/session_01X8ZPCcEw5r2augVrtDqdyJ


Generated by Claude Code

…+ remediation

A single coherent change to the reporter/output layer, landing five related
issues that all live in `vibeguard/reporters/` + the CLI output dispatch.

- #233 `--output PATH` (`-o`, `-`=stdout) on scan/gate/publish-check, plus
  repeatable `--report FORMAT=PATH` to emit several formats from one scan.
  Generated workflow uses `--output` instead of shell redirection. New
  `reporters/registry.py` centralizes format→string rendering.
- #237 reviewdog rdjson reporter (`--rdjson`) + golden.
- #244 SonarQube Generic Issue Import reporter (`--sonar`) + golden.
- #227 SARIF result cap for GitHub Code Scanning ingestion limits: severity
  ordered, overflow notification, configurable via `output.sarif_max_results`;
  output byte-identical at/below the cap.
- #238 structured `Finding.remediation` model (machine-actionable fixes),
  populated on sourcemaps + committed-env findings, serialized to JSON and
  mapped to SARIF `fixes` for replace-span/add-line kinds.

Docs: docs/output-schemas.md (formats 4-8), docs/github-actions.md (file
output + large-repo guidance), README output examples. Tests: new rdjson/
sonar/remediation suites, SARIF cap + fixes, CLI --output/--report e2e;
goldens regenerated.

Closes #233
Closes #237
Closes #244
Closes #227
Closes #238

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X8ZPCcEw5r2augVrtDqdyJ
Copilot AI review requested due to automatic review settings June 18, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands VibeGuard’s reporter/output layer to support writing reports to files (including multi-report output from a single scan), adds two new machine formats (reviewdog rdjson and SonarQube Generic Issue Import), and enhances SARIF output with ingestion safeguards and optional machine-actionable remediation metadata.

Changes:

  • Add --output and repeatable --report FORMAT=PATH to scan/gate/publish-check, with a centralized reporter registry for “format → rendered string”.
  • Introduce new reporters: rdjson (reviewdog) and sonar (SonarQube), plus goldens and targeted tests.
  • Add SARIF result-capping + overflow notification and a new Finding.remediation model mapped to SARIF fixes for precise edit kinds.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vibeguard/rules/sourcemaps.py Adds structured remediation metadata to sourcemap-related findings.
vibeguard/rules/secrets.py Adds structured remediation metadata to committed-env findings.
vibeguard/reporters/sonar.py New SonarQube Generic Issue Import JSON renderer.
vibeguard/reporters/sarif.py Adds SARIF max-results cap + overflow notice and SARIF fixes mapping.
vibeguard/reporters/registry.py Centralizes format-name → rendered-string dispatch for CLI and multi-report.
vibeguard/reporters/rdjson.py New reviewdog rdjson renderer.
vibeguard/models.py Introduces RemediationKind/Remediation and adds Finding.remediation.
vibeguard/config.py Adds output.sarif_max_results configuration.
vibeguard/cli.py Implements --output/--report plumbing and unified output dispatch.
vibeguard/ci_setup.py Updates generated workflow to use --output instead of shell redirection.
tests/test_sonar.py Adds Sonar reporter/CLI tests.
tests/test_sarif.py Adds SARIF cap tests and SARIF fixes tests.
tests/test_reporters_golden.py Adds golden coverage for rdjson and sonar outputs.
tests/test_remediation.py Adds remediation model + rule integration tests.
tests/test_rdjson.py Adds rdjson reporter/CLI tests.
tests/test_cli_e2e.py Adds e2e coverage for --output and --report.
tests/fixtures/golden/scan_result.sonar.json Adds sonar golden fixture.
tests/fixtures/golden/scan_result.rdjson Adds rdjson golden fixture.
tests/fixtures/golden/scan_result.json Updates JSON golden for remediation: null.
README.md Documents new output flags and formats.
docs/output-schemas.md Documents remediation metadata, SARIF cap, rdjson/sonar formats, and file output.
docs/github-actions.md Updates Actions docs for --output and SARIF cap guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vibeguard/models.py Outdated
Comment thread vibeguard/cli.py
claude added 2 commits June 18, 2026 19:22
…dout

Address PR review:
- models.py: the Remediation docstring listed `add-ignore-entry` among the
  kinds mapped to SARIF `fixes`, but `_build_fixes` only maps `add-line` /
  `replace-span`. Correct the docstring to match the reporter.
- cli.py: `_write_report` computed a newline-normalized string but echoed the
  raw text on the `-` (stdout) path, so a renderer ending in `\n` would emit a
  double trailing newline and diverge from the file path. Echo `normalized`
  with `nl=False` so stdout matches file output byte-for-byte.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X8ZPCcEw5r2augVrtDqdyJ
…e-line SARIF fix

Two audit follow-ups on the reporter layer:

- Sonar: the IaC rule tags findings with their family ("iac"/"terraform"/
  "kubernetes") but no generic "security" tag, so they were typed CODE_SMELL
  instead of VULNERABILITY. Add those families to _VULNERABILITY_TAGS so
  security-relevant infra findings classify correctly.
- SARIF: a replace-span remediation with empty content (delete the line, e.g.
  the sourceMappingURL comment) emitted a single-line region that blanked the
  line in place. Span to column 1 of the next line so the line and its newline
  are removed, leaving no empty line behind.

Both paths gain tests; goldens are unaffected (the canonical fixture has no IaC
finding and no remediation).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QDQxGQtbVN2CqXkCtkCJwK
@dgenio dgenio merged commit 8dcf439 into main Jun 19, 2026
11 checks passed
@dgenio dgenio deleted the claude/issue-triage-grouping-n86ff1 branch June 19, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment