Skip to content

fix(constraints): report floor-guard findings by file and line, not line text - #806

Merged
addyosmani merged 1 commit into
addyosmani:mainfrom
TanmayShah29:fix/804-floor-guard-no-line-text
Nov 24, 2026
Merged

addyosmani merged 1 commit into
addyosmani:mainfrom
TanmayShah29:fix/804-floor-guard-no-line-text

Conversation

@TanmayShah29

Copy link
Copy Markdown
Contributor

Fixes #804

The floor-guard reference says it "reports the rule and the location, never the matched secret value", but flag() kept the first 120 characters of the matched diff line and the report printed them to stderr. So a value on a // gitleaks:allow or // TODO KEY=... line ended up in terminal output and agent logs.

Findings now carry file:line, numbered from the @@ hunk headers. Removed lines are named and numbered as in the base and marked (removed), a deleted test reads (file deleted), and a threshold change reads base -> new. Detection, exit codes and the hint text are unchanged.

Before (throwaway repo, placeholder values):

  [silenced-checker] src/app.js: const KEY = "<value>"; // gitleaks:allow
  [unfinished-work] src/app.js: // TODO KEY=<value>

After:

  [silenced-checker] src/app.js:2
  [unfinished-work] src/app.js:4

Context lines are counted, so numbers stay right when diff.interHunkContext is set (git then prints context between nearby hunks even with --unified=0).

One separate fix, flagged so you can ask me to split it out: pathOf now strips the trailing tab git adds to a header path that contains a space. Without it the tab lands inside file:line, and it also meant a CONSTRAINTS.md under such a path never matched isConstraints, so a loosened threshold in my dir/CONSTRAINTS.md went unreported (1 finding before, 2 after on the same diff). Happy to move this one line to its own PR.

Checked on node 22 and git 2.34 with throwaway repos: multi-hunk edits, a missing final newline, an untracked file, a deleted test file, a detected rename, a new exception row, a rule removed, a rule moved between two CONSTRAINTS.md files, diff.interHunkContext=5, and a path with a space. Same findings and exit codes as before in every case, with no line text in the output.

I left the rule labels out of threshold findings so nothing from the line is printed, and did not add sentinel fixtures to the reference, to keep it a clean copyable file. Happy to add either if you want them.

This touches the same diff-walk lines as #650; I can rebase on whichever lands first.

…ine text

The reference promises to report the rule and the location, never the
matched secret value, but flag() kept the first 120 characters of the
matched diff line and the report printed them to stderr. A suppressed
or TODO line is often the one holding a secret-like value.

Findings now carry file:line, numbered from the @@ hunk headers. Removed
lines are named and numbered as in the base and marked (removed).
Context lines (diff.interHunkContext) are counted so numbers stay right,
and the trailing tab git adds to paths with spaces is stripped.

Fixes addyosmani#804

@addyosmani addyosmani left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

praise: the reference promised never to print the matched value and then printed the line. file:line is what a reviewer needs anyway. Thanks.

@addyosmani
addyosmani merged commit ca5d610 into addyosmani:main Nov 24, 2026
8 checks passed
hillemacher pushed a commit to hillemacher/agent-skills that referenced this pull request Dec 1, 2026
fix(constraints): report floor-guard findings by file and line, not line text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

floor-guard reference prints matched diff lines, contradicting its no-secret-output promise

2 participants