mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e760d7fed | ||
|
|
679f00dc9c | ||
|
|
dae5c142d7 | ||
|
|
8e8873286e | ||
|
|
6693cbdde3 |
No files matched your search
@@ -5,6 +5,9 @@
|
|||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
### [Gitleaks Action](https://github.com/marketplace/actions/gitleaks) now available for your workflows!
|
||||||
|
|
||||||
|
|
||||||
Audit git repos for secrets. Gitleaks provides a way for you to find unencrypted secrets and other unwanted data types in git repositories. As part of its core functionality, it provides:
|
Audit git repos for secrets. Gitleaks provides a way for you to find unencrypted secrets and other unwanted data types in git repositories. As part of its core functionality, it provides:
|
||||||
|
|
||||||
* Audits for uncommitted changes
|
* Audits for uncommitted changes
|
||||||
@@ -64,7 +67,7 @@ Application Options:
|
|||||||
--password= Password for git repo
|
--password= Password for git repo
|
||||||
--access-token= Access token for git repo
|
--access-token= Access token for git repo
|
||||||
--commit= sha of commit to audit
|
--commit= sha of commit to audit
|
||||||
--files-at-commit= sha of commit to audit all files at commit
|
--files-at-commit= sha of commit to audit all files at commit or "latest" to scan the last commit of the repository
|
||||||
--threads= Maximum number of threads gitleaks spawns
|
--threads= Maximum number of threads gitleaks spawns
|
||||||
--ssh-key= path to ssh key used for auth
|
--ssh-key= path to ssh key used for auth
|
||||||
--uncommitted run gitleaks on uncommitted code
|
--uncommitted run gitleaks on uncommitted code
|
||||||
|
|||||||
@@ -243,6 +243,16 @@ func TestAudit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
|
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo five files at latest commit",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_5",
|
||||||
|
Report: "../test_data/test_local_repo_five_files_at_latest_commit.json.got",
|
||||||
|
FilesAtCommit: "latest",
|
||||||
|
ReportFormat: "json",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "test local repo five at commit",
|
description: "test local repo five at commit",
|
||||||
opts: options.Options{
|
opts: options.Options{
|
||||||
|
|||||||
@@ -224,6 +224,15 @@ func (repo *Repo) Audit() error {
|
|||||||
if repo.Manager.Opts.Commit != "" {
|
if repo.Manager.Opts.Commit != "" {
|
||||||
return inspectCommit(repo.Manager.Opts.Commit, repo, inspectCommitPatches)
|
return inspectCommit(repo.Manager.Opts.Commit, repo, inspectCommitPatches)
|
||||||
} else if repo.Manager.Opts.FilesAtCommit != "" {
|
} else if repo.Manager.Opts.FilesAtCommit != "" {
|
||||||
|
if repo.Manager.Opts.FilesAtCommit == "latest" {
|
||||||
|
// Getting the latest commit on the current branch
|
||||||
|
// ... retrieving the branch being pointed by HEAD
|
||||||
|
ref, err := repo.Repository.Head()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return inspectCommit(ref.Hash().String(), repo, inspectFilesAtCommit)
|
||||||
|
}
|
||||||
return inspectCommit(repo.Manager.Opts.FilesAtCommit, repo, inspectFilesAtCommit)
|
return inspectCommit(repo.Manager.Opts.FilesAtCommit, repo, inspectFilesAtCommit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+51
-18
@@ -124,45 +124,78 @@ title = "gitleaks config"
|
|||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Env Var"
|
description = "Env Var"
|
||||||
regex = '''(?i)(api_key|apikey|secret|key|api|password|pw|host)=[0-9a-zA-Z-_{}]{4,120}'''
|
regex = '''(?i)(apikey|secret|key|api|password|pass|pw|host)=[0-9a-zA-Z-_.{}]{4,120}'''
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Port"
|
description = "Port"
|
||||||
regex = '''(?i)port(.{0,4})?[0-9]{1,10}'''
|
regex = '''(?i)port(.{0,4})?[0-9]{1,10}'''
|
||||||
|
[[rules.whitelist]]
|
||||||
|
regex = '''(?i)port '''
|
||||||
|
description = "ignore export "
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Email"
|
description = "Email"
|
||||||
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'''
|
regex = '''[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}'''
|
||||||
tags = ["email"]
|
tags = ["email"]
|
||||||
|
[[rules.whitelist]]
|
||||||
|
file = '''(?i)bashrc'''
|
||||||
|
description = "ignore bashrc emails"
|
||||||
|
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Generic Credential"
|
description = "Generic Credential"
|
||||||
regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|secret|key|api|password|user|guid|hostname|pw|auth)(.{0,20})?['|"][0-9a-zA-Z-_!{}/=]{4,120}['|"]'''
|
regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|secret|key|api|password|user|guid|hostname|pw|auth)(.{0,20})?['|"]([0-9a-zA-Z-_\/+!{}/=]{4,120})['|"]'''
|
||||||
tags = ["key", "API", "generic"]
|
tags = ["key", "API", "generic"]
|
||||||
|
# ignore leaks with specific identifiers like slack and aws
|
||||||
|
[[rules.whitelist]]
|
||||||
|
regex = '''xox[baprs]-([0-9a-zA-Z]{10,48})'''
|
||||||
|
description = "ignore slack"
|
||||||
|
[[rules.whitelist]]
|
||||||
|
description = "MailChimp API key"
|
||||||
|
regex = '''(?i)(.{0,20})?['"][0-9a-f]{32}-us[0-9]{1,2}['"]'''
|
||||||
|
[[rules.whitelist]]
|
||||||
|
description = "AWS Manager ID"
|
||||||
|
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
|
||||||
|
|
||||||
|
#[[rules]]
|
||||||
|
# description = "s3config"
|
||||||
|
# regex = '''(?i)(dbpasswd|dbuser|dbname|dbhost|api_key|apikey|key|api|password|user|guid|hostname|pw|auth)(.{0,3})?([0-9a-zA-Z-_\/+!{}=]{4,120})'''
|
||||||
|
# fileNameRegex = '''(?i)s3cfg$'''
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "High Entropy"
|
||||||
|
regex = '''[0-9a-zA-Z-_!{}/=]{4,120}'''
|
||||||
|
fileNameRegex = '''(?i)(dump.sql|high-entropy-misc.txt)$'''
|
||||||
|
tags = ["entropy"]
|
||||||
|
[[rules.Entropies]]
|
||||||
|
Min = "4.3"
|
||||||
|
Max = "7.0"
|
||||||
|
[[rules.whitelist]]
|
||||||
|
description = "ignore ssh key and pems"
|
||||||
|
file = '''(pem|ppk|env)$'''
|
||||||
|
path = '''(.*)?ssh'''
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Potential bash var"
|
||||||
|
regex='''(?i)(=)([0-9a-zA-Z-_!{}=]{4,120})'''
|
||||||
|
tags = ["key", "bash", "API", "generic"]
|
||||||
|
[[rules.Entropies]]
|
||||||
|
Min = "3.5"
|
||||||
|
Max = "4.5"
|
||||||
|
Group = "1"
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "WP-Config"
|
description = "WP-Config"
|
||||||
regex='''define(.{0,20})?(DB_CHARSET|NONCE_SALT|LOGGED_IN_SALT|AUTH_SALT|NONCE_KEY|DB_HOST|DB_PASSWORD|AUTH_KEY|SECURE_AUTH_KEY|LOGGED_IN_KEY|DB_NAME|DB_USER)(.{0,20})?['|"].{10,120}['|"]'''
|
regex='''define(.{0,20})?(DB_CHARSET|NONCE_SALT|LOGGED_IN_SALT|AUTH_SALT|NONCE_KEY|DB_HOST|DB_PASSWORD|AUTH_KEY|SECURE_AUTH_KEY|LOGGED_IN_KEY|DB_NAME|DB_USER)(.{0,20})?['|"].{10,120}['|"]'''
|
||||||
tags = ["key", "API", "generic"]
|
tags = ["key", "API", "generic"]
|
||||||
|
|
||||||
|
|
||||||
[[rules]]
|
|
||||||
description = "Pure Entropy"
|
|
||||||
regex = '''['|"][0-9a-zA-Z-._{}$\/=]{40,120}['|"]'''
|
|
||||||
[[rules.Entropies]]
|
|
||||||
Min = "5.0"
|
|
||||||
Max = "5.6"
|
|
||||||
|
|
||||||
[[rules]]
|
|
||||||
description = "Entropy plus Generic Credential"
|
|
||||||
regex = '''(?i)(api_key|apikey|secret|key|api|password|pw)'''
|
|
||||||
[[rules.Entropies]]
|
|
||||||
Min = "5.2"
|
|
||||||
Max = "5.5"
|
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Files with keys and credentials"
|
description = "Files with keys and credentials"
|
||||||
file = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)'''
|
fileNameRegex = '''(?i)(id_rsa|passwd|id_rsa.pub|pgpass|pem|key|shadow)'''
|
||||||
|
|
||||||
[whitelist]
|
[whitelist]
|
||||||
description = "image whitelists"
|
description = "image whitelists"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ go 1.13
|
|||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/google/go-cmp v0.4.0 // indirect
|
github.com/google/go-cmp v0.4.0 // indirect
|
||||||
github.com/google/go-github v17.0.0+incompatible
|
github.com/google/go-github/v29 v29.0.3
|
||||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4
|
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4
|
||||||
github.com/jessevdk/go-flags v1.4.0
|
github.com/jessevdk/go-flags v1.4.0
|
||||||
github.com/mattn/go-colorable v0.1.2
|
github.com/mattn/go-colorable v0.1.2
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
|
|||||||
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
||||||
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
|
||||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
github.com/google/go-github/v29 v29.0.3 h1:IktKCTwU//aFHnpA+2SLIi7Oo9uhAzgsdZNbcAqhgdc=
|
||||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
github.com/google/go-github/v29 v29.0.3/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E=
|
||||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||||
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 h1:60gBOooTSmNtrqNaRvrDbi8VAne0REaek2agjnITKSw=
|
github.com/hako/durafmt v0.0.0-20191009132224-3f39dc1ed9f4 h1:60gBOooTSmNtrqNaRvrDbi8VAne0REaek2agjnITKSw=
|
||||||
@@ -81,10 +83,12 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
|
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk=
|
||||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@@ -107,6 +111,7 @@ golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a h1:mEQZbbaBjWyLNy0tmZmgEuQ
|
|||||||
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
|
||||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
|||||||
+15
-3
@@ -10,12 +10,13 @@ import (
|
|||||||
"github.com/zricethezav/gitleaks/v4/manager"
|
"github.com/zricethezav/gitleaks/v4/manager"
|
||||||
"github.com/zricethezav/gitleaks/v4/options"
|
"github.com/zricethezav/gitleaks/v4/options"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/v29/github"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"gopkg.in/src-d/go-git.v4"
|
"gopkg.in/src-d/go-git.v4"
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
||||||
@@ -57,7 +58,10 @@ func (g *Github) Audit() {
|
|||||||
Page: 1,
|
Page: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
var githubRepos []*github.Repository
|
var (
|
||||||
|
githubRepos []*github.Repository
|
||||||
|
auth transport.AuthMethod
|
||||||
|
)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
var (
|
var (
|
||||||
@@ -71,6 +75,9 @@ func (g *Github) Audit() {
|
|||||||
} else if g.manager.Opts.Organization != "" {
|
} else if g.manager.Opts.Organization != "" {
|
||||||
_githubRepos, resp, err = g.client.Repositories.ListByOrg(ctx, g.manager.Opts.Organization,
|
_githubRepos, resp, err = g.client.Repositories.ListByOrg(ctx, g.manager.Opts.Organization,
|
||||||
&github.RepositoryListByOrgOptions{ListOptions: listOptions})
|
&github.RepositoryListByOrgOptions{ListOptions: listOptions})
|
||||||
|
} else {
|
||||||
|
_githubRepos, resp, err = g.client.Repositories.List(ctx, "",
|
||||||
|
&github.RepositoryListOptions{ListOptions: listOptions})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range _githubRepos {
|
for _, r := range _githubRepos {
|
||||||
@@ -99,8 +106,13 @@ func (g *Github) Audit() {
|
|||||||
|
|
||||||
for _, repo := range githubRepos {
|
for _, repo := range githubRepos {
|
||||||
r := audit.NewRepo(g.manager)
|
r := audit.NewRepo(g.manager)
|
||||||
|
|
||||||
|
if g.manager.CloneOptions != nil {
|
||||||
|
auth = g.manager.CloneOptions.Auth
|
||||||
|
}
|
||||||
err := r.Clone(&git.CloneOptions{
|
err := r.Clone(&git.CloneOptions{
|
||||||
URL: *repo.CloneURL,
|
URL: *repo.CloneURL,
|
||||||
|
Auth: auth,
|
||||||
})
|
})
|
||||||
r.Name = *repo.Name
|
r.Name = *repo.Name
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,7 @@ const (
|
|||||||
Success = 0
|
Success = 0
|
||||||
LeaksPresent = 1
|
LeaksPresent = 1
|
||||||
ErrorEncountered = 2
|
ErrorEncountered = 2
|
||||||
|
donateMessage = "👋 maintaining gitleaks takes a lot of work so consider sponsoring me or donating a little something\n❤️ https://github.com/sponsors/zricethezav\n💸 https://www.paypal.me/zricethezav\n₿ btc:3GndEzRZa6rJ8ZpkLureUcc5TDHMYfpDxn"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Options stores values of command line options
|
// Options stores values of command line options
|
||||||
@@ -35,7 +36,7 @@ type Options struct {
|
|||||||
Username string `long:"username" description:"Username for git repo"`
|
Username string `long:"username" description:"Username for git repo"`
|
||||||
Password string `long:"password" description:"Password for git repo"`
|
Password string `long:"password" description:"Password for git repo"`
|
||||||
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
||||||
Commit string `long:"commit" description:"sha of commit to audit"`
|
Commit string `long:"commit" description:"sha of commit to audit or \"latest\" to scan the last commit of the repository"`
|
||||||
FilesAtCommit string `long:"files-at-commit" description:"sha of commit to audit all files at commit"`
|
FilesAtCommit string `long:"files-at-commit" description:"sha of commit to audit all files at commit"`
|
||||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||||
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
||||||
@@ -76,6 +77,7 @@ func ParseOptions() (Options, error) {
|
|||||||
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type != flags.ErrHelp {
|
if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type != flags.ErrHelp {
|
||||||
parser.WriteHelp(os.Stdout)
|
parser.WriteHelp(os.Stdout)
|
||||||
}
|
}
|
||||||
|
fmt.Println(donateMessage)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user