From 6f6ebd454f37ec30abcaeb5b24d4ffbe592f7faf Mon Sep 17 00:00:00 2001 From: Zach Rice Date: Wed, 8 Dec 2021 15:04:32 -0600 Subject: [PATCH] fix off by one line number for --no-git --- .goreleaser.yml | 6 ++++++ detect/files.go | 4 ++++ detect/files_test.go | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 601be1638..94ad5762c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -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: diff --git a/detect/files.go b/detect/files.go index 580850d4e..f2fd2b753 100644 --- a/detect/files.go +++ b/detect/files.go @@ -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() } diff --git a/detect/files_test.go b/detect/files_test.go index 7f9f7706f..34e3e4d0c 100644 --- a/detect/files_test.go +++ b/detect/files_test.go @@ -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", @@ -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",