mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 20:54:22 +01:00
feat: Add optional redaction value, default 100 (#1229)
This commit introduces an optional value for the --redact flag, allowing users to specify the extent of redaction for secrets. The valid range of values is from 0 (no redaction) to 100 (full redaction). If no value is provided, the default redaction value is set to 100, resulting in complete redaction by replacing the secret with the term 'REDACTED'. This preserves the original behavior of the --redact flag. Co-authored-by: Zachary Rice <zachary.rice@trufflesec.com>
This commit is contained in:
1 parent
e9135cf0b5
commit
30c6117aaa
7 files changed
+97
-14
No files matched your search
+1
-1
@@ -46,7 +46,7 @@ type Detector struct {
|
||||
// Redact is a flag to redact findings. This is exported
|
||||
// so users using gitleaks as a library can set this flag
|
||||
// without calling `detector.Start(cmd *cobra.Command)`
|
||||
Redact bool
|
||||
Redact uint
|
||||
|
||||
// verbose is a flag to print findings
|
||||
Verbose bool
|
||||
|
||||
+3
-3
@@ -60,7 +60,7 @@ func shannonEntropy(data string) (entropy float64) {
|
||||
}
|
||||
|
||||
// filter will dedupe and redact findings
|
||||
func filter(findings []report.Finding, redact bool) []report.Finding {
|
||||
func filter(findings []report.Finding, redact uint) []report.Finding {
|
||||
var retFindings []report.Finding
|
||||
for _, f := range findings {
|
||||
include := true
|
||||
@@ -81,8 +81,8 @@ func filter(findings []report.Finding, redact bool) []report.Finding {
|
||||
}
|
||||
}
|
||||
|
||||
if redact {
|
||||
f.Redact()
|
||||
if redact > 0 {
|
||||
f.Redact(redact)
|
||||
}
|
||||
if include {
|
||||
retFindings = append(retFindings, f)
|
||||
|
||||
Reference in new issue
Block a user