Report every finding on a line in the guardrails content scan

Offen Anfängerfreundlich
#20,942 5 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
84/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
shell
Bereich
devtools, testing

Rechercherichtung

Beginne in plugins/guardrails/git-hooks/content-scan.sh und untersuche die sort -u-Pipeline, die von beiden Scans verwendet wird. Lies dann pre-commit-content.test.sh und pre-push-content.test.sh; füge Fälle hinzu, in denen eine Zeile ein GitHub PAT und einen Linux-Home-Pfad enthält. Die Aufgabe ist erledigt, wenn beide Befunde in jedem Test gemeldet werden, doppelte Befunde aus zwei Durchläufen nur einmal erscheinen und beide genannten Testskripte bestehen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Context

content_scan in plugins/guardrails/git-hooks/content-scan.sh ends with sort -u -t: -k1,1 -k2,2n. With key fields, sort -u treats two lines as duplicates when only their keys (path and line number) match. So when one line has two findings, for example a secret and a machine-specific path, or two secret patterns, only one is reported. The pre-commit and pre-push scans both use it.

This does not fail open: the line still blocks on the finding that is kept. But the author fixes one finding, commits or pushes again, and only then sees the second. Found by the review lane on #20938 (thread on content-scan.sh at the sort -u line); the same line is on main.

Proposed work

  • Sort by path and line, then remove only whole-line duplicates (for example sort -t: -k1,1 -k2,2n | uniq). Identical lines with equal keys end up next to each other, because sort compares the whole line when keys tie.
  • Add a test to pre-commit-content.test.sh and pre-push-content.test.sh: a line holding both a GitHub PAT and a Linux home path reports both findings.

Acceptance criteria

  • A line with two different findings reports both, in pre-commit and pre-push.
  • The same finding reached through two passes is still reported once.
  • pre-commit-content.test.sh and pre-push-content.test.sh pass.
Vorherrschende Sprache
Shell
Sterne
22
Forks
2
Ø Merge
3 Std. 4 Min.
Gemergte PRs (30 T.)
941

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus melodic-software/claude-code-plugins

Alle Issues in melodic-software/claude-code-plugins

Ähnliche Issues

Weitere Issues zu Shell/Bash

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.