Add a baseline file so accepted findings stop failing builds

未關閉
#81 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
40/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
go

研究方向

Start at exitFor in internal/cli/scan.go:167 and the status definitions in internal/finding/finding.go, then read how findings are serialized in internal/report/sarif.go. The issue leaves design choices open (line-dependent id vs. fingerprint, inline ignore syntax), so a first pass should settle those before coding. Done means the four acceptance criteria hold: baseline-matching findings exit 0, accepted findings appear in reports, stale entries are listed, and docs/ci.md and docs/config.md describe the workflow.

由索引模型根據 Issue 內容生成。

描述

enhancement severity: high

Summary

There is no way to accept a known finding. exitFor fails the run for any open or patch-available finding at or above fail_on, so teams adopting Spackle on an existing codebase must choose between fail-on: never (no gate) and a check that stays red.

Where

  • internal/cli/scan.go:167 (exitFor)
  • internal/finding/finding.go:30-40 (statuses: open, dismissed, patch-available, fixed)
  • docs/ci.md:113, docs/ci.md:136
  • ROADMAP.md:37 (lists baseline files as an intention; no issue tracks it)

Details

for _, f := range run.Findings {
    unresolved := f.Status == finding.StatusOpen || f.Status == finding.StatusPatchAvailable
    if unresolved && finding.LabelRank(f.Severity.Label) >= threshold {
        return ExitFindings
    }
}

docs/ci.md says the first PR on an existing codebase fails on old findings and that findings that predate the change "are not accepted or recorded anywhere". --since filters by file, so a PR that touches a file with an old finding still fails on it. A false positive can only be silenced for a whole rule (disable_rules) or path (exclude).

Suggested fix

  • spackle baseline <run-id> [--out .spackle-baseline.json] writes the run's active findings (id, title, location, optional reason, optional expires).
  • [scan] baseline = "path" and --baseline load it. Matching findings get a new status such as accepted: kept in reports, emitted in SARIF as suppressions with kind: external, and excluded from exitFor.
  • Report baseline entries that no longer match anything.
  • Open questions: match on the current line-dependent id or on a line-stable fingerprint (see the related fingerprint issue filed in this audit); whether an inline spackle:ignore <rule> comment is also wanted.

Acceptance criteria

  • A run with every finding in the baseline exits 0 under --fail-on high.
  • Accepted findings still appear in every report format, marked as accepted.
  • Stale baseline entries are listed.
  • docs/ci.md and docs/config.md describe the workflow.

Getting started

  • Relevant files: internal/cli/scan.go, internal/finding/finding.go, internal/report/sarif.go, docs/ci.md
  • How to run tests: make test (Unix) or .\make.ps1 test (Windows PowerShell); one package: go test ./internal/<pkg>
  • Related docs: docs/ci.md, ROADMAP.md

Filed by repo-audit/full-audit at a7f6edc. Severity: high. Effort: M. audit-key: enhancement|internal/cli/scan.go|exitFor

主要語言
Go
星號
0
分支
1
PR 合併指標
30 天內沒有已合併 PR

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/Spackle 的其他 Issue

查看 TMHSDigital/Spackle 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。