Add support in .gitleaksignore file comment strings (#1425) (#1502)

* Add support in .gitleaksignore file comment strings  (#1195)

* Apply suggestions from code review

Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>

---------

Co-authored-by: Zachary Rice <zricezrice@gmail.com>
Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2024-09-18 13:44:44 -05:00
1 parent 9e06824372
commit 97dbe1ef09
2 files changed
+6 -1

No files matched your search

+5 -1
View File
@@ -149,7 +149,11 @@ func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error {
scanner := bufio.NewScanner(file)
for scanner.Scan() {
d.gitleaksIgnore[scanner.Text()] = true
line := strings.TrimSpace(scanner.Text())
// Skip lines that start with a comment
if line != "" && !strings.HasPrefix(line, "#") {
d.gitleaksIgnore[line] = true
}
}
return nil
}
+1
View File
@@ -1,2 +1,3 @@
api/ignoreGlobal.go:aws-access-key:20
# test comment
53cd7a3c6eb4937f413e3c25e4a9f39289afa69e:api/ignoreCommit.go:aws-access-key:20