mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3b799ec63 | ||
|
|
4b6f4d0de5 | ||
|
|
fbfb3f591e | ||
|
|
b91799aa18 | ||
|
|
db1b54bf9f | ||
|
|
e9529744f8 | ||
|
|
d1f642a9df | ||
|
|
9261f1c47f | ||
|
|
991223abab | ||
|
|
801d44a6e4 |
No files matched your search
@@ -11,8 +11,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
GO111MODULE: on
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
@@ -26,8 +24,6 @@ jobs:
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
|
||||||
GO111MODULE: on
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ FROM golang:1.17 AS build
|
|||||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN VERSION=$(git describe --tags --abbrev=0) && \
|
RUN VERSION=$(git describe --tags --abbrev=0) && \
|
||||||
GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="github.com/zricethezav/gitleaks/v8/cmd.Version=${VERSION}
|
CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="github.com/zricethezav/gitleaks/v8/cmd.Version=${VERSION}
|
||||||
|
|
||||||
FROM alpine:3.14.2
|
FROM alpine:3.14.2
|
||||||
RUN adduser -D gitleaks && \
|
RUN adduser -D gitleaks && \
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ Use "gitleaks [command] --help" for more information about a command.
|
|||||||
### Commands
|
### Commands
|
||||||
There are two commands you will use to detect secrets; `detect` and `protect`.
|
There are two commands you will use to detect secrets; `detect` and `protect`.
|
||||||
#### Detect
|
#### Detect
|
||||||
The `detect` command is used to scan repos, directories, and files. This comand can be used on developer machines and in CI environments.
|
The `detect` command is used to scan repos, directories, and files. This command can be used on developer machines and in CI environments.
|
||||||
|
|
||||||
When running `detect` on a git repository, gitleaks will parse the output of a `git log -p` command (you can see how this executed
|
When running `detect` on a git repository, gitleaks will parse the output of a `git log -p` command (you can see how this executed
|
||||||
[here](https://github.com/zricethezav/gitleaks/blob/7240e16769b92d2a1b137c17d6bf9d55a8562899/git/git.go#L17-L25)).
|
[here](https://github.com/zricethezav/gitleaks/blob/7240e16769b92d2a1b137c17d6bf9d55a8562899/git/git.go#L17-L25)).
|
||||||
@@ -203,7 +203,7 @@ title = "Gitleaks title"
|
|||||||
# Unique identifier for this rule
|
# Unique identifier for this rule
|
||||||
id = "awesome-rule-1"
|
id = "awesome-rule-1"
|
||||||
# Short human readable description of the rule.
|
# Short human readable description of the rule.
|
||||||
description = "awsome rule 1"
|
description = "awesome rule 1"
|
||||||
# Golang regular expression used to detect secrets. Note Golang's regex engine
|
# Golang regular expression used to detect secrets. Note Golang's regex engine
|
||||||
# does not support lookaheads.
|
# does not support lookaheads.
|
||||||
regex = '''one-go-style-regex-for-this-rule'''
|
regex = '''one-go-style-regex-for-this-rule'''
|
||||||
@@ -225,7 +225,7 @@ commits = [ "commit-A", "commit-B"]
|
|||||||
paths = ['''one-file-path-regex''']
|
paths = ['''one-file-path-regex''']
|
||||||
regexes = ['''one-regex-within-the-already-matched-regex''']
|
regexes = ['''one-regex-within-the-already-matched-regex''']
|
||||||
|
|
||||||
# This is a global allowlist which has a higher order of precendence than rule-specific allowlists.
|
# This is a global allowlist which has a higher order of precedence than rule-specific allowlists.
|
||||||
# If a commit listed in the `commits` field below is encountered then that commit will be skipped and no
|
# If a commit listed in the `commits` field below is encountered then that commit will be skipped and no
|
||||||
# secrets will be detected for said commit. The same logic applies for regexes and paths.
|
# secrets will be detected for said commit. The same logic applies for regexes and paths.
|
||||||
[allowlist]
|
[allowlist]
|
||||||
|
|||||||
+21
-21
@@ -2,7 +2,7 @@ title = "gitleaks config"
|
|||||||
|
|
||||||
# Gitleaks rules are defined by regular expressions and entropy ranges.
|
# Gitleaks rules are defined by regular expressions and entropy ranges.
|
||||||
# Some secrets have unique signatures which make detecting those secrets easy.
|
# Some secrets have unique signatures which make detecting those secrets easy.
|
||||||
# Examples of those secrets would be Gitlab Personal Access Tokens, AWS keys, and Github Access Tokens.
|
# Examples of those secrets would be GitLab Personal Access Tokens, AWS keys, and GitHub Access Tokens.
|
||||||
# All these examples have defined prefixes like `glpat`, `AKIA`, `ghp_`, etc.
|
# All these examples have defined prefixes like `glpat`, `AKIA`, `ghp_`, etc.
|
||||||
#
|
#
|
||||||
# Other secrets might just be a hash which means we need to write more complex rules to verify
|
# Other secrets might just be a hash which means we need to write more complex rules to verify
|
||||||
@@ -62,12 +62,12 @@ regex = '''-----BEGIN PGP PRIVATE KEY BLOCK-----'''
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "github-pat"
|
id = "github-pat"
|
||||||
description = "Github Personal Access Token"
|
description = "GitHub Personal Access Token"
|
||||||
regex = '''ghp_[0-9a-zA-Z]{36}'''
|
regex = '''ghp_[0-9a-zA-Z]{36}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "github-oauth"
|
id = "github-oauth"
|
||||||
description = "Github OAuth Access Token"
|
description = "GitHub OAuth Access Token"
|
||||||
regex = '''gho_[0-9a-zA-Z]{36}'''
|
regex = '''gho_[0-9a-zA-Z]{36}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
@@ -83,12 +83,12 @@ regex = '''-----BEGIN EC PRIVATE KEY-----'''
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "github-app-token"
|
id = "github-app-token"
|
||||||
description = "Github App Token"
|
description = "GitHub App Token"
|
||||||
regex = '''(ghu|ghs)_[0-9a-zA-Z]{36}'''
|
regex = '''(ghu|ghs)_[0-9a-zA-Z]{36}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "github-refresh-token"
|
id = "github-refresh-token"
|
||||||
description = "Github Refresh Token"
|
description = "GitHub Refresh Token"
|
||||||
regex = '''ghr_[0-9a-zA-Z]{76}'''
|
regex = '''ghr_[0-9a-zA-Z]{76}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
@@ -326,18 +326,18 @@ regex = '''(?i)(finicity[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([
|
|||||||
secretGroup = 3
|
secretGroup = 3
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "flutterweave-public-key"
|
id = "flutterwave-public-key"
|
||||||
description = "Flutterweave public key"
|
description = "Flutterwave public key"
|
||||||
regex = '''FLWPUBK_TEST-(?i)[a-h0-9]{32}-X'''
|
regex = '''FLWPUBK_TEST-(?i)[a-h0-9]{32}-X'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "flutterweave-secret-key"
|
id = "flutterwave-secret-key"
|
||||||
description = "Flutterweave secret key"
|
description = "Flutterwave secret key"
|
||||||
regex = '''FLWSECK_TEST-(?i)[a-h0-9]{32}-X'''
|
regex = '''FLWSECK_TEST-(?i)[a-h0-9]{32}-X'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "flutterweave-enc-key"
|
id = "flutterwave-enc-key"
|
||||||
description = "Flutterweave encrypted key"
|
description = "Flutterwave encrypted key"
|
||||||
regex = '''FLWSECK_TEST[a-h0-9]{12}'''
|
regex = '''FLWSECK_TEST[a-h0-9]{12}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
@@ -357,12 +357,12 @@ regex = '''['\"]eyJrIjoi(?i)[a-z0-9-_=]{72,92}['\"]'''
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "hashicorp-tf-api-token"
|
id = "hashicorp-tf-api-token"
|
||||||
description = "Hashicorp Terraform user/org API token"
|
description = "HashiCorp Terraform user/org API token"
|
||||||
regex = '''['\"](?i)[a-z0-9]{14}\.atlasv1\.[a-z0-9-_=]{60,70}['\"]'''
|
regex = '''['\"](?i)[a-z0-9]{14}\.atlasv1\.[a-z0-9-_=]{60,70}['\"]'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "hubspot-api-token"
|
id = "hubspot-api-token"
|
||||||
description = "Hubspot API token"
|
description = "HubSpot API token"
|
||||||
regex = '''(?i)(hubspot[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([a-h0-9]{8}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{12})['\"]'''
|
regex = '''(?i)(hubspot[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([a-h0-9]{8}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{12})['\"]'''
|
||||||
secretGroup = 3
|
secretGroup = 3
|
||||||
|
|
||||||
@@ -470,12 +470,12 @@ regex = '''['\"](npm_(?i)[a-z0-9]{36})['\"]'''
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "planetscale-password"
|
id = "planetscale-password"
|
||||||
description = "Planetscale password"
|
description = "PlanetScale password"
|
||||||
regex = '''pscale_pw_(?i)[a-z0-9\-_\.]{43}'''
|
regex = '''pscale_pw_(?i)[a-z0-9\-_\.]{43}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "planetscale-api-token"
|
id = "planetscale-api-token"
|
||||||
description = "Planetscale API token"
|
description = "PlanetScale API token"
|
||||||
regex = '''pscale_tkn_(?i)[a-z0-9\-_\.]{43}'''
|
regex = '''pscale_tkn_(?i)[a-z0-9\-_\.]{43}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
@@ -495,7 +495,7 @@ regex = '''rubygems_[a-f0-9]{48}'''
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "sendgrid-api-token"
|
id = "sendgrid-api-token"
|
||||||
description = "Sendgrid API token"
|
description = "SendGrid API token"
|
||||||
regex = '''SG\.(?i)[a-z0-9_\-\.]{66}'''
|
regex = '''SG\.(?i)[a-z0-9_\-\.]{66}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
@@ -509,14 +509,14 @@ description = "Shippo API token"
|
|||||||
regex = '''shippo_(live|test)_[a-f0-9]{40}'''
|
regex = '''shippo_(live|test)_[a-f0-9]{40}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "linedin-client-secret"
|
id = "linkedin-client-secret"
|
||||||
description = "Linkedin Client secret"
|
description = "LinkedIn Client secret"
|
||||||
regex = '''(?i)(linkedin[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([a-z]{16})['\"]'''
|
regex = '''(?i)(linkedin[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([a-z]{16})['\"]'''
|
||||||
secretGroup = 3
|
secretGroup = 3
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "linedin-client-id"
|
id = "linkedin-client-id"
|
||||||
description = "Linkedin Client ID"
|
description = "LinkedIn Client ID"
|
||||||
regex = '''(?i)(linkedin[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([a-z0-9]{14})['\"]'''
|
regex = '''(?i)(linkedin[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([a-z0-9]{14})['\"]'''
|
||||||
secretGroup = 3
|
secretGroup = 3
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ secretGroup = 3
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
id = "generic-api-key"
|
id = "generic-api-key"
|
||||||
description = "Generic API Key"
|
description = "Generic API Key"
|
||||||
regex = '''(?i)((key|api|token|secret|password)[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([0-9a-zA-Z\-_=]{8,64})['\"]'''
|
regex = '''(?i)((key|api[^Version]|token|secret|password)[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([0-9a-zA-Z\-_=]{8,64})['\"]'''
|
||||||
entropy = 3.7
|
entropy = 3.7
|
||||||
secretGroup = 4
|
secretGroup = 4
|
||||||
|
|
||||||
|
|||||||
+3
-8
@@ -17,6 +17,8 @@ type Options struct {
|
|||||||
Redact bool
|
Redact bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAXGOROUTINES = 4
|
||||||
|
|
||||||
func DetectFindings(cfg config.Config, b []byte, filePath string, commit string) []report.Finding {
|
func DetectFindings(cfg config.Config, b []byte, filePath string, commit string) []report.Finding {
|
||||||
var findings []report.Finding
|
var findings []report.Finding
|
||||||
linePairs := regexp.MustCompile("\n").FindAllIndex(b, -1)
|
linePairs := regexp.MustCompile("\n").FindAllIndex(b, -1)
|
||||||
@@ -82,7 +84,7 @@ func DetectFindings(cfg config.Config, b []byte, filePath string, commit string)
|
|||||||
// extract secret from secret group if set
|
// extract secret from secret group if set
|
||||||
if r.SecretGroup != 0 {
|
if r.SecretGroup != 0 {
|
||||||
groups := r.Regex.FindStringSubmatch(secret)
|
groups := r.Regex.FindStringSubmatch(secret)
|
||||||
if len(groups)-1 > r.SecretGroup || len(groups) == 0 {
|
if len(groups) <= r.SecretGroup || len(groups) == 0 {
|
||||||
// Config validation should prevent this
|
// Config validation should prevent this
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -106,13 +108,6 @@ func DetectFindings(cfg config.Config, b []byte, filePath string, commit string)
|
|||||||
return dedupe(findings)
|
return dedupe(findings)
|
||||||
}
|
}
|
||||||
|
|
||||||
func limit(s string) string {
|
|
||||||
if len(s) > 500 {
|
|
||||||
return s[:500] + "..."
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func printFinding(f report.Finding) {
|
func printFinding(f report.Finding) {
|
||||||
var b []byte
|
var b []byte
|
||||||
b, _ = json.MarshalIndent(f, "", " ")
|
b, _ = json.MarshalIndent(f, "", " ")
|
||||||
|
|||||||
+5
-10
@@ -7,7 +7,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
godocutil "golang.org/x/tools/godoc/util"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
"github.com/zricethezav/gitleaks/v8/report"
|
"github.com/zricethezav/gitleaks/v8/report"
|
||||||
@@ -20,7 +19,7 @@ func FromFiles(source string, cfg config.Config, outputOptions Options) ([]repor
|
|||||||
findings []report.Finding
|
findings []report.Finding
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
)
|
)
|
||||||
concurrentGoroutines := make(chan struct{}, 4)
|
concurrentGoroutines := make(chan struct{}, MAXGOROUTINES)
|
||||||
g, _ := errgroup.WithContext(context.Background())
|
g, _ := errgroup.WithContext(context.Background())
|
||||||
paths := make(chan string)
|
paths := make(chan string)
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
@@ -41,18 +40,15 @@ func FromFiles(source string, cfg config.Config, outputOptions Options) ([]repor
|
|||||||
})
|
})
|
||||||
for pa := range paths {
|
for pa := range paths {
|
||||||
p := pa
|
p := pa
|
||||||
|
concurrentGoroutines <- struct{}{}
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
concurrentGoroutines <- struct{}{}
|
defer func() {
|
||||||
|
<-concurrentGoroutines
|
||||||
|
}()
|
||||||
b, err := os.ReadFile(p)
|
b, err := os.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
<-concurrentGoroutines
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !godocutil.IsText(b) {
|
|
||||||
<-concurrentGoroutines
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
fis := DetectFindings(cfg, b, p, "")
|
fis := DetectFindings(cfg, b, p, "")
|
||||||
for _, fi := range fis {
|
for _, fi := range fis {
|
||||||
// need to add 1 since line counting starts at 1
|
// need to add 1 since line counting starts at 1
|
||||||
@@ -69,7 +65,6 @@ func FromFiles(source string, cfg config.Config, outputOptions Options) ([]repor
|
|||||||
findings = append(findings, fi)
|
findings = append(findings, fi)
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
}
|
}
|
||||||
<-concurrentGoroutines
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
"github.com/zricethezav/gitleaks/v8/report"
|
"github.com/zricethezav/gitleaks/v8/report"
|
||||||
godocutil "golang.org/x/tools/godoc/util"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// FromGit accepts a gitdiff.File channel (structure output from `git log -p`) and a configuration
|
// FromGit accepts a gitdiff.File channel (structure output from `git log -p`) and a configuration
|
||||||
@@ -19,16 +18,20 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
|
|||||||
var findings []report.Finding
|
var findings []report.Finding
|
||||||
mu := sync.Mutex{}
|
mu := sync.Mutex{}
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
|
concurrentGoroutines := make(chan struct{}, MAXGOROUTINES)
|
||||||
commitMap := make(map[string]bool)
|
commitMap := make(map[string]bool)
|
||||||
for f := range files {
|
for f := range files {
|
||||||
// keep track of commits for logging
|
// keep track of commits for logging
|
||||||
if f.PatchHeader != nil {
|
if f.PatchHeader != nil {
|
||||||
commitMap[f.PatchHeader.SHA] = true
|
commitMap[f.PatchHeader.SHA] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
concurrentGoroutines <- struct{}{}
|
||||||
go func(f *gitdiff.File) {
|
go func(f *gitdiff.File) {
|
||||||
defer wg.Done()
|
defer func() {
|
||||||
|
wg.Done()
|
||||||
|
<-concurrentGoroutines
|
||||||
|
}()
|
||||||
if f.IsBinary {
|
if f.IsBinary {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -54,10 +57,6 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !godocutil.IsText([]byte(tf.Raw(gitdiff.OpAdd))) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, fi := range DetectFindings(cfg, []byte(tf.Raw(gitdiff.OpAdd)), f.NewName, commitSHA) {
|
for _, fi := range DetectFindings(cfg, []byte(tf.Raw(gitdiff.OpAdd)), f.NewName, commitSHA) {
|
||||||
// don't add to start/end lines if finding is from a file only rule
|
// don't add to start/end lines if finding is from a file only rule
|
||||||
if !strings.HasPrefix(fi.Match, "file detected") {
|
if !strings.HasPrefix(fi.Match, "file detected") {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module github.com/zricethezav/gitleaks/v8
|
module github.com/zricethezav/gitleaks/v8
|
||||||
|
|
||||||
go 1.16
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gitleaks/go-gitdiff v0.7.4
|
github.com/gitleaks/go-gitdiff v0.7.4
|
||||||
@@ -9,7 +9,26 @@ require (
|
|||||||
github.com/spf13/viper v1.8.1
|
github.com/spf13/viper v1.8.1
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/fsnotify/fsnotify v1.4.9 // indirect
|
||||||
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
|
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||||
|
github.com/magiconair/properties v1.8.5 // indirect
|
||||||
|
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
||||||
|
github.com/pelletier/go-toml v1.9.3 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/spf13/afero v1.6.0 // indirect
|
||||||
|
github.com/spf13/cast v1.3.1 // indirect
|
||||||
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||||
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
|
github.com/subosito/gotenv v1.2.0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 // indirect
|
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 // indirect
|
||||||
golang.org/x/tools v0.1.5
|
golang.org/x/text v0.3.5 // indirect
|
||||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
|
||||||
|
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||||
)
|
)
|
||||||
@@ -467,7 +467,6 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f
|
|||||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
|
|
||||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
|||||||
@@ -2,4 +2,3 @@ package report
|
|||||||
|
|
||||||
const version = "v8.0.0"
|
const version = "v8.0.0"
|
||||||
const driver = "gitleaks"
|
const driver = "gitleaks"
|
||||||
const driverURL = "https://github.com/zricethezav/gitleaks"
|
|
||||||
+27
-17
@@ -30,25 +30,46 @@ func getRuns(cfg config.Config, findings []Finding) []Runs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getTool(cfg config.Config) Tool {
|
func getTool(cfg config.Config) Tool {
|
||||||
return Tool{
|
tool := Tool{
|
||||||
Driver: Driver{
|
Driver: Driver{
|
||||||
Name: driver,
|
Name: driver,
|
||||||
SemanticVersion: version,
|
SemanticVersion: version,
|
||||||
Rules: getRules(cfg),
|
Rules: getRules(cfg),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if this tool has no rules, ensure that it is represented as [] instead of null/nil
|
||||||
|
if hasEmptyRules(tool) {
|
||||||
|
tool.Driver.Rules = make([]Rules, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return tool
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasEmptyRules(tool Tool) bool {
|
||||||
|
return len(tool.Driver.Rules) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRules(cfg config.Config) []Rules {
|
func getRules(cfg config.Config) []Rules {
|
||||||
// TODO for _, rule := range cfg.Rules {
|
// TODO for _, rule := range cfg.Rules {
|
||||||
var rules []Rules
|
var rules []Rules
|
||||||
for _, rule := range cfg.Rules {
|
for _, rule := range cfg.Rules {
|
||||||
rules = append(rules, Rules{
|
shortDescription := ShortDescription{
|
||||||
ID: rule.RuleID,
|
Text: rule.Description,
|
||||||
Name: rule.Description,
|
}
|
||||||
Description: ShortDescription{
|
if rule.Regex != nil {
|
||||||
|
shortDescription = ShortDescription{
|
||||||
Text: rule.Regex.String(),
|
Text: rule.Regex.String(),
|
||||||
},
|
}
|
||||||
|
} else if rule.Path != nil {
|
||||||
|
shortDescription = ShortDescription{
|
||||||
|
Text: rule.Path.String(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rules = append(rules, Rules{
|
||||||
|
ID: rule.RuleID,
|
||||||
|
Name: rule.Description,
|
||||||
|
Description: shortDescription,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return rules
|
return rules
|
||||||
@@ -186,14 +207,3 @@ type Runs struct {
|
|||||||
Tool Tool `json:"tool"`
|
Tool Tool `json:"tool"`
|
||||||
Results []Results `json:"results"`
|
Results []Results `json:"results"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func configToRules(cfg config.Config) []Rules {
|
|
||||||
var rules []Rules
|
|
||||||
for _, rule := range cfg.Rules {
|
|
||||||
rules = append(rules, Rules{
|
|
||||||
ID: rule.RuleID,
|
|
||||||
Name: rule.Description,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return rules
|
|
||||||
}
|
|
||||||
Vendored
BIN
Binary file not shown.
Reference in new issue
Block a user