Use a line-independent fingerprint so a finding moved by an unrelated edit is not "new"

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

還沒有人認領這個 Issue。

評估

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

研究方向

Start in internal/finding/finding.go at MakeRuleID, which hashes loc.StartLine, then see where f.ID is emitted as the SARIF key in internal/report/sarif.go near line 152 and used for matching in internal/cli/runs.go around lines 268-309. Add a line-independent content fingerprint, emit it as a partialFingerprints entry, and switch runs compare to join on it. Done when inserting a line above a finding leaves its fingerprint unchanged and runs compare reports it as unchanged; run go test ./internal/finding and ./internal/report.

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

描述

enhancement severity: medium

Summary

Finding ids hash the start line, and the id is the only SARIF fingerprint. Adding one line above a finding changes its id, so runs compare reports a false "gone" and a false "new", and any future baseline keyed on the id stops matching.

Where

  • internal/finding/finding.go:195-204 (MakeRuleID hashes loc.StartLine)
  • internal/report/sarif.go:152 ("spackle/v1": f.ID)
  • internal/cli/runs.go:268-271, :309 (documents the effect)
  • docs/ci.md:150

Suggested fix

Add a second fingerprint, for example a hash of class, file, rule, the normalized text of the flagged line(s) and the occurrence index among identical lines. Store it on the finding, emit it as an extra partialFingerprints key (spackle/content/v1), and use it as the join key in runs compare and in a baseline. Keep SPK- ids for display. Hash the text as the rest of Spackle sees it (after redaction).

Acceptance criteria

  • Inserting a line above a finding keeps its fingerprint and runs compare reports it as unchanged.
  • SARIF carries the new fingerprint.

Getting started

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

Filed by repo-audit/full-audit at a7f6edc. Severity: medium. Effort: M. audit-key: enhancement|internal/finding/finding.go|MakeRuleID

主要語言
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 摘要。