Compare commits

..
3 Commits
Author SHA1 Message Date
Zach Rice 84e285e4ce ignore gitleaks.toml by default 2021-12-06 10:43:21 -06:00
Ben Randall 928c6a6043 Update pre-commit step to run gitleaks checks (#729)
* Fix pre-commit config.

* Debug output

* No debug and use redacted.

* Typo

* Add back staged.

* Update .pre-commit-hooks.yaml

* Update .pre-commit-hooks.yaml
2021-12-03 16:09:05 -06:00
Florian Greinacher 106897fdf0 fix: format dates in log in a portable way (#735)
The output of time.String() depends on the runtime environment and should only be used for debugging.

This commit ensures that a well-defined UTC time is written to the report.
2021-12-03 09:34:57 -06:00
4 changed files with 10 additions and 4 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
- id: gitleaks
name: Detect hardcoded secrets
description: Detect hardcoded secrets using Gitleaks
entry: gitleaks
entry: gitleaks protect --verbose --redact --staged
language: golang
pass_filenames: false
+4 -1
View File
@@ -538,4 +538,7 @@ secretGroup = 4
[allowlist]
description = "global allow lists"
regexes = ['''219-09-9999''', '''078-05-1120''', '''(9[0-9]{2}|666)-\d{2}-\d{4}''']
paths = ['''(.*?)(jpg|gif|doc|pdf|bin|svg|socket)$''']
paths = [
'''gitleaks.toml''',
'''(.*?)(jpg|gif|doc|pdf|bin|svg|socket)$'''
]
+2 -1
View File
@@ -3,6 +3,7 @@ package detect
import (
"strings"
"sync"
"time"
"github.com/gitleaks/go-gitdiff/gitdiff"
"github.com/rs/zerolog/log"
@@ -70,7 +71,7 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
fi.Author = f.PatchHeader.Author.Name
fi.Email = f.PatchHeader.Author.Email
}
fi.Date = f.PatchHeader.AuthorDate.String()
fi.Date = f.PatchHeader.AuthorDate.UTC().Format(time.RFC3339)
}
if outputOptions.Redact {
+3 -1
View File
@@ -42,6 +42,7 @@ func TestFromGit(t *testing.T) {
Secret: "AKIALALEMEL33243OLIA",
File: "main.go",
// Line: "\tawsToken := \"AKIALALEMEL33243OLIA\"",
Date: "2021-11-02T23:37:53Z",
Commit: "1b6da43b82b22e4eaa10bcf8ee591e91abbfc587",
Author: "Zachary Rice",
Email: "zricer@protonmail.com",
@@ -58,6 +59,7 @@ func TestFromGit(t *testing.T) {
Secret: "AKIALALEMEL33243OLIA",
File: "foo/foo.go",
// Line: "\taws_token := \"AKIALALEMEL33243OLIA\"",
Date: "2021-11-02T23:48:06Z",
Commit: "491504d5a31946ce75e22554cc34203d8e5ff3ca",
Author: "Zach Rice",
Email: "zricer@protonmail.com",
@@ -81,6 +83,7 @@ func TestFromGit(t *testing.T) {
EndColumn: 36,
Secret: "AKIALALEMEL33243OLIA",
// Line: "\taws_token := \"AKIALALEMEL33243OLIA\"",
Date: "2021-11-02T23:48:06Z",
File: "foo/foo.go",
Commit: "491504d5a31946ce75e22554cc34203d8e5ff3ca",
Author: "Zach Rice",
@@ -120,7 +123,6 @@ func TestFromGit(t *testing.T) {
findings := FromGit(files, cfg, tt.opts)
for _, f := range findings {
f.Match = "" // remove lines cause copying and pasting them has some wack formatting
f.Date = ""
}
assert.ElementsMatch(t, tt.expectedFindings, findings)
}