mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
Merge pull request #558 from AmitHofree/fix_default_config
Removed unnecessary backslashes in default config
This commit is contained in:
4 files changed
+99
-2
No files matched your search
@@ -75,7 +75,7 @@ title = "gitleaks config"
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Google API key"
|
description = "Google API key"
|
||||||
regex = '''AIza[0-9A-Za-z\\-_]{35}'''
|
regex = '''AIza[0-9A-Za-z\-_]{35}'''
|
||||||
tags = ["key", "Google"]
|
tags = ["key", "Google"]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
@@ -130,7 +130,7 @@ title = "gitleaks config"
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Square OAuth secret"
|
description = "Square OAuth secret"
|
||||||
regex = '''sq0csp-[0-9A-Za-z\\-_]{43}'''
|
regex = '''sq0csp-[0-9A-Za-z\-_]{43}'''
|
||||||
tags = ["key", "square"]
|
tags = ["key", "square"]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
|
|||||||
@@ -5,13 +5,71 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v7/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v7/options"
|
||||||
"github.com/zricethezav/gitleaks/v7/scan"
|
"github.com/zricethezav/gitleaks/v7/scan"
|
||||||
)
|
)
|
||||||
|
|
||||||
const repoBasePath = "../testdata/repos/"
|
const repoBasePath = "../testdata/repos/"
|
||||||
const expectPath = "../testdata/expect/"
|
const expectPath = "../testdata/expect/"
|
||||||
|
|
||||||
|
func TestScan(t *testing.T) {
|
||||||
|
err := moveDotGit("dotGit", ".git")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer moveDotGit(".git", "dotGit")
|
||||||
|
tests := []struct {
|
||||||
|
description string
|
||||||
|
opts options.Options
|
||||||
|
wantPath string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
description: "test google api key leak AND square oauth leak",
|
||||||
|
opts: options.Options{
|
||||||
|
Path: filepath.Join(repoBasePath, "with_square_and_google"),
|
||||||
|
Report: filepath.Join(expectPath, "results_square_and_google.json.got"),
|
||||||
|
ReportFormat: "json",
|
||||||
|
NoGit: true,
|
||||||
|
},
|
||||||
|
wantPath: filepath.Join(expectPath, "results_square_and_google.json"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
cfg, err := config.NewConfig(test.opts)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
scanner, err := scan.NewScanner(test.opts, cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(test.description, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
scannerReport, err := scanner.Scan()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(test.description, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = scan.WriteReport(scannerReport, test.opts, cfg)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(test.description, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if test.wantPath != "" {
|
||||||
|
err := fileCheck(test.wantPath, test.opts.Report)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(test.description, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func moveDotGit(from, to string) error {
|
func moveDotGit(from, to string) error {
|
||||||
repoDirs, err := ioutil.ReadDir("../testdata/repos")
|
repoDirs, err := ioutil.ReadDir("../testdata/repos")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": "SQUARE_OAUTH=sq0csp-QZxqK3fHycIxFsjZ7_HoqRN08qY2by3wLXcfJCfsKEg",
|
||||||
|
"lineNumber": 1,
|
||||||
|
"offender": "sq0csp-QZxqK3fHycIxFsjZ7_HoqRN08qY2by3wLXcfJCfsKEg",
|
||||||
|
"offenderEntropy": -1,
|
||||||
|
"commit": "",
|
||||||
|
"repo": "",
|
||||||
|
"repoURL": "",
|
||||||
|
"leakURL": "",
|
||||||
|
"rule": "Square OAuth secret",
|
||||||
|
"commitMessage": "",
|
||||||
|
"author": "",
|
||||||
|
"email": "",
|
||||||
|
"file": ".",
|
||||||
|
"date": "0001-01-01T00:00:00Z",
|
||||||
|
"tags": "key, square"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "GOOGLE_MAPS_KEY=AIzaSyDtz3Di0ZrzeU5ET3UFU0p-xP4bx2FkSrg",
|
||||||
|
"lineNumber": 3,
|
||||||
|
"offender": "AIzaSyDtz3Di0ZrzeU5ET3UFU0p-xP4bx2FkSrg",
|
||||||
|
"offenderEntropy": -1,
|
||||||
|
"commit": "",
|
||||||
|
"repo": "",
|
||||||
|
"repoURL": "",
|
||||||
|
"leakURL": "",
|
||||||
|
"rule": "Google API key",
|
||||||
|
"commitMessage": "",
|
||||||
|
"author": "",
|
||||||
|
"email": "",
|
||||||
|
"file": ".",
|
||||||
|
"date": "0001-01-01T00:00:00Z",
|
||||||
|
"tags": "key, Google"
|
||||||
|
}
|
||||||
|
]
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
SQUARE_OAUTH=sq0csp-QZxqK3fHycIxFsjZ7_HoqRN08qY2by3wLXcfJCfsKEg
|
||||||
|
|
||||||
|
GOOGLE_MAPS_KEY=AIzaSyDtz3Di0ZrzeU5ET3UFU0p-xP4bx2FkSrg
|
||||||
Reference in new issue
Block a user