We should use `(*regexp.Regexp).MatchString` instead of
`(*regexp.Regexp).Match([]byte(...))` when matching string to avoid
unnecessary `[]byte` conversions and reduce allocations.
Example benchmark:
var pathRegex = regexp.MustCompile(".*.yaml")
func BenchmarkMatch(b *testing.B) {
for i := 0; i < b.N; i++ {
if match := pathRegex.Match([]byte("./config/deploy.yaml")); !match {
b.Fail()
}
}
}
func BenchmarkMatchString(b *testing.B) {
for i := 0; i < b.N; i++ {
if match := pathRegex.MatchString("./config/deploy.yaml"); !match {
b.Fail()
}
}
}
goos: linux
goarch: amd64
pkg: github.com/zricethezav/gitleaks/v8/detect
cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics
BenchmarkMatch-16 2167712 657.9 ns/op 24 B/op 1 allocs/op
BenchmarkMatchString-16 3275372 324.8 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/zricethezav/gitleaks/v8/detect 3.436s
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
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>
* Initial secret set
* Covered off all rule types in comments
* Finished Azure and Ansible rules
* About to run go run main.go
* Fixed some rules, but tests need work
* Initial secret set for Azure
Needs work - many tests fail
* Fix remaining Azure secrets - but couldn't get XML to work
* Update .gitignore
Co-authored-by: Jesse Houwing <jesse.houwing@gmail.com>
---------
Co-authored-by: Jesse Houwing <jesse.houwing@gmail.com>
The docker run command was missing `ghcr.io/` in the image name, which resulted in an error:
Unable to find image 'gitleaks/gitleaks:latest' locally
docker: Error response from daemon: pull access denied for gitleaks/gitleaks, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.