Skip to content

Find, verify, and analyze leaked credentials

Fix wrong line number in private key detector (#4485) (#4486)

Maciek Sobczak1ef44e7987e3
diff --git a/pkg/detectors/privatekey/privatekey.go b/pkg/detectors/privatekey/privatekey.go
index f07e7bb4b..8deaa0575 100644
--- a/pkg/detectors/privatekey/privatekey.go
+++ b/pkg/detectors/privatekey/privatekey.go
@@ -71,6 +71,9 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
ExtraData: make(map[string]string),
}
+ // set not normalized match as primary secret value so it is used to calculate line of code
+ s1.SetPrimarySecretValue(match)
+
var passphrase string
parsedKey, err := ssh.ParseRawPrivateKey([]byte(token))
if err != nil && strings.Contains(err.Error(), "private key is passphrase protected") {