Skip to content

Commit

Permalink
fix off by one line number for --no-git
Browse files Browse the repository at this point in the history
  • Loading branch information
zricethezav committed Dec 8, 2021
1 parent ce42947 commit 6f6ebd4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ builds:
- windows
goarch:
- amd64
- "386"
- arm
- arm64
goarm:
- "6"
- "7"
ldflags:
- -s -w -X=github.com/zricethezav/gitleaks/v8/cmd.Version={{.Version}}
archives:
Expand Down
4 changes: 4 additions & 0 deletions detect/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func FromFiles(source string, cfg config.Config, outputOptions Options) ([]repor
}
fis := DetectFindings(cfg, b, p, "")
for _, fi := range fis {
// need to add 1 since line counting starts at 1
fi.StartLine++
fi.EndLine++

if outputOptions.Redact {
fi.Redact()
}
Expand Down
8 changes: 4 additions & 4 deletions detect/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func TestFromFiles(t *testing.T) {
expectedFindings: []report.Finding{
{
Description: "AWS Access Key",
StartLine: 19,
EndLine: 19,
StartLine: 20,
EndLine: 20,
StartColumn: 16,
EndColumn: 35,
Match: "AKIALALEMEL33243OLIA",
Expand All @@ -43,8 +43,8 @@ func TestFromFiles(t *testing.T) {
expectedFindings: []report.Finding{
{
Description: "AWS Access Key",
StartLine: 19,
EndLine: 19,
StartLine: 20,
EndLine: 20,
StartColumn: 16,
EndColumn: 35,
Match: "AKIALALEMEL33243OLIA",
Expand Down

0 comments on commit 6f6ebd4

Please sign in to comment.