mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
1 parent
7d9dd260f4
commit
96eed6aa0f
12 files changed
+134
-15
No files matched your search
+4
-1
@@ -13,6 +13,8 @@ type Finding struct {
|
||||
StartColumn int
|
||||
EndColumn int
|
||||
|
||||
Line string `json:"-"`
|
||||
|
||||
Match string
|
||||
|
||||
// Secret contains the full content of what is matched in
|
||||
@@ -42,6 +44,7 @@ type Finding struct {
|
||||
|
||||
// Redact removes sensitive information from a finding.
|
||||
func (f *Finding) Redact() {
|
||||
f.Line = strings.Replace(f.Line, f.Secret, "REDACTED", -1)
|
||||
f.Match = strings.Replace(f.Match, f.Secret, "REDACTED", -1)
|
||||
f.Secret = "REDACT"
|
||||
f.Secret = "REDACTED"
|
||||
}
|
||||
@@ -19,7 +19,7 @@ func TestRedact(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
for _, f := range test.findings {
|
||||
f.Redact()
|
||||
if f.Secret != "REDACT" {
|
||||
if f.Secret != "REDACTED" {
|
||||
t.Error("redact not redacting: ", f.Secret)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user