mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
external repo file support
This commit is contained in:
1 parent
2c80ad5ea9
commit
ccef3680d5
6 files changed
+96
-15
No files matched your search
@@ -2,6 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"os"
|
||||
"bufio"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func TestCheckRegex(t *testing.T) {
|
||||
@@ -29,6 +32,32 @@ func TestCheckRegex(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExternalRegex(t *testing.T) {
|
||||
opts, err := defaultOptions()
|
||||
if err != nil {
|
||||
t.Error()
|
||||
}
|
||||
file, err := os.Create("testregex.txt")
|
||||
if err != nil {
|
||||
t.Error()
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
w := bufio.NewWriter(file)
|
||||
fmt.Fprintln(w, "AKIA[0-9A-Z]{16}")
|
||||
w.Flush()
|
||||
|
||||
opts.RegexFile = "testregex.txt"
|
||||
opts.loadExternalRegex()
|
||||
leaks := doChecks("aws=\"AKIALALEMEL33243OLIAE",
|
||||
Commit{}, &Repo{url:"someurl"})
|
||||
if len(leaks) != 2 {
|
||||
// leak from default regex, leak from external
|
||||
t.Error()
|
||||
}
|
||||
os.Remove("testregex.txt")
|
||||
}
|
||||
|
||||
func TestEntropy(t *testing.T) {
|
||||
var enoughEntropy bool
|
||||
opts := &Options{
|
||||
|
||||
Reference in new issue
Block a user