Diff scans filter by whole file, so touching one line reports every old lead in it

Đang mở
#125 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
70/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
git, github-actions, go
Lĩnh vực
ci-cd, security, tooling

Hướng nghiên cứu

Start with keepChanged in internal/engine/diffscan.go:59-72, which today filters leads by changed[l.File], and with the --name-only listing in internal/gitx/gitx.go:312-329 that produces that set. Add a --diff-scope file|lines flag plus the diff-scope Action input in action.yml, and put the git diff -U0 hunk parser in a new internal/diffx/ package, keeping dependency leads on the existing lockfile rule. Done when the new engine and gitx tests pass via go test ./internal/engine ./internal/gitx, hunk parsing is covered for deletions, renames and CRLF, and docs/ci.md:135-139 documents the flag and the note counting leads outside changed lines.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement help wanted severity: medium

Summary

Diff scans (--since, --changed, the Action's diff-base) keep a lead when its file changed. Touching one line of a large legacy file therefore reports, and can fail CI on, every pre-existing lead in that file. A line-level scope would fix the common case without a baseline file.

Where

  • internal/engine/diffscan.go:59-72 (keepChanged)
  • internal/gitx/gitx.go:312-329 (--name-only listing: no line information)
  • docs/ci.md:135-139

Details

for _, l := range leads {
    if changed[l.File] {
        kept = append(kept, l)
    }
}

Impact

In a PR gate, a one-line typo fix in an old file fails CI on every lead already in it. That is the adoption blocker #81 describes, and the common case can be fixed without a baseline file.

Steps to reproduce

  1. app.py has an old SQL-injection lead at line 40.
  2. On a branch, change a comment on line 300.
  3. spackle scan . --since main --fail-on high exits 1 on the line-40 lead.

Suggested fix

Add --diff-scope file|lines (Action input diff-scope), defaulting to file to keep today's behavior. lines runs git diff -U0 --no-textconv --no-ext-diff <spec>, parses the @@ -a,b +c,d @@ hunks into changed line ranges per file, and keeps a lead whose [StartLine, EndLine] overlaps one. Dependency leads keep today's lockfile rule. The run note should say how many leads in changed files fell outside the changed lines. This complements #81 (baseline) and #96 (line-stable fingerprint) and does not replace them.

Acceptance criteria

  • With --diff-scope lines, a lead outside the changed hunks of a changed file is not reported, and the note counts it.
  • A lead overlapping an added or modified line is reported.
  • Hunk parsing is unit tested, including pure deletions, renames and CRLF files.

Getting started

  • Relevant files: internal/engine/diffscan.go, internal/gitx/gitx.go, internal/diffx/, action.yml, docs/ci.md
  • How to run tests: go test ./internal/engine ./internal/gitx

Related: #81, #96


Filed by repo-audit/full-audit at fffef43. Severity: medium. Effort: M. audit-key: enhancement|internal/engine/diffscan.go|keepChanged

Ngôn ngữ chính
Go
Star
0
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TMHSDigital/Spackle

Tất cả issue của TMHSDigital/Spackle

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.