E4BD
Skip to content

fix: calculate columns from line starts - #2215

Open
Eljees wants to merge 1 commit into
gitleaks:masterfrom
Eljees:fix/location-columns-1424
Open

fix: calculate columns from line starts#2215
Eljees wants to merge 1 commit into
gitleaks:masterfrom
Eljees:fix/location-columns-1424

Conversation

@Eljees
@Eljees Eljees commented Jul 28, 2026
Copy link
Copy Markdown

Description:

Fixes #1424.

Newline matches contain both the newline byte offset and the first byte of the next line. The location calculation previously used the newline byte itself as the column offset, so matches after the first line were shifted one column to the right. This change tracks the actual line start separately while preserving the existing line-slice indexes.

The regression coverage now derives newline indexes from realistic LF and CRLF input, verifies identical matches on the first and later lines, and updates the affected expected coordinates for plain and decoded findings.

Tested with Go 1.24.11:

go test ./detect -run '^Test(GetLocation|Detect|FromGitStaged|FromFiles|DetectWithArchives|DetectRuleAllowlist)$' -count=1

Checklist:

  • Does your PR pass tests?
  • Have you written new tests for your changes?
  • Have you lint your code locally prior to submission?

Signed-off-by: Eljees <3.14hell@gmail.com>
@Eljees
Eljees commented Aug 9, 2026
Copy link
Copy Markdown
Author

Ping on this one and #2219 - both open since 28 July with no review. #2215 is a column offset fix, #2219 narrows the hashicorp-tf-password rule; they are unrelated and can be taken separately.

@Eljees
Eljees commented Aug 14, 2026
Copy link
Copy Markdown
Author

Following up on my ping of 9 August, with a correction to it: CI has not run on either PR. The Test workflow on both is at action_required and needs a maintainer to approve it, so there are no results to judge them by yet.

#2215 calculates columns from line starts rather than from the match offset; #2219 requires the identifier to end with the keyword in hashicorp-tf-password. Unrelated to each other.

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.

Off-by-one error in startColumn and endColumn calculation

1 participant

0