Jelajahi Sumber

fix off by one line number for --no-git

Zach Rice 4 tahun lalu
induk
melakukan
6f6ebd454f
3 mengubah file dengan 14 tambahan dan 4 penghapusan
  1. 6 0
      .goreleaser.yml
  2. 4 0
      detect/files.go
  3. 4 4
      detect/files_test.go

+ 6 - 0
.goreleaser.yml

@@ -9,6 +9,12 @@ builds:
       - windows
       - windows
     goarch:
     goarch:
       - amd64
       - amd64
+      - "386"
+      - arm
+      - arm64
+    goarm:
+      - "6"
+      - "7"
     ldflags:
     ldflags:
       - -s -w -X=github.com/zricethezav/gitleaks/v8/cmd.Version={{.Version}}
       - -s -w -X=github.com/zricethezav/gitleaks/v8/cmd.Version={{.Version}}
 archives:
 archives:

+ 4 - 0
detect/files.go

@@ -51,6 +51,10 @@ func FromFiles(source string, cfg config.Config, outputOptions Options) ([]repor
 			}
 			}
 			fis := DetectFindings(cfg, b, p, "")
 			fis := DetectFindings(cfg, b, p, "")
 			for _, fi := range fis {
 			for _, fi := range fis {
+				// need to add 1 since line counting starts at 1
+				fi.StartLine++
+				fi.EndLine++
+
 				if outputOptions.Redact {
 				if outputOptions.Redact {
 					fi.Redact()
 					fi.Redact()
 				}
 				}

+ 4 - 4
detect/files_test.go

@@ -25,8 +25,8 @@ func TestFromFiles(t *testing.T) {
 			expectedFindings: []report.Finding{
 			expectedFindings: []report.Finding{
 				{
 				{
 					Description: "AWS Access Key",
 					Description: "AWS Access Key",
-					StartLine:   19,
-					EndLine:     19,
+					StartLine:   20,
+					EndLine:     20,
 					StartColumn: 16,
 					StartColumn: 16,
 					EndColumn:   35,
 					EndColumn:   35,
 					Match:       "AKIALALEMEL33243OLIA",
 					Match:       "AKIALALEMEL33243OLIA",
@@ -43,8 +43,8 @@ func TestFromFiles(t *testing.T) {
 			expectedFindings: []report.Finding{
 			expectedFindings: []report.Finding{
 				{
 				{
 					Description: "AWS Access Key",
 					Description: "AWS Access Key",
-					StartLine:   19,
-					EndLine:     19,
+					StartLine:   20,
+					EndLine:     20,
 					StartColumn: 16,
 					StartColumn: 16,
 					EndColumn:   35,
 					EndColumn:   35,
 					Match:       "AKIALALEMEL33243OLIA",
 					Match:       "AKIALALEMEL33243OLIA",