Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Revert "Fix off by one (#1891)" (#1963)
Cody Rosee556bdd7b22a
diff --git a/pkg/engine/engine.go b/pkg/engine/engine.goindex 19af7dd25..370c44db6 100644--- a/pkg/engine/engine.go+++ b/pkg/engine/engine.go@@ -623,7 +623,7 @@ func FragmentLineOffset(chunk *sources.Chunk, result *detectors.Result) (int64,if !found {return 0, false}- lineNumber := int64(bytes.Count(before, []byte("\n")) + 1)+ lineNumber := int64(bytes.Count(before, []byte("\n")))// 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 da8989799..4e9b2eda5 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: 3,+ expectedLine: 2,ignore: true,},{@@ -43,7 +43,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret here"),},- expectedLine: 3,+ expectedLine: 2,ignore: false,},{@@ -54,7 +54,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret here"),},- expectedLine: 5,+ expectedLine: 4,ignore: false,},{@@ -65,7 +65,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret\nhere"),},- expectedLine: 5,+ expectedLine: 4,ignore: false,},{@@ -76,7 +76,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret\nhere"),},- expectedLine: 4,+ expectedLine: 3,ignore: true,},{@@ -87,7 +87,7 @@ func TestFragmentLineOffset(t *testing.T) {result: &detectors.Result{Raw: []byte("secret here"),},- expectedLine: 4,+ expectedLine: 3,ignore: true,},}