Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Fix off by one (#1891)
Shreyas Sriram7f534d0bb759
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.goindex 61a525048..83642f9f6 100644--- a/pkg/engine/engine.go+++ b/pkg/engine/engine.go@@ -635,7 +635,7 @@ func FragmentLineOffset(chunk *sources.Chunk, result *detectors.Result) (int64,if !found {return 0, false}- lineNumber := int64(bytes.Count(before, []byte("\n")))+ lineNumber := int64(bytes.Count(before, []byte("\n")) + 1)// If the line contains the ignore tag, we should ignore the result.endLine := bytes.Index(after, []byte("\n"))if endLine == -1 {diff --git a/pkg/engine/engine_test.go b/pkg/engine/engine_test.goindex 4e9b2eda5..da8989799 100644--- a/pkg/engine/engine_test.go+++ b/pkg/engine/engine_test.go@@ -32,7 +32,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret here"),},- expectedLine: 2,+ expectedLine: 3,ignore: true,},{@@ -43,7 +43,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret here"),},- expectedLine: 2,+ expectedLine: 3,ignore: false,},{@@ -54,7 +54,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret here"),},- expectedLine: 4,+ expectedLine: 5,ignore: false,},{@@ -65,7 +65,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret\nhere"),},- expectedLine: 4,+ expectedLine: 5,ignore: false,},{@@ -76,7 +76,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret\nhere"),},- expectedLine: 3,+ expectedLine: 4,ignore: true,},{@@ -87,7 +87,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret here"),},- expectedLine: 3,+ expectedLine: 4,ignore: true,},}