mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 12:14:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f6ec56cfa | ||
|
|
4695bdb828 | ||
|
|
b58d3f102c | ||
|
|
e18d0da14b | ||
|
|
c33331503a | ||
|
|
d68f282a94 | ||
|
|
4c232b5014 | ||
|
|
652f743b43 | ||
|
|
8ad8470035 | ||
|
|
ad138e213f | ||
|
|
81fc7f93b7 | ||
|
|
c63f9c6f61 | ||
|
|
dfcab34362 | ||
|
|
d8fafb2396 | ||
|
|
5454f7bdec | ||
|
|
7900fbae49 | ||
|
|
2719f0e001 | ||
|
|
9ea08626dc | ||
|
|
22e600ebe3 | ||
|
|
1207d58159 | ||
|
|
db3bc42b83 | ||
|
|
80093b8a7b | ||
|
|
9febafb621 | ||
|
|
b5cb8ad01b | ||
|
|
8863af47d6 | ||
|
|
67fcd836b3 | ||
|
|
8d1f98c796 | ||
|
|
ca20267a84 | ||
|
|
b66ac75e4f | ||
|
|
6eaad03960 | ||
|
|
09242ce9c8 | ||
|
|
c98e5e0d27 | ||
|
|
4ed0ca4902 | ||
|
|
fb5d707e08 | ||
|
|
50493dbe1f | ||
|
|
ed65b65095 | ||
|
|
c5ccbb9468 | ||
|
|
3821f30b06 | ||
|
|
d22371873b | ||
|
|
87d96295d6 | ||
|
|
228396b37b | ||
|
|
a82bc53d89 | ||
|
|
4fb43823ef | ||
|
|
b1c9c7ecbe | ||
|
|
72977e41b6 | ||
|
|
7b02c98eb4 | ||
|
|
2a7bcffd7c | ||
|
|
bd79c3eaca | ||
|
|
7fb4eda723 | ||
|
|
a044b815b3 | ||
|
|
bf380d4767 | ||
|
|
f487f85378 | ||
|
|
958f55ac62 | ||
|
|
c7acf33d96 | ||
|
|
9faaa4a09c | ||
|
|
79068b35e5 | ||
|
|
80468eff1d | ||
|
|
ef8223700a | ||
|
|
2463f11e71 | ||
|
|
6f251eef65 | ||
|
|
20f9a1d4eb | ||
|
|
722ce8213a | ||
|
|
79780b884d | ||
|
|
c5683ca6a3 | ||
|
|
0357c3cbf6 | ||
|
|
782f310478 | ||
|
|
489d13c14e | ||
|
|
d29ee55171 | ||
|
|
611db6579b | ||
|
|
0589ae0298 | ||
|
|
82f7e32b71 | ||
|
|
f97a9ee872 | ||
|
|
78eebaca9d | ||
|
|
6f967cad68 | ||
|
|
88f56d3695 | ||
|
|
9609928c02 | ||
|
|
23cb69fba4 | ||
|
|
d1c77598da | ||
|
|
4451b455f3 | ||
|
|
7fb21a4e61 | ||
|
|
f6193bc92c | ||
|
|
9bc725786d | ||
|
|
b6cc71aa3a | ||
|
|
cfdeb0d7e0 | ||
|
|
107a41827b | ||
|
|
7fac002325 | ||
|
|
4b541044e8 | ||
|
|
af7d5bcb83 | ||
|
|
3e8cd2d1ab | ||
|
|
ddcc75371f | ||
|
|
9708e65c25 | ||
|
|
198e41051e | ||
|
|
e273a970a4 | ||
|
|
a503b583ba | ||
|
|
d5c275d6b2 | ||
|
|
5361c7c917 | ||
|
|
6cc0e386ac | ||
|
|
b4df42364d | ||
|
|
4344b00934 | ||
|
|
f74ced7985 | ||
|
|
c08cb1dc9a | ||
|
|
991a940412 | ||
|
|
ade376ab77 | ||
|
|
1c81ae02fa | ||
|
|
e9b93c6033 | ||
|
|
de105fca6d | ||
|
|
a3be7222a6 | ||
|
|
b44958220e | ||
|
|
2f6b9f72d1 | ||
|
|
3fdc9c13d2 | ||
|
|
96b92c3d07 | ||
|
|
f6a7439306 | ||
|
|
59fdd904af | ||
|
|
c2afd56bbe | ||
|
|
818e32f7a4 | ||
|
|
3fa5a3a954 | ||
|
|
2020e6a9ab | ||
|
|
9122a2d359 | ||
|
|
398d0c46dd | ||
|
|
ae26eff464 | ||
|
|
c6424a6fc3 | ||
|
|
6411402d43 | ||
|
|
d71d95d65e | ||
|
|
3188ad6005 | ||
|
|
7fc11bb264 | ||
|
|
36c52c6b73 | ||
|
|
1f323d8b69 | ||
|
|
d88bc094f7 | ||
|
|
3fdaefdaa3 | ||
|
|
f3ae52e138 | ||
|
|
d6a828a530 | ||
|
|
d2ffffecbd | ||
|
|
a43dc0d3d0 | ||
|
|
69ed20e25e | ||
|
|
52b895a603 | ||
|
|
3f4d91fc22 | ||
|
|
049f5b2435 | ||
|
|
7a6183dab0 | ||
|
|
3c7f3f0e08 | ||
|
|
0e3f4f7abb | ||
|
|
3ed85671a4 | ||
|
|
e977850ab4 | ||
|
|
ad7a4fb4ea | ||
|
|
b2cf03c7e3 | ||
|
|
a3f623cc69 | ||
|
|
cc71bb1e9a | ||
|
|
7bad9f7654 | ||
|
|
977236cb5f | ||
|
|
a211b1601f | ||
|
|
0e5f644b67 | ||
|
|
f320a60e6f | ||
|
|
c4526b2c55 | ||
|
|
748076d976 | ||
|
|
db8e5e672e | ||
|
|
973c794cf0 | ||
|
|
f0d4499064 | ||
|
|
ab38a46986 | ||
|
|
b022d1c856 | ||
|
|
b69b5157a0 | ||
|
|
7357adca5e | ||
|
|
4c3da6ebb7 | ||
|
|
dbe3746455 | ||
|
|
7edfc6b5d5 | ||
|
|
efe40cae39 | ||
|
|
7cb5f6f64c | ||
|
|
2930537190 | ||
|
|
a91c6717a0 | ||
|
|
906085fba6 | ||
|
|
d0ba52e2be | ||
|
|
8a8306288e | ||
|
|
a9e6d8c9a7 | ||
|
|
2f73a3e3cf | ||
|
|
f6966057f5 | ||
|
|
0bf13fc25a | ||
|
|
83e99bacf1 | ||
|
|
e393d299bc | ||
|
|
263ce82365 | ||
|
|
3c0e068b69 | ||
|
|
f3adda07ca | ||
|
|
ed205a5f63 | ||
|
|
6018012b7e | ||
|
|
7f77987d91 | ||
|
|
48a2e0e318 | ||
|
|
4e303d0284 | ||
|
|
c1add1d268 | ||
|
|
202106a190 | ||
|
|
8e94f98e92 | ||
|
|
dbb42a727d | ||
|
|
259946000b | ||
|
|
8ffb980ee5 | ||
|
|
4181ad647a | ||
|
|
48ea14bd47 | ||
|
|
81f0002845 | ||
|
|
c11adc91ad | ||
|
|
d1d9054ef0 | ||
|
|
5fe58bf0b0 | ||
|
|
5c2e8132f2 |
No files matched your search
@@ -0,0 +1,8 @@
|
|||||||
|
# Default — every PR requires at least one org member review.
|
||||||
|
* @bryanbeverly @dustin-decker @dxa4481 @zricethezav
|
||||||
|
|
||||||
|
# Release-critical paths
|
||||||
|
/.github/ @bryanbeverly @dustin-decker @dxa4481 @zricethezav
|
||||||
|
/.goreleaser.yml @bryanbeverly @dustin-decker @dxa4481 @zricethezav
|
||||||
|
/go.mod @bryanbeverly @dustin-decker @dxa4481 @zricethezav
|
||||||
|
/go.sum @bryanbeverly @dustin-decker @dxa4481 @zricethezav
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "gomod"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
open-pull-requests-limit: 5
|
||||||
|
groups:
|
||||||
|
actions:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
name: gitleaks
|
name: gitleaks
|
||||||
on: [push, workflow_dispatch]
|
on:
|
||||||
|
push:
|
||||||
|
workflow_dispatch:
|
||||||
jobs:
|
jobs:
|
||||||
scan:
|
scan:
|
||||||
name: gitleaks
|
name: gitleaks
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: ${{ github.repository == 'gitleaks/gitleaks' }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: gitleaks/gitleaks-action@v2
|
- uses: gitleaks/gitleaks-action@e0c47f4f8be36e29cdc102c57e68cb5cbf0e8d1e # v3
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}
|
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}
|
||||||
@@ -17,23 +17,23 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@8b122486cedac8393e77aa9734c3528886e4a1a8
|
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6
|
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
|
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||||
with:
|
with:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
|
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -41,14 +41,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
zricethezav/gitleaks
|
zricethezav/gitleaks
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8
|
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
context: .
|
context: .
|
||||||
|
|||||||
@@ -10,20 +10,28 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
platform: [ ubuntu-latest, windows-latest ]
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
|
||||||
with:
|
with:
|
||||||
go-version: 1.22
|
go-version: 1.25
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v ./...
|
run: go build ./...
|
||||||
|
|
||||||
|
- name: Set up gotestsum
|
||||||
|
run: |
|
||||||
|
go install gotest.tools/gotestsum@latest
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: make test
|
run: |
|
||||||
|
gotestsum --raw-command -- go test -json ./... --race
|
||||||
|
|
||||||
- name: Validate Config
|
- name: Validate Config
|
||||||
run: go generate ./... && git diff --exit-code
|
run: go generate ./... && git diff --exit-code
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
*.got
|
*.got
|
||||||
gitleaks
|
gitleaks
|
||||||
build
|
build
|
||||||
|
profile
|
||||||
|
|
||||||
# configs
|
# configs
|
||||||
.gitleaks.toml
|
.gitleaks.toml
|
||||||
|
|||||||
+3
-1
@@ -1,4 +1,4 @@
|
|||||||
# This is NOT the default gitleaks config. The default gitleaks config is located
|
# This is NOT the default gitleaks config. The default gitleaks config is located
|
||||||
# here: https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
|
# here: https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
|
||||||
# This gitleaks config extends the default config and ignores secrets located in the `cmd/generate/config/rules`
|
# This gitleaks config extends the default config and ignores secrets located in the `cmd/generate/config/rules`
|
||||||
|
|
||||||
@@ -9,4 +9,6 @@ useDefault = true
|
|||||||
[allowlist]
|
[allowlist]
|
||||||
paths = [
|
paths = [
|
||||||
'''(^|/)cmd/generate/config/rules''',
|
'''(^|/)cmd/generate/config/rules''',
|
||||||
|
'''.*test\.go''',
|
||||||
|
'''testdata'''
|
||||||
]
|
]
|
||||||
@@ -938,3 +938,7 @@ e56870aecf8ac2733affc82e1ac25e3be9092db3:cmd/generate/config/rules/curl.go:gener
|
|||||||
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/prefect.go:prefect-api-token:26
|
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/prefect.go:prefect-api-token:26
|
||||||
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/databricks.go:databricks-api-token:25
|
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/databricks.go:databricks-api-token:25
|
||||||
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/databricks.go:generic-api-key:22
|
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/databricks.go:generic-api-key:22
|
||||||
|
c24a3a654b18d689732ec3199f0a19a254505b04:detect/detect_test.go:generic-api-key:52
|
||||||
|
c08cb1dc9aee87186dba4eebbc13b8aaa2351f0c:detect/detect_test.go:generic-api-key:52
|
||||||
|
ee0da5c7fa5f3c9a7f1617e162497199cac3537f:README.md:generic-api-key:480
|
||||||
|
782f3104786efdce0f809bce8a9ff31f2fa1c9ed:README.md:generic-api-key:481
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
version: '2'
|
||||||
|
linters:
|
||||||
|
default: none
|
||||||
|
# It might be worth going through some of the disabled linters and enabling
|
||||||
|
# them and fixing the items they call out e.g.: cyclop, prealloc,
|
||||||
|
# paralleltest, prealloc, errcheck, dupl, unused, testifylint, gosec,
|
||||||
|
# gocritic, perfsprint, exptostd, intrange, perfsprint (maybe others?)
|
||||||
|
disable:
|
||||||
|
- cyclop
|
||||||
|
- depguard
|
||||||
|
- dupl
|
||||||
|
- err113
|
||||||
|
- errcheck
|
||||||
|
- exhaustive
|
||||||
|
- exhaustruct
|
||||||
|
- exptostd
|
||||||
|
- forbidigo
|
||||||
|
- funcorder
|
||||||
|
- funlen
|
||||||
|
- gochecknoglobals
|
||||||
|
- gochecknoinits
|
||||||
|
- gocognit
|
||||||
|
- goconst
|
||||||
|
- gocritic
|
||||||
|
- gocyclo
|
||||||
|
- godot
|
||||||
|
- godox
|
||||||
|
- gosec
|
||||||
|
- gosmopolitan
|
||||||
|
- intrange
|
||||||
|
- lll
|
||||||
|
- maintidx
|
||||||
|
- mnd
|
||||||
|
- musttag
|
||||||
|
- nestif
|
||||||
|
- nilerr
|
||||||
|
- nlreturn
|
||||||
|
- nonamedreturns
|
||||||
|
- paralleltest
|
||||||
|
- perfsprint
|
||||||
|
- prealloc
|
||||||
|
- predeclared
|
||||||
|
- tagliatelle
|
||||||
|
- testifylint
|
||||||
|
- testpackage
|
||||||
|
- tparallel
|
||||||
|
- unparam
|
||||||
|
- unused
|
||||||
|
- varnamelen
|
||||||
|
- wastedassign
|
||||||
|
- whitespace
|
||||||
|
- wrapcheck
|
||||||
|
- wsl
|
||||||
|
- zerologlint # doesn't seem to catch gitleaks/v8/logging mistakes
|
||||||
|
enable:
|
||||||
|
- inamedparam
|
||||||
|
- misspell
|
||||||
|
- revive
|
||||||
|
- misspell
|
||||||
|
- inamedparam
|
||||||
|
- exhaustruct
|
||||||
|
- inamedparam
|
||||||
|
- misspell
|
||||||
|
- nonamedreturns
|
||||||
|
- staticcheck
|
||||||
|
- unconvert
|
||||||
|
exclusions:
|
||||||
|
rules:
|
||||||
|
- linters:
|
||||||
|
- staticcheck
|
||||||
|
source: 'detector\.Detect\w+\(|sources\.DirectoryTargets\(|detect\.(?:Fragment|RemoteInfo)'
|
||||||
|
- linters:
|
||||||
|
- misspell
|
||||||
|
source: '"(?:addres|busines|clas)",'
|
||||||
|
settings:
|
||||||
|
staticcheck:
|
||||||
|
checks:
|
||||||
|
- all
|
||||||
|
- '-QF1001'
|
||||||
|
- '-ST1000'
|
||||||
|
- '-ST1003'
|
||||||
|
- '-ST1018'
|
||||||
|
- '-ST1020'
|
||||||
|
- '-ST1021'
|
||||||
|
revive:
|
||||||
|
severity: error
|
||||||
+3
-1
@@ -15,8 +15,10 @@ builds:
|
|||||||
goarm:
|
goarm:
|
||||||
- "6"
|
- "6"
|
||||||
- "7"
|
- "7"
|
||||||
|
tags:
|
||||||
|
- gore2regex
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X=github.com/zricethezav/gitleaks/v8/cmd.Version={{.Version}}
|
- -s -w -X=github.com/zricethezav/gitleaks/v8/version.Version={{.Version}}
|
||||||
archives:
|
archives:
|
||||||
- builds: [gitleaks]
|
- builds: [gitleaks]
|
||||||
format_overrides:
|
format_overrides:
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
name: Detect hardcoded secrets
|
name: Detect hardcoded secrets
|
||||||
description: Detect hardcoded secrets using Gitleaks
|
description: Detect hardcoded secrets using Gitleaks
|
||||||
entry: gitleaks protect --verbose --redact --staged
|
entry: gitleaks git --pre-commit --redact --staged --verbose
|
||||||
language: golang
|
language: golang
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
- id: gitleaks-docker
|
- id: gitleaks-docker
|
||||||
name: Detect hardcoded secrets
|
name: Detect hardcoded secrets
|
||||||
description: Detect hardcoded secrets using Gitleaks
|
description: Detect hardcoded secrets using Gitleaks
|
||||||
entry: zricethezav/gitleaks protect --verbose --redact --staged
|
entry: zricethezav/gitleaks git --pre-commit --redact --staged --verbose
|
||||||
language: docker_image
|
language: docker_image
|
||||||
|
pass_filenames: false
|
||||||
- id: gitleaks-system
|
- id: gitleaks-system
|
||||||
name: Detect hardcoded secrets
|
name: Detect hardcoded secrets
|
||||||
description: Detect hardcoded secrets using Gitleaks
|
description: Detect hardcoded secrets using Gitleaks
|
||||||
entry: gitleaks protect --verbose --redact --staged
|
entry: gitleaks git --pre-commit --redact --staged --verbose
|
||||||
language: system
|
language: system
|
||||||
+6
-3
@@ -35,7 +35,7 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
|
|||||||
RuleID: "beamer-api-token",
|
RuleID: "beamer-api-token",
|
||||||
|
|
||||||
// Regex capture group for the actual secret
|
// Regex capture group for the actual secret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Regex used for detecting secrets. See regex section below for more details
|
// Regex used for detecting secrets. See regex section below for more details
|
||||||
@@ -49,7 +49,10 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
|
|||||||
tps := []string{
|
tps := []string{
|
||||||
generateSampleSecret("beamer", "b_"+secrets.NewSecret(alphaNumericExtended("44"))),
|
generateSampleSecret("beamer", "b_"+secrets.NewSecret(alphaNumericExtended("44"))),
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
fps := []string{
|
||||||
|
`R21A-A-V010SP13RC181024R16900-CN-B_250K-Release-OTA-97B6C6C59241976086FABDC41472150C.bfu`,
|
||||||
|
}
|
||||||
|
return validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -92,7 +95,7 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
|
|||||||
the `rules.Beamer(),` in `main()`. Try and keep
|
the `rules.Beamer(),` in `main()`. Try and keep
|
||||||
this alphabetically pretty please.
|
this alphabetically pretty please.
|
||||||
|
|
||||||
1. Run `go generate ./...`
|
1. Run `make config/gitleaks.toml`
|
||||||
|
|
||||||
1. Check out your new rules in `config/gitleaks.toml` and see if everything looks good.
|
1. Check out your new rules in `config/gitleaks.toml` and see if everything looks good.
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
FROM golang:1.22 AS build
|
FROM golang:1.24 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) && \
|
||||||
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/version.Version=${VERSION}"
|
||||||
|
|
||||||
FROM alpine:3.19
|
FROM alpine:3.22
|
||||||
RUN apk add --no-cache bash git openssh-client
|
RUN apk add --no-cache bash git openssh-client
|
||||||
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
.PHONY: test test-cover
|
.PHONY: test test-cover failfast profile clean format build
|
||||||
|
|
||||||
PKG=github.com/zricethezav/gitleaks
|
PKG=github.com/zricethezav/gitleaks
|
||||||
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
||||||
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v8/cmd.Version=$(VERSION)"
|
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v8/version.Version=$(VERSION)"
|
||||||
COVER=--cover --coverprofile=cover.out
|
COVER=--cover --coverprofile=cover.out
|
||||||
|
|
||||||
test-cover:
|
test-cover:
|
||||||
@@ -12,13 +12,26 @@ test-cover:
|
|||||||
format:
|
format:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
|
|
||||||
test: format
|
test: config/gitleaks.toml format
|
||||||
go test -v ./... --race $(PKG)
|
go test -v ./... --race $(PKG)
|
||||||
|
|
||||||
build: format
|
failfast: format
|
||||||
|
go test -failfast ./...
|
||||||
|
|
||||||
|
build: config/gitleaks.toml format
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build $(LDFLAGS)
|
go build $(LDFLAGS)
|
||||||
|
|
||||||
|
lint:
|
||||||
|
golangci-lint run
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
rm -rf profile
|
||||||
find . -type f -name '*.got.*' -delete
|
find . -type f -name '*.got.*' -delete
|
||||||
find . -type f -name '*.out' -delete
|
find . -type f -name '*.out' -delete
|
||||||
|
|
||||||
|
profile: build
|
||||||
|
./scripts/profile.sh './gitleaks' '.'
|
||||||
|
|
||||||
|
config/gitleaks.toml: $(wildcard cmd/generate/config/**/*)
|
||||||
|
go generate ./...
|
||||||
@@ -8,26 +8,31 @@
|
|||||||
└─░───┘
|
└─░───┘
|
||||||
```
|
```
|
||||||
|
|
||||||
<p align="left">
|
> [!WARNING]
|
||||||
<p align="left">
|
> Gitleaks is feature complete. I'm not merging new features into Gitleaks. Future releases will be security patches only. I'm shifting my focus to [Betterleaks](https://github.com/betterleaks/betterleaks)
|
||||||
<a href="https://github.com/gitleaks/gitleaks/actions/workflows/test.yml">
|
|
||||||
<img alt="Github Test" src="https://github.com/gitleaks/gitleaks/actions/workflows/test.yml/badge.svg">
|
|
||||||
</a>
|
|
||||||
<a href="https://hub.docker.com/r/zricethezav/gitleaks">
|
|
||||||
<img src="https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg" />
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/gitleaks/gitleaks-action">
|
|
||||||
<img alt="gitleaks badge" src="https://img.shields.io/badge/protected%20by-gitleaks-blue">
|
|
||||||
</a>
|
|
||||||
<a href="https://twitter.com/intent/follow?screen_name=zricethezav">
|
|
||||||
<img src="https://img.shields.io/twitter/follow/zricethezav?label=Follow%20zricethezav&style=social&color=blue" alt="Follow @zricethezav" />
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
### Join our Discord! [](https://discord.gg/8Hzbrnkr7E)
|
[license]: ./LICENSE
|
||||||
|
[badge-license]: https://img.shields.io/github/license/gitleaks/gitleaks.svg
|
||||||
|
[go-docs-badge]: https://pkg.go.dev/badge/github.com/gitleaks/gitleaks/v8?status
|
||||||
|
[go-docs]: https://pkg.go.dev/github.com/zricethezav/gitleaks/v8
|
||||||
|
[badge-build]: https://github.com/gitleaks/gitleaks/actions/workflows/test.yml/badge.svg
|
||||||
|
[build]: https://github.com/gitleaks/gitleaks/actions/workflows/test.yml
|
||||||
|
[go-report-card-badge]: https://goreportcard.com/badge/github.com/gitleaks/gitleaks/v8
|
||||||
|
[go-report-card]: https://goreportcard.com/report/github.com/gitleaks/gitleaks/v8
|
||||||
|
[dockerhub]: https://hub.docker.com/r/zricethezav/gitleaks
|
||||||
|
[dockerhub-badge]: https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg
|
||||||
|
[gitleaks-action]: https://github.com/gitleaks/gitleaks-action
|
||||||
|
[gitleaks-badge]: https://img.shields.io/badge/protected%20by-gitleaks-blue
|
||||||
|
|
||||||
Gitleaks is a SAST tool for **detecting** and **preventing** hardcoded secrets like passwords, API keys, and tokens in git repos. Gitleaks is an **easy-to-use, all-in-one solution** for detecting secrets, past or present, in your code.
|
|
||||||
|
[![GitHub Action Test][badge-build]][build]
|
||||||
|
[![Docker Hub][dockerhub-badge]][dockerhub]
|
||||||
|
[![Gitleaks Action][gitleaks-badge]][gitleaks-action]
|
||||||
|
[![GoDoc][go-docs-badge]][go-docs]
|
||||||
|
[![GoReportCard][go-report-card-badge]][go-report-card]
|
||||||
|
[![License][badge-license]][license]
|
||||||
|
|
||||||
|
Gitleaks is a tool for **detecting** secrets like passwords, API keys, and tokens in git repos, files, and whatever else you wanna throw at it via `stdin`. If you wanna learn more about how the detection engine works check out this blog: [Regex is (almost) all you need](https://lookingatcomputer.substack.com/p/regex-is-almost-all-you-need).
|
||||||
|
|
||||||
```
|
```
|
||||||
➜ ~/code(master) gitleaks git -v
|
➜ ~/code(master) gitleaks git -v
|
||||||
@@ -52,6 +57,7 @@ Date: 2022-08-03T12:31:40Z
|
|||||||
Fingerprint: cd5226711335c68be1e720b318b7bc3135a30eb2:cmd/generate/config/rules/sidekiq.go:sidekiq-secret:23
|
Fingerprint: cd5226711335c68be1e720b318b7bc3135a30eb2:cmd/generate/config/rules/sidekiq.go:sidekiq-secret:23
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
Gitleaks can be installed using Homebrew, Docker, or Go. Gitleaks is also available in binary form for many popular platforms and OS types on the [releases page](https://github.com/gitleaks/gitleaks/releases). In addition, Gitleaks can be implemented as a pre-commit hook directly in your repo or as a GitHub action using [Gitleaks-Action](https://github.com/gitleaks/gitleaks-action).
|
Gitleaks can be installed using Homebrew, Docker, or Go. Gitleaks is also available in binary form for many popular platforms and OS types on the [releases page](https://github.com/gitleaks/gitleaks/releases). In addition, Gitleaks can be implemented as a pre-commit hook directly in your repo or as a GitHub action using [Gitleaks-Action](https://github.com/gitleaks/gitleaks-action).
|
||||||
@@ -76,27 +82,6 @@ cd gitleaks
|
|||||||
make build
|
make build
|
||||||
```
|
```
|
||||||
|
|
||||||
### GitHub Action
|
|
||||||
|
|
||||||
Check out the official [Gitleaks GitHub Action](https://github.com/gitleaks/gitleaks-action)
|
|
||||||
|
|
||||||
```
|
|
||||||
name: gitleaks
|
|
||||||
on: [pull_request, push, workflow_dispatch]
|
|
||||||
jobs:
|
|
||||||
scan:
|
|
||||||
name: gitleaks
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- uses: gitleaks/gitleaks-action@v2
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} # Only required for Organizations, not personal accounts.
|
|
||||||
```
|
|
||||||
|
|
||||||
### Pre-Commit
|
### Pre-Commit
|
||||||
|
|
||||||
1. Install pre-commit from https://pre-commit.com/#install
|
1. Install pre-commit from https://pre-commit.com/#install
|
||||||
@@ -105,12 +90,12 @@ jobs:
|
|||||||
```
|
```
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/gitleaks/gitleaks
|
- repo: https://github.com/gitleaks/gitleaks
|
||||||
rev: v8.19.0
|
rev: v8.24.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
```
|
```
|
||||||
|
|
||||||
for a [native execution of GitLeaks](https://github.com/gitleaks/gitleaks/releases) or use the [`gitleaks-docker` pre-commit ID](https://github.com/gitleaks/gitleaks/blob/master/.pre-commit-hooks.yaml) for executing GitLeaks using the [official Docker images](#docker)
|
for a [native execution of gitleaks](https://github.com/gitleaks/gitleaks/releases) or use the [`gitleaks-docker` pre-commit ID](https://github.com/gitleaks/gitleaks/blob/master/.pre-commit-hooks.yaml) for executing gitleaks using the [official Docker images](#docker)
|
||||||
|
|
||||||
3. Auto-update the config to the latest repos' versions by executing `pre-commit autoupdate`
|
3. Auto-update the config to the latest repos' versions by executing `pre-commit autoupdate`
|
||||||
4. Install with `pre-commit install`
|
4. Install with `pre-commit install`
|
||||||
@@ -132,11 +117,13 @@ Detect hardcoded secrets................................................Skipped
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Gitleaks scans code, past or present, for secrets
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
gitleaks [command]
|
gitleaks [command]
|
||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
completion generate the autocompletion script for the specified shell
|
completion Generate the autocompletion script for the specified shell
|
||||||
dir scan directories or files for secrets
|
dir scan directories or files for secrets
|
||||||
git scan git repositories for secrets
|
git scan git repositories for secrets
|
||||||
help Help about any command
|
help Help about any command
|
||||||
@@ -149,21 +136,27 @@ Flags:
|
|||||||
order of precedence:
|
order of precedence:
|
||||||
1. --config/-c
|
1. --config/-c
|
||||||
2. env var GITLEAKS_CONFIG
|
2. env var GITLEAKS_CONFIG
|
||||||
3. (target path)/.gitleaks.toml
|
3. env var GITLEAKS_CONFIG_TOML with the file content
|
||||||
If none of the three options are used, then gitleaks will use the default config
|
4. (target path)/.gitleaks.toml
|
||||||
|
If none of the four options are used, then gitleaks will use the default config
|
||||||
|
--diagnostics string enable diagnostics (http OR comma-separated list: cpu,mem,trace). cpu=CPU prof, mem=memory prof, trace=exec tracing, http=serve via net/http/pprof
|
||||||
|
--diagnostics-dir string directory to store diagnostics output files when not using http mode (defaults to current directory)
|
||||||
--enable-rule strings only enable specific rules by id
|
--enable-rule strings only enable specific rules by id
|
||||||
--exit-code int exit code when leaks have been encountered (default 1)
|
--exit-code int exit code when leaks have been encountered (default 1)
|
||||||
-i, --gitleaks-ignore-path string path to .gitleaksignore file or folder containing one (default ".")
|
-i, --gitleaks-ignore-path string path to .gitleaksignore file or folder containing one (default ".")
|
||||||
-h, --help help for gitleaks
|
-h, --help help for gitleaks
|
||||||
--ignore-gitleaks-allow ignore gitleaks:allow comments
|
--ignore-gitleaks-allow ignore gitleaks:allow comments
|
||||||
-l, --log-level string log level (trace, debug, info, warn, error, fatal) (default "info")
|
-l, --log-level string log level (trace, debug, info, warn, error, fatal) (default "info")
|
||||||
|
--max-archive-depth int allow scanning into nested archives up to this depth (default "0", no archive traversal is done)
|
||||||
--max-decode-depth int allow recursive decoding up to this depth (default "0", no decoding is done)
|
--max-decode-depth int allow recursive decoding up to this depth (default "0", no decoding is done)
|
||||||
--max-target-megabytes int files larger than this will be skipped
|
--max-target-megabytes int files larger than this will be skipped
|
||||||
--no-banner suppress banner
|
--no-banner suppress banner
|
||||||
--no-color turn off color for verbose output
|
--no-color turn off color for verbose output
|
||||||
--redact uint[=100] redact secrets from logs and stdout. To redact only parts of the secret just apply a percent value from 0..100. For example --redact=20 (default 100%)
|
--redact uint[=100] redact secrets from logs and stdout. To redact only parts of the secret just apply a percent value from 0..100. For example --redact=20 (default 100%)
|
||||||
-f, --report-format string output format (json, csv, junit, sarif) (default "json")
|
-f, --report-format string output format (json, csv, junit, sarif, template)
|
||||||
-r, --report-path string report file
|
-r, --report-path string report file
|
||||||
|
--report-template string template file used to generate the report (implies --report-format=template)
|
||||||
|
--timeout int set a timeout for gitleaks commands in seconds (default "0", no timeout is set)
|
||||||
-v, --verbose show verbose output from scan
|
-v, --verbose show verbose output from scan
|
||||||
--version version for gitleaks
|
--version version for gitleaks
|
||||||
|
|
||||||
@@ -179,6 +172,7 @@ If you find v8.19.0 broke an existing command (`detect`/`protect`), please open
|
|||||||
There are three scanning modes: `git`, `dir`, and `stdin`.
|
There are three scanning modes: `git`, `dir`, and `stdin`.
|
||||||
|
|
||||||
#### Git
|
#### Git
|
||||||
|
|
||||||
The `git` command lets you scan local git repos. Under the hood, gitleaks uses the `git log -p` command to scan patches.
|
The `git` command lets you scan local git repos. Under the hood, gitleaks uses the `git log -p` command to scan patches.
|
||||||
You can configure the behavior of `git log -p` with the `log-opts` option.
|
You can configure the behavior of `git log -p` with the `log-opts` option.
|
||||||
For example, if you wanted to run gitleaks on a range of commits you could use the following
|
For example, if you wanted to run gitleaks on a range of commits you could use the following
|
||||||
@@ -186,10 +180,12 @@ command: `gitleaks git -v --log-opts="--all commitA..commitB" path_to_repo`. See
|
|||||||
If there is no target specified as a positional argument, then gitleaks will attempt to scan the current working directory as a git repo.
|
If there is no target specified as a positional argument, then gitleaks will attempt to scan the current working directory as a git repo.
|
||||||
|
|
||||||
#### Dir
|
#### Dir
|
||||||
|
|
||||||
The `dir` (aliases include `files`, `directory`) command lets you scan directories and files. Example: `gitleaks dir -v path_to_directory_or_file`.
|
The `dir` (aliases include `files`, `directory`) command lets you scan directories and files. Example: `gitleaks dir -v path_to_directory_or_file`.
|
||||||
If there is no target specified as a positional argument, then gitleaks will scan the current working directory.
|
If there is no target specified as a positional argument, then gitleaks will scan the current working directory.
|
||||||
|
|
||||||
#### Stdin
|
#### Stdin
|
||||||
|
|
||||||
You can also stream data to gitleaks with the `stdin` command. Example: `cat some_file | gitleaks -v stdin`
|
You can also stream data to gitleaks with the `stdin` command. Example: `cat some_file | gitleaks -v stdin`
|
||||||
|
|
||||||
### Creating a baseline
|
### Creating a baseline
|
||||||
@@ -214,38 +210,76 @@ After running the detect command with the --baseline-path parameter, report outp
|
|||||||
You can run Gitleaks as a pre-commit hook by copying the example `pre-commit.py` script into
|
You can run Gitleaks as a pre-commit hook by copying the example `pre-commit.py` script into
|
||||||
your `.git/hooks/` directory.
|
your `.git/hooks/` directory.
|
||||||
|
|
||||||
|
## Load Configuration
|
||||||
|
|
||||||
|
The order of precedence is:
|
||||||
|
|
||||||
|
1. `--config/-c` option:
|
||||||
|
```bash
|
||||||
|
gitleaks git --config /home/dev/customgitleaks.toml .
|
||||||
|
```
|
||||||
|
2. Environment variable `GITLEAKS_CONFIG` with the file path:
|
||||||
|
```bash
|
||||||
|
export GITLEAKS_CONFIG="/home/dev/customgitleaks.toml"
|
||||||
|
gitleaks git .
|
||||||
|
```
|
||||||
|
3. Environment variable `GITLEAKS_CONFIG_TOML` with the file content:
|
||||||
|
```bash
|
||||||
|
export GITLEAKS_CONFIG_TOML=`cat customgitleaks.toml`
|
||||||
|
gitleaks git .
|
||||||
|
```
|
||||||
|
4. A `.gitleaks.toml` file within the target path:
|
||||||
|
```bash
|
||||||
|
gitleaks git .
|
||||||
|
```
|
||||||
|
|
||||||
|
If none of the four options are used, then gitleaks will use the default config.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Gitleaks offers a configuration format you can follow to write your own secret detection rules:
|
Gitleaks offers a configuration format you can follow to write your own secret detection rules:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Title for the gitleaks configuration file.
|
# Title for the gitleaks configuration file.
|
||||||
title = "Gitleaks title"
|
title = "Custom Gitleaks configuration"
|
||||||
|
|
||||||
|
# You have basically two options for your custom configuration:
|
||||||
|
#
|
||||||
|
# 1. define your own configuration, default rules do not apply
|
||||||
|
#
|
||||||
|
# use e.g., the default configuration as starting point:
|
||||||
|
# https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
|
||||||
|
#
|
||||||
|
# 2. extend a configuration, the rules are overwritten or extended
|
||||||
|
#
|
||||||
|
# When you extend a configuration the extended rules take precedence over the
|
||||||
|
# default rules. I.e., if there are duplicate rules in both the extended
|
||||||
|
# configuration and the default configuration the extended rules or
|
||||||
|
# attributes of them will override the default rules.
|
||||||
|
# Another thing to know with extending configurations is you can chain
|
||||||
|
# together multiple configuration files to a depth of 2. Allowlist arrays are
|
||||||
|
# appended and can contain duplicates.
|
||||||
|
|
||||||
# Extend the base (this) configuration. When you extend a configuration
|
|
||||||
# the base rules take precedence over the extended rules. I.e., if there are
|
|
||||||
# duplicate rules in both the base configuration and the extended configuration
|
|
||||||
# the base rules will override the extended rules.
|
|
||||||
# Another thing to know with extending configurations is you can chain together
|
|
||||||
# multiple configuration files to a depth of 2. Allowlist arrays are appended
|
|
||||||
# and can contain duplicates.
|
|
||||||
# useDefault and path can NOT be used at the same time. Choose one.
|
# useDefault and path can NOT be used at the same time. Choose one.
|
||||||
[extend]
|
[extend]
|
||||||
# useDefault will extend the base configuration with the default gitleaks config:
|
# useDefault will extend the default gitleaks config built in to the binary
|
||||||
|
# the latest version is located at:
|
||||||
# https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
|
# https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
|
||||||
useDefault = true
|
useDefault = true
|
||||||
# or you can supply a path to a configuration. Path is relative to where gitleaks
|
# or you can provide a path to a configuration to extend from.
|
||||||
# was invoked, not the location of the base config.
|
# The path is relative to where gitleaks was invoked,
|
||||||
path = "common_config.toml"
|
# not the location of the base config.
|
||||||
|
# path = "common_config.toml"
|
||||||
|
# If there are any rules you don't want to inherit, they can be specified here.
|
||||||
|
disabledRules = [ "generic-api-key"]
|
||||||
|
|
||||||
# An array of tables that contain information that define instructions
|
# An array of tables that contain information that define instructions
|
||||||
# on how to detect secrets
|
# on how to detect secrets
|
||||||
[[rules]]
|
[[rules]]
|
||||||
|
|
||||||
# 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 = "awesome 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
|
||||||
@@ -278,7 +312,7 @@ keywords = [
|
|||||||
tags = ["tag","another tag"]
|
tags = ["tag","another tag"]
|
||||||
|
|
||||||
# ⚠️ In v8.21.0 `[rules.allowlist]` was replaced with `[[rules.allowlists]]`.
|
# ⚠️ In v8.21.0 `[rules.allowlist]` was replaced with `[[rules.allowlists]]`.
|
||||||
# This change was backwards-compatible: instances of `[rules.allowlist]` still work.
|
# This change was backwards-compatible: instances of `[rules.allowlist]` still work.
|
||||||
#
|
#
|
||||||
# You can define multiple allowlists for a rule to reduce false positives.
|
# You can define multiple allowlists for a rule to reduce false positives.
|
||||||
# A finding will be ignored if _ANY_ `[[rules.allowlists]]` matches.
|
# A finding will be ignored if _ANY_ `[[rules.allowlists]]` matches.
|
||||||
@@ -319,19 +353,20 @@ id = "gitlab-pat"
|
|||||||
regexTarget = "line"
|
regexTarget = "line"
|
||||||
regexes = [ '''MY-glpat-''' ]
|
regexes = [ '''MY-glpat-''' ]
|
||||||
|
|
||||||
# This is a global allowlist which has a higher order of precedence than rule-specific allowlists.
|
|
||||||
|
# ⚠️ In v8.25.0 `[allowlist]` was replaced with `[[allowlists]]`.
|
||||||
|
#
|
||||||
|
# Global allowlists have 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]
|
[[allowlists]]
|
||||||
description = "global allow list"
|
description = "global allow list"
|
||||||
commits = [ "commit-A", "commit-B", "commit-C"]
|
commits = [ "commit-A", "commit-B", "commit-C"]
|
||||||
paths = [
|
paths = [
|
||||||
'''gitleaks\.toml''',
|
'''gitleaks\.toml''',
|
||||||
'''(.*?)(jpg|gif|doc)'''
|
'''(.*?)(jpg|gif|doc)'''
|
||||||
]
|
]
|
||||||
|
|
||||||
# note: (global) regexTarget defaults to check the _Secret_ in the finding.
|
# note: (global) regexTarget defaults to check the _Secret_ in the finding.
|
||||||
# if regexTarget is not specified then _Secret_ will be used.
|
|
||||||
# Acceptable values for regexTarget are "match" and "line"
|
# Acceptable values for regexTarget are "match" and "line"
|
||||||
regexTarget = "match"
|
regexTarget = "match"
|
||||||
regexes = [
|
regexes = [
|
||||||
@@ -345,12 +380,109 @@ stopwords = [
|
|||||||
'''client''',
|
'''client''',
|
||||||
'''endpoint''',
|
'''endpoint''',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# ⚠️ In v8.25.0, `[[allowlists]]` have a new field called |targetRules|.
|
||||||
|
#
|
||||||
|
# Common allowlists can be defined once and assigned to multiple rules using |targetRules|.
|
||||||
|
# This will only run on the specified rules, not globally.
|
||||||
|
[[allowlists]]
|
||||||
|
targetRules = ["awesome-rule-1", "awesome-rule-2"]
|
||||||
|
description = "Our test assets trigger false-positives in a couple rules."
|
||||||
|
paths = ['''tests/expected/._\.json$''']
|
||||||
```
|
```
|
||||||
|
|
||||||
Refer to the default [gitleaks config](https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/gitleaks/gitleaks/blob/master/CONTRIBUTING.md) if you would like to contribute to the default configuration. Additionally, you can check out [this gitleaks blog post](https://blog.gitleaks.io/stop-leaking-secrets-configuration-2-3-aeed293b1fbf) which covers advanced configuration setups.
|
Refer to the default [gitleaks config](https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/gitleaks/gitleaks/blob/master/CONTRIBUTING.md) if you would like to contribute to the default configuration. Additionally, you can check out [this gitleaks blog post](https://blog.gitleaks.io/stop-leaking-secrets-configuration-2-3-aeed293b1fbf) which covers advanced configuration setups.
|
||||||
|
|
||||||
### Additional Configuration
|
### Additional Configuration
|
||||||
|
|
||||||
|
#### Composite Rules (Multi-part or `required` Rules)
|
||||||
|
In v8.28.0 Gitleaks introduced composite rules, which are made up of a single "primary" rule and one or more auxiliary or `required` rules. To create a composite rule, add a `[[rules.required]]` table to the primary rule specifying an `id` and optionally `withinLines` and/or `withinColumns` proximity constraints. A fragment is a chunk of content that Gitleaks processes at once (typically a file, part of a file, or git diff), and proximity matching instructs the primary rule to only report a finding if the auxiliary `required` rules also find matches within the specified area of the fragment.
|
||||||
|
|
||||||
|
**Proximity matching:** Using the `withinLines` and `withinColumns` fields instructs the primary rule to only report a finding if the auxiliary `required` rules also find matches within the specified proximity. You can set:
|
||||||
|
|
||||||
|
- **`withinLines: N`** - required findings must be within N lines (vertically)
|
||||||
|
- **`withinColumns: N`** - required findings must be within N characters (horizontally)
|
||||||
|
- **Both** - creates a rectangular search area (both constraints must be satisfied)
|
||||||
|
- **Neither** - fragment-level matching (required findings can be anywhere in the same fragment)
|
||||||
|
|
||||||
|
Here are diagrams illustrating each proximity behavior:
|
||||||
|
|
||||||
|
```
|
||||||
|
p = primary captured secret
|
||||||
|
a = auxiliary (required) captured secret
|
||||||
|
fragment = section of data gitleaks is looking at
|
||||||
|
|
||||||
|
|
||||||
|
*Fragment-level proximity*
|
||||||
|
Any required finding in the fragment
|
||||||
|
┌────────┐
|
||||||
|
┌──────┤fragment├─────┐
|
||||||
|
│ └──────┬─┤ │ ┌───────┐
|
||||||
|
│ │a│◀────┼─│✓ MATCH│
|
||||||
|
│ ┌─┐└─┘ │ └───────┘
|
||||||
|
│┌─┐ │p│ │
|
||||||
|
││a│ ┌─┐└─┘ │ ┌───────┐
|
||||||
|
│└─┘ │a│◀──────────┼─│✓ MATCH│
|
||||||
|
└─▲─────┴─┴───────────┘ └───────┘
|
||||||
|
│ ┌───────┐
|
||||||
|
└────│✓ MATCH│
|
||||||
|
└───────┘
|
||||||
|
|
||||||
|
|
||||||
|
*Column bounded proximity*
|
||||||
|
`withinColumns = 3`
|
||||||
|
┌────────┐
|
||||||
|
┌────┬─┤fragment├─┬───┐
|
||||||
|
│ └──────┬─┤ │ ┌───────────┐
|
||||||
|
│ │ │a│◀┼───┼─│+1C ✓ MATCH│
|
||||||
|
│ ┌─┐└─┘ │ └───────────┘
|
||||||
|
│┌─┐ │ │p│ │ │
|
||||||
|
┌──▶│a│ ┌─┐ └─┘ │ ┌───────────┐
|
||||||
|
│ │└─┘ ││a│◀────────┼───┼─│-2C ✓ MATCH│
|
||||||
|
│ │ ┘ │ └───────────┘
|
||||||
|
│ └── -3C ───0C─── +3C ─┘
|
||||||
|
│ ┌─────────┐
|
||||||
|
│ │ -4C ✗ NO│
|
||||||
|
└──│ MATCH │
|
||||||
|
└─────────┘
|
||||||
|
|
||||||
|
|
||||||
|
*Line bounded proximity*
|
||||||
|
`withinLines = 4`
|
||||||
|
┌────────┐
|
||||||
|
┌─────┤fragment├─────┐
|
||||||
|
+4L─ ─ ┴────────┘─ ─ ─│
|
||||||
|
│ │
|
||||||
|
│ ┌─┐ │ ┌────────────┐
|
||||||
|
│ ┌─┐ │a│◀──┼─│+1L ✓ MATCH │
|
||||||
|
0L ┌─┐ │p│ └─┘ │ ├────────────┤
|
||||||
|
│ │a│◀──┴─┴────────┼─│-1L ✓ MATCH │
|
||||||
|
│ └─┘ │ └────────────┘
|
||||||
|
│ │ ┌─────────┐
|
||||||
|
-4L─ ─ ─ ─ ─ ─ ─ ─┌─┐─│ │-5L ✗ NO │
|
||||||
|
│ │a│◀┼─│ MATCH │
|
||||||
|
└────────────────┴─┴─┘ └─────────┘
|
||||||
|
|
||||||
|
|
||||||
|
*Line and column bounded proximity*
|
||||||
|
`withinLines = 4`
|
||||||
|
`withinColumns = 3`
|
||||||
|
┌────────┐
|
||||||
|
┌─────┤fragment├─────┐
|
||||||
|
+4L ┌└────────┴ ┐ │
|
||||||
|
│ ┌─┐ │ ┌───────────────┐
|
||||||
|
│ │ │a│◀┼───┼─│+2L/+1C ✓ MATCH│
|
||||||
|
│ ┌─┐└─┘ │ └───────────────┘
|
||||||
|
0L │ │p│ │ │
|
||||||
|
│ └─┘ │
|
||||||
|
│ │ │ │ ┌────────────┐
|
||||||
|
-4L ─ ─ ─ ─ ─ ─┌─┐ │ │-5L/+3C ✗ NO│
|
||||||
|
│ │a│◀┼─│ MATCH │
|
||||||
|
└───-3C────0L───+3C┴─┘ └────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
<details><summary>Some final quick thoughts on composite rules.</summary>This is an experimental feature! It's subject to change so don't go sellin' a new B2B SaaS feature built ontop of this feature. Scan type (git vs dir) based context is interesting. I'm monitoring the situation. Composite rules might not be super useful for git scans because gitleaks only looks at additions in the git history. It could be useful to scan non-additions in git history for `required` rules. Oh, right this is a readme, I'll shut up now.</details>
|
||||||
|
|
||||||
#### gitleaks:allow
|
#### gitleaks:allow
|
||||||
|
|
||||||
If you are knowingly committing a test secret that gitleaks will catch you can add a `gitleaks:allow` comment to that line which will instruct gitleaks
|
If you are knowingly committing a test secret that gitleaks will catch you can add a `gitleaks:allow` comment to that line which will instruct gitleaks
|
||||||
@@ -391,7 +523,89 @@ ways:
|
|||||||
|
|
||||||
Currently supported encodings:
|
Currently supported encodings:
|
||||||
|
|
||||||
- `base64` (both standard and base64url)
|
- **percent** - Any printable ASCII percent encoded values
|
||||||
|
- **hex** - Any printable ASCII hex encoded values >= 32 characters
|
||||||
|
- **base64** - Any printable ASCII base64 encoded values >= 16 characters
|
||||||
|
|
||||||
|
#### Archive Scanning
|
||||||
|
|
||||||
|
Sometimes secrets are packaged within archive files like zip files or tarballs,
|
||||||
|
making them difficult to discover. Now you can tell gitleaks to automatically
|
||||||
|
extract and scan the contents of archives. The flag `--max-archive-depth`
|
||||||
|
enables this feature for both `dir` and `git` scan types. The default value of
|
||||||
|
"0" means this feature is disabled by default.
|
||||||
|
|
||||||
|
Recursive scanning is supported since archives can also contain other archives.
|
||||||
|
The `--max-archive-depth` flag sets the recursion limit. Recursion stops when
|
||||||
|
there are no new archives to extract, so setting a very high max depth just
|
||||||
|
sets the potential to go that deep. It will only go as deep as it needs to.
|
||||||
|
|
||||||
|
The findings for secrets located within an archive will include the path to the
|
||||||
|
file inside the archive. Inner paths are separated with `!`.
|
||||||
|
|
||||||
|
Example finding (shortened for brevity):
|
||||||
|
|
||||||
|
```
|
||||||
|
Finding: DB_PASSWORD=8ae31cacf141669ddfb5da
|
||||||
|
...
|
||||||
|
File: testdata/archives/nested.tar.gz!archives/files.tar!files/.env.prod
|
||||||
|
Line: 4
|
||||||
|
Commit: 6e6ee6596d337bb656496425fb98644eb62b4a82
|
||||||
|
...
|
||||||
|
Fingerprint: 6e6ee6596d337bb656496425fb98644eb62b4a82:testdata/archives/nested.tar.gz!archives/files.tar!files/.env.prod:generic-api-key:4
|
||||||
|
Link: https://github.com/leaktk/gitleaks/blob/6e6ee6596d337bb656496425fb98644eb62b4a82/testdata/archives/nested.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
This means a secret was detected on line 4 of `files/.env.prod.` which is in
|
||||||
|
`archives/files.tar` which is in `testdata/archives/nested.tar.gz`.
|
||||||
|
|
||||||
|
Currently supported formats:
|
||||||
|
|
||||||
|
The [compression](https://github.com/mholt/archives?tab=readme-ov-file#supported-compression-formats)
|
||||||
|
and [archive](https://github.com/mholt/archives?tab=readme-ov-file#supported-archive-formats)
|
||||||
|
formats supported by mholt's [archives package](https://github.com/mholt/archives)
|
||||||
|
are supported.
|
||||||
|
|
||||||
|
#### Reporting
|
||||||
|
|
||||||
|
Gitleaks has built-in support for several report formats: [`json`](https://github.com/gitleaks/gitleaks/blob/master/testdata/expected/report/json_simple.json), [`csv`](https://github.com/gitleaks/gitleaks/blob/master/testdata/expected/report/csv_simple.csv?plain=1), [`junit`](https://github.com/gitleaks/gitleaks/blob/master/testdata/expected/report/junit_simple.xml), and [`sarif`](https://github.com/gitleaks/gitleaks/blob/master/testdata/expected/report/sarif_simple.sarif).
|
||||||
|
|
||||||
|
If none of these formats fit your need, you can create your own report format with a [Go `text/template` .tmpl file](https://www.digitalocean.com/community/tutorials/how-to-use-templates-in-go#step-4-writing-a-template) and the `--report-template` flag. The template can use [extended functionality from the `Masterminds/sprig` template library](https://masterminds.github.io/sprig/).
|
||||||
|
|
||||||
|
For example, the following template provides a custom JSON output:
|
||||||
|
```gotemplate
|
||||||
|
# jsonextra.tmpl
|
||||||
|
[{{ $lastFinding := (sub (len . ) 1) }}
|
||||||
|
{{- range $i, $finding := . }}{{with $finding}}
|
||||||
|
{
|
||||||
|
"Description": {{ quote .Description }},
|
||||||
|
"StartLine": {{ .StartLine }},
|
||||||
|
"EndLine": {{ .EndLine }},
|
||||||
|
"StartColumn": {{ .StartColumn }},
|
||||||
|
"EndColumn": {{ .EndColumn }},
|
||||||
|
"Line": {{ quote .Line }},
|
||||||
|
"Match": {{ quote .Match }},
|
||||||
|
"Secret": {{ quote .Secret }},
|
||||||
|
"File": "{{ .File }}",
|
||||||
|
"SymlinkFile": {{ quote .SymlinkFile }},
|
||||||
|
"Commit": {{ quote .Commit }},
|
||||||
|
"Entropy": {{ .Entropy }},
|
||||||
|
"Author": {{ quote .Author }},
|
||||||
|
"Email": {{ quote .Email }},
|
||||||
|
"Date": {{ quote .Date }},
|
||||||
|
"Message": {{ quote .Message }},
|
||||||
|
"Tags": [{{ $lastTag := (sub (len .Tags ) 1) }}{{ range $j, $tag := .Tags }}{{ quote . }}{{ if ne $j $lastTag }},{{ end }}{{ end }}],
|
||||||
|
"RuleID": {{ quote .RuleID }},
|
||||||
|
"Fingerprint": {{ quote .Fingerprint }}
|
||||||
|
}{{ if ne $i $lastFinding }},{{ end }}
|
||||||
|
{{- end}}{{ end }}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
```sh
|
||||||
|
$ gitleaks dir ~/leaky-repo/ --report-path "report.json" --report-format template --report-template testdata/report/jsonextra.tmpl
|
||||||
|
```
|
||||||
|
|
||||||
## Sponsorships
|
## Sponsorships
|
||||||
|
|
||||||
@@ -401,11 +615,6 @@ Currently supported encodings:
|
|||||||
<img alt="CodeRabbit.ai Sponsorship" src="https://github.com/gitleaks/gitleaks/assets/15034943/76c30a85-887b-47ca-9956-17a8e55c6c41" width=200>
|
<img alt="CodeRabbit.ai Sponsorship" src="https://github.com/gitleaks/gitleaks/assets/15034943/76c30a85-887b-47ca-9956-17a8e55c6c41" width=200>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p align="left">
|
|
||||||
<a href="https://www.tines.com/?utm_source=oss&utm_medium=sponsorship&utm_campaign=gitleaks">
|
|
||||||
<img alt="Tines Sponsorship" src="https://user-images.githubusercontent.com/15034943/146411864-4878f936-b4f7-49a0-b625-f9f40c704bfa.png" width=200>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
||||||
## Exit Codes
|
## Exit Codes
|
||||||
@@ -417,3 +626,5 @@ You can always set the exit code when leaks are encountered with the --exit-code
|
|||||||
1 - leaks or error encountered
|
1 - leaks or error encountered
|
||||||
126 - unknown flag
|
126 - unknown flag
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Join the Discord! [](https://discord.gg/8Hzbrnkr7E)
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
|---------|-----------|
|
||||||
|
| Latest | Yes |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
If you discover a security vulnerability in gitleaks, please report it responsibly:
|
||||||
|
|
||||||
|
1. **Do not open a public issue.**
|
||||||
|
2. Use [GitHub's private vulnerability reporting](https://github.com/gitleaks/gitleaks/security/advisories/new) to submit your report directly.
|
||||||
|
3. Include a description of the vulnerability, steps to reproduce, and any relevant logs or screenshots.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This policy covers `gitleaks` (this repository). For vulnerabilities in `gitleaks-action`, please report them at [gitleaks/gitleaks-action](https://github.com/gitleaks/gitleaks-action/security/advisories/new).
|
||||||
+60
-53
@@ -22,9 +22,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/scm"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/logging"
|
||||||
"github.com/zricethezav/gitleaks/v8/report"
|
"github.com/zricethezav/gitleaks/v8/report"
|
||||||
"github.com/zricethezav/gitleaks/v8/sources"
|
"github.com/zricethezav/gitleaks/v8/sources"
|
||||||
)
|
)
|
||||||
@@ -36,6 +37,7 @@ func init() {
|
|||||||
detectCmd.Flags().Bool("follow-symlinks", false, "scan files that are symlinks to other files")
|
detectCmd.Flags().Bool("follow-symlinks", false, "scan files that are symlinks to other files")
|
||||||
detectCmd.Flags().StringP("source", "s", ".", "path to source")
|
detectCmd.Flags().StringP("source", "s", ".", "path to source")
|
||||||
detectCmd.Flags().String("log-opts", "", "git log options")
|
detectCmd.Flags().String("log-opts", "", "git log options")
|
||||||
|
detectCmd.Flags().String("platform", "", "the target platform used to generate links (github, gitlab)")
|
||||||
}
|
}
|
||||||
|
|
||||||
var detectCmd = &cobra.Command{
|
var detectCmd = &cobra.Command{
|
||||||
@@ -46,84 +48,89 @@ var detectCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runDetect(cmd *cobra.Command, args []string) {
|
func runDetect(cmd *cobra.Command, args []string) {
|
||||||
source, err := cmd.Flags().GetString("source")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("could not get source")
|
|
||||||
}
|
|
||||||
initConfig(source)
|
|
||||||
|
|
||||||
var findings []report.Finding
|
|
||||||
|
|
||||||
// setup config (aka, the thing that defines rules)
|
|
||||||
cfg := Config(cmd)
|
|
||||||
|
|
||||||
// start timer
|
// start timer
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
sourcePath := mustGetStringFlag(cmd, "source")
|
||||||
|
|
||||||
detector := Detector(cmd, cfg, source)
|
// setup config (aka, the thing that defines rules)
|
||||||
|
initConfig(sourcePath)
|
||||||
|
initDiagnostics()
|
||||||
|
cfg := Config(cmd)
|
||||||
|
|
||||||
// set exit code
|
// create detector
|
||||||
exitCode, err := cmd.Flags().GetInt("exit-code")
|
detector := Detector(cmd, cfg, sourcePath)
|
||||||
if err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("could not get exit code")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// parse flags
|
||||||
|
detector.FollowSymlinks = mustGetBoolFlag(cmd, "follow-symlinks")
|
||||||
|
exitCode := mustGetIntFlag(cmd, "exit-code")
|
||||||
|
noGit := mustGetBoolFlag(cmd, "no-git")
|
||||||
|
fromPipe := mustGetBoolFlag(cmd, "pipe")
|
||||||
// determine what type of scan:
|
// determine what type of scan:
|
||||||
// - git: scan the history of the repo
|
// - git: scan the history of the repo
|
||||||
// - no-git: scan files by treating the repo as a plain directory
|
// - no-git: scan files by treating the repo as a plain directory
|
||||||
noGit, err := cmd.Flags().GetBool("no-git")
|
var (
|
||||||
if err != nil {
|
err error
|
||||||
log.Fatal().Err(err).Msg("could not call GetBool() for no-git")
|
findings []report.Finding
|
||||||
}
|
)
|
||||||
fromPipe, err := cmd.Flags().GetBool("pipe")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("could not call GetBool() for pipe")
|
|
||||||
}
|
|
||||||
|
|
||||||
// start the detector scan
|
|
||||||
if noGit {
|
if noGit {
|
||||||
var paths <-chan sources.ScanTarget
|
findings, err = detector.DetectSource(
|
||||||
paths, err = sources.DirectoryTargets(source, detector.Sema, detector.FollowSymlinks)
|
cmd.Context(), &sources.Files{
|
||||||
if err != nil {
|
Config: &cfg,
|
||||||
log.Fatal().Err(err)
|
FollowSymlinks: detector.FollowSymlinks,
|
||||||
}
|
MaxFileSize: detector.MaxTargetMegaBytes * 1_000_000,
|
||||||
|
Path: sourcePath,
|
||||||
|
Sema: detector.Sema,
|
||||||
|
MaxArchiveDepth: detector.MaxArchiveDepth,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
findings, err = detector.DetectFiles(paths)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// don't exit on error, just log it
|
// don't exit on error, just log it
|
||||||
log.Error().Err(err).Msg("failed scan directory")
|
logging.Error().Err(err).Msg("failed to scan directory")
|
||||||
}
|
}
|
||||||
} else if fromPipe {
|
} else if fromPipe {
|
||||||
findings, err = detector.DetectReader(os.Stdin, 10)
|
findings, err = detector.DetectSource(
|
||||||
|
cmd.Context(), &sources.File{
|
||||||
|
Content: os.Stdin,
|
||||||
|
MaxArchiveDepth: detector.MaxArchiveDepth,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// log fatal to exit, no need to continue since a report
|
// log fatal to exit, no need to continue since a report
|
||||||
// will not be generated when scanning from a pipe...for now
|
// will not be generated when scanning from a pipe...for now
|
||||||
log.Fatal().Err(err).Msg("failed scan input from stdin")
|
logging.Fatal().Err(err).Msg("failed scan input from stdin")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var (
|
var (
|
||||||
gitCmd *sources.GitCmd
|
gitCmd *sources.GitCmd
|
||||||
logOpts string
|
scmPlatform scm.Platform
|
||||||
)
|
)
|
||||||
logOpts, err = cmd.Flags().GetString("log-opts")
|
|
||||||
if err != nil {
|
logOpts := mustGetStringFlag(cmd, "log-opts")
|
||||||
log.Fatal().Err(err).Msg("could not call GetString() for log-opts")
|
if gitCmd, err = sources.NewGitLogCmdContext(cmd.Context(), sourcePath, logOpts); err != nil {
|
||||||
|
logging.Fatal().Err(err).Msg("could not create Git cmd")
|
||||||
}
|
}
|
||||||
gitCmd, err = sources.NewGitLogCmd(source, logOpts)
|
|
||||||
if err != nil {
|
if scmPlatform, err = scm.PlatformFromString(mustGetStringFlag(cmd, "platform")); err != nil {
|
||||||
log.Fatal().Err(err).Msg("could not create Git cmd")
|
logging.Fatal().Err(err).Send()
|
||||||
}
|
}
|
||||||
findings, err = detector.DetectGit(gitCmd)
|
|
||||||
|
findings, err = detector.DetectSource(
|
||||||
|
cmd.Context(), &sources.Git{
|
||||||
|
Cmd: gitCmd,
|
||||||
|
Config: &detector.Config,
|
||||||
|
Remote: sources.NewRemoteInfoContext(cmd.Context(), scmPlatform, sourcePath),
|
||||||
|
Sema: detector.Sema,
|
||||||
|
MaxArchiveDepth: detector.MaxArchiveDepth,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// don't exit on error, just log it
|
// don't exit on error, just log it
|
||||||
log.Error().Err(err).Msg("failed to scan Git repository")
|
logging.Error().Err(err).Msg("failed to scan Git repository")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set follow symlinks flag
|
findingSummaryAndExit(detector, findings, exitCode, start, err)
|
||||||
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("")
|
|
||||||
}
|
|
||||||
|
|
||||||
findingSummaryAndExit(findings, cmd, cfg, exitCode, start, err)
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,239 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"runtime/pprof"
|
||||||
|
"runtime/trace"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/logging"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DiagnosticsManager manages various types of diagnostics
|
||||||
|
type DiagnosticsManager struct {
|
||||||
|
Enabled bool
|
||||||
|
DiagTypes []string
|
||||||
|
OutputDir string
|
||||||
|
cpuProfile *os.File
|
||||||
|
memProfile string
|
||||||
|
traceProfile *os.File
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDiagnosticsManager creates a new DiagnosticsManager instance
|
||||||
|
func NewDiagnosticsManager(diagnosticsFlag string, diagnosticsDir string) (*DiagnosticsManager, error) {
|
||||||
|
if diagnosticsFlag == "" {
|
||||||
|
return &DiagnosticsManager{Enabled: false}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
dm := &DiagnosticsManager{
|
||||||
|
Enabled: true,
|
||||||
|
DiagTypes: strings.Split(diagnosticsFlag, ","),
|
||||||
|
OutputDir: diagnosticsDir,
|
||||||
|
}
|
||||||
|
|
||||||
|
if diagnosticsFlag == "http" {
|
||||||
|
if len(diagnosticsDir) != 0 {
|
||||||
|
return nil, errors.New("the diagnostics directory should not be set in http mode")
|
||||||
|
}
|
||||||
|
|
||||||
|
return dm, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no output directory is specified, use the current directory
|
||||||
|
if dm.OutputDir == "" {
|
||||||
|
var err error
|
||||||
|
dm.OutputDir, err = os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get current directory: %w", err)
|
||||||
|
}
|
||||||
|
logging.Debug().Msgf("No diagnostics directory specified, using current directory: %s", dm.OutputDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the output directory if it doesn't exist
|
||||||
|
if err := os.MkdirAll(dm.OutputDir, 0755); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create diagnostics directory: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure the output directory is absolute
|
||||||
|
if !filepath.IsAbs(dm.OutputDir) {
|
||||||
|
absPath, err := filepath.Abs(dm.OutputDir)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to get absolute path for diagnostics directory: %w", err)
|
||||||
|
}
|
||||||
|
dm.OutputDir = absPath
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.Debug().Msgf("Diagnostics enabled: %s", strings.Join(dm.DiagTypes, ","))
|
||||||
|
logging.Debug().Msgf("Diagnostics output directory: %s", dm.OutputDir)
|
||||||
|
|
||||||
|
return dm, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartDiagnostics starts all enabled diagnostics
|
||||||
|
func (dm *DiagnosticsManager) StartDiagnostics() error {
|
||||||
|
if !dm.Enabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
for _, diagType := range dm.DiagTypes {
|
||||||
|
diagType = strings.TrimSpace(diagType)
|
||||||
|
switch diagType {
|
||||||
|
case "cpu":
|
||||||
|
if err = dm.StartCPUProfile(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case "mem":
|
||||||
|
if err = dm.SetupMemoryProfile(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case "trace":
|
||||||
|
if err = dm.StartTraceProfile(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case "http":
|
||||||
|
if err = dm.StartHttpHandler(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
logging.Warn().Msgf("Unknown diagnostics type: %s", diagType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopDiagnostics stops all started diagnostics
|
||||||
|
func (dm *DiagnosticsManager) StopDiagnostics() {
|
||||||
|
if !dm.Enabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
logging.Debug().Msg("Stopping diagnostics and writing profiling data...")
|
||||||
|
|
||||||
|
for _, diagType := range dm.DiagTypes {
|
||||||
|
diagType = strings.TrimSpace(diagType)
|
||||||
|
switch diagType {
|
||||||
|
case "cpu":
|
||||||
|
dm.StopCPUProfile()
|
||||||
|
case "mem":
|
||||||
|
dm.WriteMemoryProfile()
|
||||||
|
case "trace":
|
||||||
|
dm.StopTraceProfile()
|
||||||
|
case "http":
|
||||||
|
// No need to stop the http one
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dm *DiagnosticsManager) StartHttpHandler() error {
|
||||||
|
if len(dm.DiagTypes) > 1 {
|
||||||
|
return errors.New("other diagnostics modes should not be enabled when http mode is enabled")
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
logging.Error().Err(http.ListenAndServe("localhost:6060", nil)).Send()
|
||||||
|
}()
|
||||||
|
|
||||||
|
logging.Info().Str("url", "http://localhost:6060/debug/pprof/").Msg("Diagnostics server started")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartCPUProfile starts CPU profiling
|
||||||
|
func (dm *DiagnosticsManager) StartCPUProfile() error {
|
||||||
|
cpuProfilePath := filepath.Join(dm.OutputDir, "cpu.pprof")
|
||||||
|
f, err := os.Create(cpuProfilePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not create CPU profile at %s: %w", cpuProfilePath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := pprof.StartCPUProfile(f); err != nil {
|
||||||
|
_ = f.Close()
|
||||||
|
return fmt.Errorf("could not start CPU profile: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dm.cpuProfile = f
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopCPUProfile stops CPU profiling
|
||||||
|
func (dm *DiagnosticsManager) StopCPUProfile() {
|
||||||
|
if dm.cpuProfile != nil {
|
||||||
|
pprof.StopCPUProfile()
|
||||||
|
if err := dm.cpuProfile.Close(); err != nil {
|
||||||
|
logging.Error().Err(err).Msg("Error closing CPU profile file")
|
||||||
|
}
|
||||||
|
logging.Info().Msgf("CPU profile written to: %s", dm.cpuProfile.Name())
|
||||||
|
dm.cpuProfile = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetupMemoryProfile sets up memory profiling to be written when StopDiagnostics is called
|
||||||
|
func (dm *DiagnosticsManager) SetupMemoryProfile() error {
|
||||||
|
memProfilePath := filepath.Join(dm.OutputDir, "mem.pprof")
|
||||||
|
dm.memProfile = memProfilePath
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteMemoryProfile writes the memory profile to disk
|
||||||
|
func (dm *DiagnosticsManager) WriteMemoryProfile() {
|
||||||
|
if dm.memProfile == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := os.Create(dm.memProfile)
|
||||||
|
if err != nil {
|
||||||
|
logging.Error().Err(err).Msgf("Could not create memory profile at %s", dm.memProfile)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get memory profile
|
||||||
|
runtime.GC() // Run GC before taking the memory profile
|
||||||
|
if err := pprof.WriteHeapProfile(f); err != nil {
|
||||||
|
logging.Error().Err(err).Msg("Could not write memory profile")
|
||||||
|
} else {
|
||||||
|
logging.Info().Msgf("Memory profile written to: %s", dm.memProfile)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := f.Close(); err != nil {
|
||||||
|
logging.Error().Err(err).Msg("Error closing memory profile file")
|
||||||
|
}
|
||||||
|
|
||||||
|
dm.memProfile = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartTraceProfile starts execution tracing
|
||||||
|
func (dm *DiagnosticsManager) StartTraceProfile() error {
|
||||||
|
traceProfilePath := filepath.Join(dm.OutputDir, "trace.out")
|
||||||
|
f, err := os.Create(traceProfilePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not create trace profile at %s: %w", traceProfilePath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := trace.Start(f); err != nil {
|
||||||
|
_ = f.Close()
|
||||||
|
return fmt.Errorf("could not start trace profile: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dm.traceProfile = f
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StopTraceProfile stops execution tracing
|
||||||
|
func (dm *DiagnosticsManager) StopTraceProfile() {
|
||||||
|
if dm.traceProfile != nil {
|
||||||
|
trace.Stop()
|
||||||
|
if err := dm.traceProfile.Close(); err != nil {
|
||||||
|
logging.Error().Err(err).Msg("Error closing trace profile file")
|
||||||
|
}
|
||||||
|
logging.Info().Msgf("Trace profile written to: %s", dm.traceProfile.Name())
|
||||||
|
dm.traceProfile = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
-17
@@ -3,10 +3,9 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/report"
|
"github.com/zricethezav/gitleaks/v8/logging"
|
||||||
"github.com/zricethezav/gitleaks/v8/sources"
|
"github.com/zricethezav/gitleaks/v8/sources"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,11 +30,10 @@ func runDirectory(cmd *cobra.Command, args []string) {
|
|||||||
source = "."
|
source = "."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initConfig(source)
|
initConfig(source)
|
||||||
var (
|
initDiagnostics()
|
||||||
findings []report.Finding
|
var err error
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
// setup config (aka, the thing that defines rules)
|
// setup config (aka, the thing that defines rules)
|
||||||
cfg := Config(cmd)
|
cfg := Config(cmd)
|
||||||
@@ -45,23 +43,32 @@ func runDirectory(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
detector := Detector(cmd, cfg, source)
|
detector := Detector(cmd, cfg, source)
|
||||||
|
|
||||||
|
// set follow symlinks flag
|
||||||
|
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
|
||||||
|
logging.Fatal().Err(err).Send()
|
||||||
|
}
|
||||||
|
|
||||||
// set exit code
|
// set exit code
|
||||||
exitCode, err := cmd.Flags().GetInt("exit-code")
|
exitCode, err := cmd.Flags().GetInt("exit-code")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("could not get exit code")
|
logging.Fatal().Err(err).Msg("could not get exit code")
|
||||||
}
|
}
|
||||||
|
|
||||||
var paths <-chan sources.ScanTarget
|
findings, err := detector.DetectSource(
|
||||||
paths, err = sources.DirectoryTargets(source, detector.Sema, detector.FollowSymlinks)
|
cmd.Context(),
|
||||||
|
&sources.Files{
|
||||||
|
Config: &cfg,
|
||||||
|
FollowSymlinks: detector.FollowSymlinks,
|
||||||
|
MaxFileSize: detector.MaxTargetMegaBytes * 1_000_000,
|
||||||
|
Path: source,
|
||||||
|
Sema: detector.Sema,
|
||||||
|
MaxArchiveDepth: detector.MaxArchiveDepth,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
logging.Error().Err(err).Msg("failed scan directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
findings, err = detector.DetectFiles(paths)
|
findingSummaryAndExit(detector, findings, exitCode, start, err)
|
||||||
if err != nil {
|
|
||||||
// don't exit on error, just log it
|
|
||||||
log.Error().Err(err).Msg("failed scan directory")
|
|
||||||
}
|
|
||||||
|
|
||||||
findingSummaryAndExit(findings, cmd, cfg, exitCode, start, err)
|
|
||||||
}
|
}
|
||||||
@@ -2,110 +2,119 @@ package base
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateGlobalConfig() config.Config {
|
func CreateGlobalConfig() config.Config {
|
||||||
return config.Config{
|
return config.Config{
|
||||||
Title: "gitleaks config",
|
Title: "gitleaks config",
|
||||||
Allowlist: config.Allowlist{
|
Allowlists: []*config.Allowlist{
|
||||||
Description: "global allow lists",
|
{
|
||||||
Regexes: []*regexp.Regexp{
|
Description: "global allow lists",
|
||||||
// ----------- General placeholders -----------
|
Regexes: []*regexp.Regexp{
|
||||||
regexp.MustCompile(`(?i)^true|false|null$`),
|
// ----------- General placeholders -----------
|
||||||
// Awkward workaround to detect repeated characters.
|
regexp.MustCompile(`(?i)^true|false|null$`),
|
||||||
func() *regexp.Regexp {
|
// Awkward workaround to detect repeated characters.
|
||||||
var (
|
func() *regexp.Regexp {
|
||||||
letters = "abcdefghijklmnopqrstuvwxyz*."
|
var (
|
||||||
patterns []string
|
letters = "abcdefghijklmnopqrstuvwxyz*."
|
||||||
)
|
patterns []string
|
||||||
for _, char := range letters {
|
)
|
||||||
if char == '*' || char == '.' {
|
for _, char := range letters {
|
||||||
patterns = append(patterns, fmt.Sprintf("\\%c+", char))
|
if char == '*' || char == '.' {
|
||||||
} else {
|
patterns = append(patterns, fmt.Sprintf("\\%c+", char))
|
||||||
patterns = append(patterns, fmt.Sprintf("%c+", char))
|
} else {
|
||||||
|
patterns = append(patterns, fmt.Sprintf("%c+", char))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return regexp.MustCompile("^(?i:" + strings.Join(patterns, "|") + ")$")
|
||||||
return regexp.MustCompile("^(?i:" + strings.Join(patterns, "|") + ")$")
|
}(),
|
||||||
}(),
|
|
||||||
|
|
||||||
// ----------- Environment Variables -----------
|
// ----------- Environment Variables -----------
|
||||||
regexp.MustCompile(`^\$(\d+|{\d+})$`),
|
regexp.MustCompile(`^\$(?:\d+|{\d+})$`),
|
||||||
regexp.MustCompile(`^\$([A-Z_]+|[a-z_]+)$`),
|
regexp.MustCompile(`^\$(?:[A-Z_]+|[a-z_]+)$`),
|
||||||
regexp.MustCompile(`^\${([A-Z_]+|[a-z_]+)}$`),
|
regexp.MustCompile(`^\${(?:[A-Z_]+|[a-z_]+)}$`),
|
||||||
|
|
||||||
// ----------- Interpolated Variables -----------
|
// ----------- Interpolated Variables -----------
|
||||||
// Ansible (https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html)
|
// Ansible (https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html)
|
||||||
regexp.MustCompile(`^\{\{[ \t]*[\w ().|]+[ \t]*}}$`),
|
regexp.MustCompile(`^\{\{[ \t]*[\w ().|]+[ \t]*}}$`),
|
||||||
// GitHub Actions
|
// GitHub Actions
|
||||||
// https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables
|
// https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables
|
||||||
// https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
|
// https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
|
||||||
regexp.MustCompile(`^\$\{\{[ \t]*((env|github|secrets|vars)(\.[A-Za-z]\w+)+[\w "'&./=|]*)[ \t]*}}$`),
|
regexp.MustCompile(`^\$\{\{[ \t]*(?:(?:env|github|secrets|vars)(?:\.[A-Za-z]\w+)+[\w "'&./=|]*)[ \t]*}}$`),
|
||||||
// NuGet (https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#using-environment-variables)
|
// NuGet (https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#using-environment-variables)
|
||||||
regexp.MustCompile(`^%([A-Z_]+|[a-z_]+)%$`),
|
regexp.MustCompile(`^%(?:[A-Z_]+|[a-z_]+)%$`),
|
||||||
// String formatting.
|
// String formatting.
|
||||||
regexp.MustCompile(`^%[+\-# 0]?[bcdeEfFgGoOpqstTUvxX]$`), // Golang (https://pkg.go.dev/fmt)
|
regexp.MustCompile(`^%[+\-# 0]?[bcdeEfFgGoOpqstTUvxX]$`), // Golang (https://pkg.go.dev/fmt)
|
||||||
regexp.MustCompile(`^\{\d{0,2}}$`), // Python (https://docs.python.org/3/tutorial/inputoutput.html)
|
regexp.MustCompile(`^\{\d{0,2}}$`), // Python (https://docs.python.org/3/tutorial/inputoutput.html)
|
||||||
// Urban Code Deploy (https://www.ibm.com/support/pages/replace-token-step-replaces-replacement-values-windows-variables)
|
// Urban Code Deploy (https://www.ibm.com/support/pages/replace-token-step-replaces-replacement-values-windows-variables)
|
||||||
regexp.MustCompile(`^@([A-Z_]+|[a-z_]+)@$`),
|
regexp.MustCompile(`^@(?:[A-Z_]+|[a-z_]+)@$`),
|
||||||
|
|
||||||
// ----------- Miscellaneous -----------
|
// ----------- Miscellaneous -----------
|
||||||
},
|
// File paths
|
||||||
Paths: []*regexp.Regexp{
|
regexp.MustCompile(`^/Users/(?i)[a-z0-9]+/[\w .-/]+$`), // MacOS
|
||||||
regexp.MustCompile(`gitleaks\.toml`),
|
regexp.MustCompile(`^/(?:bin|etc|home|opt|tmp|usr|var)/[\w ./-]+$`), // Linux
|
||||||
|
// 11980 Jps -Dapplication.home=D:\develop_tools\jdk\jdk1.8.0_131 -Xms8m
|
||||||
|
//regexp.MustCompile(`^$`), // Windows
|
||||||
|
},
|
||||||
|
Paths: []*regexp.Regexp{
|
||||||
|
regexp.MustCompile(`gitleaks\.toml`),
|
||||||
|
|
||||||
// ----------- Documents and media -----------
|
// ----------- Documents and media -----------
|
||||||
regexp.MustCompile(`(?i)\.(bmp|gif|jpe?g|svg|tiff?)$`), // Images
|
regexp.MustCompile(`(?i)\.(?:bmp|gif|jpe?g|png|svg|tiff?)$`), // Images
|
||||||
regexp.MustCompile(`\.(eot|[ot]tf|woff2?)$`), // Fonts
|
regexp.MustCompile(`(?i)\.(?:eot|[ot]tf|woff2?)$`), // Fonts
|
||||||
regexp.MustCompile(`(.*?)(doc|docx|zip|xls|pdf|bin|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe|gltf)$`),
|
regexp.MustCompile(`(?i)\.(?:docx?|xlsx?|pdf|bin|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe|gltf)$`),
|
||||||
|
|
||||||
// ----------- Golang files -----------
|
// ----------- Golang files -----------
|
||||||
regexp.MustCompile(`go\.(mod|sum|work(\.sum)?)$`),
|
regexp.MustCompile(`go\.(?:mod|sum|work(?:\.sum)?)$`),
|
||||||
regexp.MustCompile(`(^|/)vendor/modules\.txt$`),
|
regexp.MustCompile(`(?:^|/)vendor/modules\.txt$`),
|
||||||
regexp.MustCompile(`(^|/)vendor/(github\.com|golang\.org/x|google\.golang\.org|gopkg\.in|istio\.io|k8s\.io|sigs\.k8s\.io)/.*$`),
|
regexp.MustCompile(`(?:^|/)vendor/(?:github\.com|golang\.org/x|google\.golang\.org|gopkg\.in|istio\.io|k8s\.io|sigs\.k8s\.io)(?:/.*)?$`),
|
||||||
|
|
||||||
// ----------- Java files -----------
|
// ----------- Java files -----------
|
||||||
// Gradle
|
// Gradle
|
||||||
regexp.MustCompile(`(^|/)gradlew(\.bat)?$`),
|
regexp.MustCompile(`(?:^|/)gradlew(?:\.bat)?$`),
|
||||||
regexp.MustCompile(`(^|/)gradle\.lockfile$`),
|
regexp.MustCompile(`(?:^|/)gradle\.lockfile$`),
|
||||||
regexp.MustCompile(`(^|/)mvnw(\.cmd)?$`),
|
regexp.MustCompile(`(?:^|/)mvnw(?:\.cmd)?$`),
|
||||||
regexp.MustCompile(`(^|/)\.mvn/wrapper/MavenWrapperDownloader\.java$`),
|
regexp.MustCompile(`(?:^|/)\.mvn/wrapper/MavenWrapperDownloader\.java$`),
|
||||||
|
|
||||||
// ----------- JavaScript files -----------
|
// ----------- JavaScript files -----------
|
||||||
// Dependencies and lock files.
|
// Dependencies and lock files.
|
||||||
regexp.MustCompile(`(^|/)node_modules/.*?$`),
|
regexp.MustCompile(`(?:^|/)node_modules(?:/.*)?$`),
|
||||||
regexp.MustCompile(`(^|/)package-lock\.json$`),
|
regexp.MustCompile(`(?:^|/)(?:deno\.lock|npm-shrinkwrap\.json|package-lock\.json|pnpm-lock\.yaml|yarn\.lock)$`),
|
||||||
regexp.MustCompile(`(^|/)yarn\.lock$`),
|
regexp.MustCompile(`(?:^|/)bower_components(?:/.*)?$`),
|
||||||
regexp.MustCompile(`(^|/)pnpm-lock\.yaml$`),
|
// TODO: Add more common static assets, such as swagger-ui.
|
||||||
regexp.MustCompile(`(^|/)npm-shrinkwrap\.json$`),
|
regexp.MustCompile(`(?:^|/)(?:angular|bootstrap|jquery(?:-?ui)?|plotly|swagger-?ui)[a-zA-Z0-9.-]*(?:\.min)?\.js(?:\.map)?$`),
|
||||||
regexp.MustCompile(`(^|/)bower_components/.*?$`),
|
regexp.MustCompile(`(?:^|/)javascript\.json$`),
|
||||||
// TODO: Add more common static assets, such as swagger-ui.
|
|
||||||
regexp.MustCompile(`(^|/)(jquery(-?ui)?|swagger-?ui)[a-zA-Z0-9.-]+\.js(\.map)?$`),
|
|
||||||
|
|
||||||
// ----------- Python files -----------
|
// ----------- Python files -----------
|
||||||
// Dependencies and lock files.
|
// Dependencies and lock files.
|
||||||
regexp.MustCompile(`(^|/)(Pipfile|poetry)\.lock$`),
|
regexp.MustCompile(`(?:^|/)(?:Pipfile|poetry)\.lock$`),
|
||||||
// Virtual environments
|
// Virtual environments
|
||||||
regexp.MustCompile(`(?i)/?(v?env|virtualenv)/lib(64)?/.+$`),
|
regexp.MustCompile(`(?i)(?:^|/)(?:v?env|virtualenv)/lib(?:64)?(?:/.*)?$`),
|
||||||
regexp.MustCompile(`(?i)(^|/)(lib(64)?/python[23](\.\d{1,2})+/|python/[23](\.\d{1,2})+/lib(64)?/).+$`),
|
regexp.MustCompile(`(?i)(?:^|/)(?:lib(?:64)?/python[23](?:\.\d{1,2})+|python/[23](?:\.\d{1,2})+/lib(?:64)?)(?:/.*)?$`),
|
||||||
// dist-info directory (https://py-pkgs.org/04-package-structure.html#building-sdists-and-wheels)
|
// dist-info directory (https://py-pkgs.org/04-package-structure.html#building-sdists-and-wheels)
|
||||||
regexp.MustCompile(`(?i)(^|/)[a-z0-9_.]+-[0-9.]+\.dist-info/.+$`),
|
regexp.MustCompile(`(?i)(?:^|/)[a-z0-9_.]+-[0-9.]+\.dist-info(?:/.+)?$`),
|
||||||
|
|
||||||
// ----------- Ruby files -----------
|
// ----------- Ruby files -----------
|
||||||
regexp.MustCompile(`(^|/)vendor/(bundle|ruby)/.*?$`),
|
regexp.MustCompile(`(?:^|/)vendor/(?:bundle|ruby)(?:/.*?)?$`),
|
||||||
regexp.MustCompile(`\.gem$`), // tar archive
|
regexp.MustCompile(`\.gem$`), // tar archive
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
regexp.MustCompile(`verification-metadata.xml`),
|
regexp.MustCompile(`verification-metadata\.xml`),
|
||||||
regexp.MustCompile(`Database.refactorlog`),
|
regexp.MustCompile(`Database.refactorlog`),
|
||||||
//regexp.MustCompile(`vendor`),
|
|
||||||
},
|
// ----------- Git files ------------
|
||||||
StopWords: []string{
|
regexp.MustCompile(`(?:^|/)\.git$`),
|
||||||
// ----------- Secrets -----------
|
},
|
||||||
// Checkmarx client secret. (https://github.com/checkmarx-ts/checkmarx-python-sdk/blob/86560f6e2a3e46d16322101294da10d5d190312d/README.md?plain=1#L56)
|
StopWords: []string{
|
||||||
"014df517-39d1-4453-b7b3-9930c563627c",
|
"abcdefghijklmnopqrstuvwxyz", // character range
|
||||||
|
// ----------- Secrets -----------
|
||||||
|
// Checkmarx client secret. (https://github.com/checkmarx-ts/checkmarx-python-sdk/blob/86560f6e2a3e46d16322101294da10d5d190312d/README.md?plain=1#L56)
|
||||||
|
"014df517-39d1-4453-b7b3-9930c563627c",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,139 +4,200 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConfigAllowlistRegexes(t *testing.T) {
|
var allowlistRegexTests = map[string]struct {
|
||||||
tests := map[string]struct {
|
invalid []string
|
||||||
invalid []string
|
valid []string
|
||||||
valid []string
|
}{
|
||||||
}{
|
"general placeholders": {
|
||||||
"general placeholders": {
|
invalid: []string{
|
||||||
invalid: []string{
|
`true`, `True`, `false`, `False`, `null`, `NULL`,
|
||||||
`true`, `True`, `false`, `False`, `null`, `NULL`,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"general placeholders - repeated characters": {
|
},
|
||||||
invalid: []string{
|
"general placeholders - repeated characters": {
|
||||||
`aaaaaaaaaaaaaaaaa`, `BBBBBBBBBBbBBBBBBBbBB`, `********************`,
|
invalid: []string{
|
||||||
},
|
`aaaaaaaaaaaaaaaaa`, `BBBBBBBBBBbBBBBBBBbBB`, `********************`,
|
||||||
valid: []string{`aaaaaaaaaaaaaaaaaaabaa`, `pas*************d`},
|
|
||||||
},
|
},
|
||||||
"environment variables": {
|
valid: []string{`aaaaaaaaaaaaaaaaaaabaa`, `pas*************d`},
|
||||||
invalid: []string{`$2`, `$GIT_PASSWORD`, `${GIT_PASSWORD}`, `$password`},
|
},
|
||||||
valid: []string{`$yP@R.@=ibxI`, `$2a6WCust9aE`, `${not_complete1`},
|
"environment variables": {
|
||||||
|
invalid: []string{`$2`, `$GIT_PASSWORD`, `${GIT_PASSWORD}`, `$password`},
|
||||||
|
valid: []string{`$yP@R.@=ibxI`, `$2a6WCust9aE`, `${not_complete1`},
|
||||||
|
},
|
||||||
|
"interpolated variables - ansible": {
|
||||||
|
invalid: []string{
|
||||||
|
`{{ x }}`, `{{ password }}`, `{{password}}`, `{{ data.proxy_password }}`,
|
||||||
|
`{{ dict1 | ansible.builtin.combine(dict2) }}`,
|
||||||
},
|
},
|
||||||
"interpolated variables - ansible": {
|
},
|
||||||
invalid: []string{
|
"interpolated variables - github actions": {
|
||||||
`{{ x }}`, `{{ password }}`, `{{password}}`, `{{ data.proxy_password }}`,
|
invalid: []string{
|
||||||
`{{ dict1 | ansible.builtin.combine(dict2) }}`,
|
`${{ env.First_Name }}`,
|
||||||
},
|
`${{ env.DAY_OF_WEEK == 'Monday' }}`,
|
||||||
|
`${{env.JAVA_VERSION}}`,
|
||||||
|
`${{ github.event.issue.title }}`,
|
||||||
|
`${{ github.repository == "Gattocrucco/lsqfitgp" }}`,
|
||||||
|
`${{ github.event.pull_request.number || github.ref }}`,
|
||||||
|
`${{ github.event_name == 'pull_request' && github.event.action == 'unassigned' }}`,
|
||||||
|
`${{ secrets.SuperSecret }}`,
|
||||||
|
`${{ vars.JOB_NAME }}`,
|
||||||
|
`${{ vars.USE_VARIABLES == 'true' }}`,
|
||||||
},
|
},
|
||||||
"interpolated variables - github actions": {
|
},
|
||||||
invalid: []string{
|
"interpolated variables - nuget": {
|
||||||
`${{ env.First_Name }}`,
|
invalid: []string{
|
||||||
`${{ env.DAY_OF_WEEK == 'Monday' }}`,
|
`%MY_PASSWORD%`, `%password%`,
|
||||||
`${{env.JAVA_VERSION}}`,
|
|
||||||
`${{ github.event.issue.title }}`,
|
|
||||||
`${{ github.repository == "Gattocrucco/lsqfitgp" }}`,
|
|
||||||
`${{ github.event.pull_request.number || github.ref }}`,
|
|
||||||
`${{ github.event_name == 'pull_request' && github.event.action == 'unassigned' }}`,
|
|
||||||
`${{ secrets.SuperSecret }}`,
|
|
||||||
`${{ vars.JOB_NAME }}`,
|
|
||||||
`${{ vars.USE_VARIABLES == 'true' }}`,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"interpolated variables - nuget": {
|
},
|
||||||
invalid: []string{
|
"interpolated variables - string fmt - golang": {
|
||||||
`%MY_PASSWORD%`, `%password%`,
|
invalid: []string{
|
||||||
},
|
`%b`, `%c`, `%d`, `% d`, `%e`, `%E`, `%f`, `%F`, `%g`, `%G`, `%o`, `%O`, `%p`, `%q`, `%-s`, `%s`, `%t`, `%T`, `%U`, `%#U`, `%+v`, `%#v`, `%v`, `%x`, `%X`,
|
||||||
},
|
},
|
||||||
"interpolated variables - string fmt - golang": {
|
},
|
||||||
invalid: []string{
|
"interpolated variables - string fmt - python": {
|
||||||
`%b`, `%c`, `%d`, `% d`, `%e`, `%E`, `%f`, `%F`, `%g`, `%G`, `%o`, `%O`, `%p`, `%q`, `%-s`, `%s`, `%t`, `%T`, `%U`, `%#U`, `%+v`, `%#v`, `%v`, `%x`, `%X`,
|
invalid: []string{
|
||||||
},
|
`{}`, `{0}`, `{10}`,
|
||||||
},
|
},
|
||||||
"interpolated variables - string fmt - python": {
|
},
|
||||||
invalid: []string{
|
"interpolated variables - ucd": {
|
||||||
`{}`, `{0}`, `{10}`,
|
invalid: []string{`@password@`, `@LDAP_PASS@`},
|
||||||
},
|
valid: []string{`@username@mastodon.example`},
|
||||||
|
},
|
||||||
|
"miscellaneous - file paths": {
|
||||||
|
invalid: []string{
|
||||||
|
// MacOS
|
||||||
|
`/Users/james/Projects/SwiftCode/build/Release`,
|
||||||
|
// Linux
|
||||||
|
`/tmp/screen-exchange`,
|
||||||
},
|
},
|
||||||
"interpolated variables - ucd": {
|
valid: []string{},
|
||||||
invalid: []string{`@password@`, `@LDAP_PASS@`},
|
},
|
||||||
valid: []string{`@username@mastodon.example`},
|
}
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
func TestConfigAllowlistRegexes(t *testing.T) {
|
||||||
cfg := CreateGlobalConfig()
|
cfg := CreateGlobalConfig()
|
||||||
allowlist := cfg.Allowlist
|
allowlists := cfg.Allowlists
|
||||||
for name, cases := range tests {
|
for name, cases := range allowlistRegexTests {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
for _, c := range cases.invalid {
|
for _, c := range cases.invalid {
|
||||||
if !allowlist.RegexAllowed(c) {
|
for _, a := range allowlists {
|
||||||
t.Errorf("invalid value not marked as allowed: %s", c)
|
if !a.RegexAllowed(c) {
|
||||||
|
t.Errorf("invalid value not marked as allowed: %s", c)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range cases.valid {
|
for _, c := range cases.valid {
|
||||||
if allowlist.RegexAllowed(c) {
|
for _, a := range allowlists {
|
||||||
t.Errorf("valid value marked as allowed: %s", c)
|
if a.RegexAllowed(c) {
|
||||||
|
t.Errorf("valid value marked as allowed: %s", c)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkConfigAllowlistRegexes(b *testing.B) {
|
||||||
|
cfg := CreateGlobalConfig()
|
||||||
|
allowlists := cfg.Allowlists
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
for _, cases := range allowlistRegexTests {
|
||||||
|
for _, c := range cases.invalid {
|
||||||
|
for _, a := range allowlists {
|
||||||
|
a.RegexAllowed(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range cases.valid {
|
||||||
|
for _, a := range allowlists {
|
||||||
|
a.RegexAllowed(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var allowlistPathsTests = map[string]struct {
|
||||||
|
invalid []string
|
||||||
|
valid []string
|
||||||
|
}{
|
||||||
|
"javascript - common static assets": {
|
||||||
|
invalid: []string{
|
||||||
|
`tests/e2e/nuget/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js`,
|
||||||
|
`src/main/static/lib/angular.1.2.16.min.js`,
|
||||||
|
`src/main/resources/static/jquery-ui-1.12.1/jquery-ui-min.js`,
|
||||||
|
`src/main/resources/static/js/jquery-ui-1.10.4.min.js`,
|
||||||
|
`src-static/js/plotly.min.js`,
|
||||||
|
`swagger/swaggerui/swagger-ui-bundle.js.map`,
|
||||||
|
`swagger/swaggerui/swagger-ui-es-bundle.js.map`,
|
||||||
|
`src/main/static/swagger-ui.min.js`,
|
||||||
|
`swagger/swaggerui/swagger-ui.js`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"python": {
|
||||||
|
invalid: []string{
|
||||||
|
// lock files
|
||||||
|
`Pipfile.lock`, `poetry.lock`,
|
||||||
|
// virtual environments
|
||||||
|
"env/lib/python3.7/site-packages/urllib3/util/url.py",
|
||||||
|
"venv/Lib/site-packages/regex-2018.08.29.dist-info/DESCRIPTION.rst",
|
||||||
|
"venv/lib64/python3.5/site-packages/pynvml.py",
|
||||||
|
"python/python3/virtualenv/Lib/site-packages/pyphonetics/utils.py",
|
||||||
|
"virtualenv/lib64/python3.7/base64.py",
|
||||||
|
// packages
|
||||||
|
"cde-root/usr/lib64/python2.4/site-packages/Numeric.pth",
|
||||||
|
"lib/python3.9/site-packages/setuptools/_distutils/msvccompiler.py",
|
||||||
|
"lib/python3.8/site-packages/botocore/data/alexaforbusiness/2017-11-09/service-2.json",
|
||||||
|
"code/python/3.7.4/Lib/site-packages/dask/bytes/tests/test_bytes_utils.py",
|
||||||
|
"python/3.7.4/Lib/site-packages/fsspec/utils.py",
|
||||||
|
"python/2.7.16.32/Lib/bsddb/test/test_dbenv.py",
|
||||||
|
"python/lib/python3.8/site-packages/boto3/data/ec2/2016-04-01/resources-1.json",
|
||||||
|
// distinfo
|
||||||
|
"libs/PyX-0.15.dist-info/AUTHORS",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
func TestConfigAllowlistPaths(t *testing.T) {
|
func TestConfigAllowlistPaths(t *testing.T) {
|
||||||
tests := map[string]struct {
|
|
||||||
invalid []string
|
|
||||||
valid []string
|
|
||||||
}{
|
|
||||||
"javascript - common static assets": {
|
|
||||||
invalid: []string{
|
|
||||||
`src/main/resources/static/jquery-ui-1.12.1/jquery-ui-min.js`,
|
|
||||||
`src/main/resources/static/js/jquery-ui-1.10.4.min.js`,
|
|
||||||
`swagger/swaggerui/swagger-ui-bundle.js.map`,
|
|
||||||
`swagger/swaggerui/swagger-ui-es-bundle.js.map`,
|
|
||||||
`src/main/static/swagger-ui.min.js`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"python": {
|
|
||||||
invalid: []string{
|
|
||||||
// lock files
|
|
||||||
`Pipfile.lock`, `poetry.lock`,
|
|
||||||
// virtual environments
|
|
||||||
"env/lib/python3.7/site-packages/urllib3/util/url.py",
|
|
||||||
"venv/Lib/site-packages/regex-2018.08.29.dist-info/DESCRIPTION.rst",
|
|
||||||
"venv/lib64/python3.5/site-packages/pynvml.py",
|
|
||||||
"python/python3/virtualenv/Lib/site-packages/pyphonetics/utils.py",
|
|
||||||
"virtualenv/lib64/python3.7/base64.py",
|
|
||||||
// packages
|
|
||||||
"cde-root/usr/lib64/python2.4/site-packages/Numeric.pth",
|
|
||||||
"lib/python3.9/site-packages/setuptools/_distutils/msvccompiler.py",
|
|
||||||
"lib/python3.8/site-packages/botocore/data/alexaforbusiness/2017-11-09/service-2.json",
|
|
||||||
"code/python/3.7.4/Lib/site-packages/dask/bytes/tests/test_bytes_utils.py",
|
|
||||||
"python/3.7.4/Lib/site-packages/fsspec/utils.py",
|
|
||||||
"python/2.7.16.32/Lib/bsddb/test/test_dbenv.py",
|
|
||||||
"python/lib/python3.8/site-packages/boto3/data/ec2/2016-04-01/resources-1.json",
|
|
||||||
// distinfo
|
|
||||||
"libs/PyX-0.15.dist-info/AUTHORS",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg := CreateGlobalConfig()
|
cfg := CreateGlobalConfig()
|
||||||
allowlist := cfg.Allowlist
|
allowlists := cfg.Allowlists
|
||||||
for name, cases := range tests {
|
for name, cases := range allowlistPathsTests {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
for _, c := range cases.invalid {
|
for _, c := range cases.invalid {
|
||||||
if !allowlist.PathAllowed(c) {
|
for _, a := range allowlists {
|
||||||
t.Errorf("invalid path not marked as allowed: %s", c)
|
if !a.PathAllowed(c) {
|
||||||
|
t.Errorf("invalid path not marked as allowed: %s", c)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range cases.valid {
|
for _, c := range cases.valid {
|
||||||
if allowlist.PathAllowed(c) {
|
for _, a := range allowlists {
|
||||||
t.Errorf("valid path marked as allowed: %s", c)
|
if a.PathAllowed(c) {
|
||||||
|
t.Errorf("valid path marked as allowed: %s", c)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkConfigAllowlistPaths(b *testing.B) {
|
||||||
|
cfg := CreateGlobalConfig()
|
||||||
|
allowlists := cfg.Allowlists
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
for _, cases := range allowlistPathsTests {
|
||||||
|
for _, c := range cases.invalid {
|
||||||
|
for _, a := range allowlists {
|
||||||
|
a.PathAllowed(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, c := range cases.valid {
|
||||||
|
for _, a := range allowlists {
|
||||||
|
a.PathAllowed(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+55
-10
@@ -2,14 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"slices"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/base"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/base"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/rules"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/rules"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -20,21 +19,29 @@ const (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) < 2 {
|
if len(os.Args) < 2 {
|
||||||
os.Stderr.WriteString("Specify path to the gitleaks.toml config\n")
|
_, _ = os.Stderr.WriteString("Specify path to the gitleaks.toml config\n")
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
gitleaksConfigPath := os.Args[1]
|
gitleaksConfigPath := os.Args[1]
|
||||||
|
|
||||||
configRules := []*config.Rule{
|
configRules := []*config.Rule{
|
||||||
|
rules.OnePasswordSecretKey(),
|
||||||
rules.OnePasswordServiceAccountToken(),
|
rules.OnePasswordServiceAccountToken(),
|
||||||
rules.AdafruitAPIKey(),
|
rules.AdafruitAPIKey(),
|
||||||
rules.AdobeClientID(),
|
rules.AdobeClientID(),
|
||||||
rules.AdobeClientSecret(),
|
rules.AdobeClientSecret(),
|
||||||
rules.AgeSecretKey(),
|
rules.AgeSecretKey(),
|
||||||
rules.Airtable(),
|
rules.AirtableApiKey(),
|
||||||
|
rules.AirtablePersonalAccessToken(),
|
||||||
rules.AlgoliaApiKey(),
|
rules.AlgoliaApiKey(),
|
||||||
rules.AlibabaAccessKey(),
|
rules.AlibabaAccessKey(),
|
||||||
rules.AlibabaSecretKey(),
|
rules.AlibabaSecretKey(),
|
||||||
|
rules.AmazonBedrockAPIKeyLongLived(),
|
||||||
|
rules.AmazonBedrockAPIKeyShortLived(),
|
||||||
|
rules.AnthropicAdminApiKey(),
|
||||||
|
rules.AnthropicApiKey(),
|
||||||
|
rules.ArtifactoryApiKey(),
|
||||||
|
rules.ArtifactoryReferenceToken(),
|
||||||
rules.AsanaClientID(),
|
rules.AsanaClientID(),
|
||||||
rules.AsanaClientSecret(),
|
rules.AsanaClientSecret(),
|
||||||
rules.Atlassian(),
|
rules.Atlassian(),
|
||||||
@@ -48,6 +55,7 @@ func main() {
|
|||||||
rules.Beamer(),
|
rules.Beamer(),
|
||||||
rules.CodecovAccessToken(),
|
rules.CodecovAccessToken(),
|
||||||
rules.CoinbaseAccessToken(),
|
rules.CoinbaseAccessToken(),
|
||||||
|
rules.ClickHouseCloud(),
|
||||||
rules.Clojars(),
|
rules.Clojars(),
|
||||||
rules.CloudflareAPIKey(),
|
rules.CloudflareAPIKey(),
|
||||||
rules.CloudflareGlobalAPIKey(),
|
rules.CloudflareGlobalAPIKey(),
|
||||||
@@ -90,6 +98,7 @@ func main() {
|
|||||||
rules.FlutterwaveEncKey(),
|
rules.FlutterwaveEncKey(),
|
||||||
rules.FlyIOAccessToken(),
|
rules.FlyIOAccessToken(),
|
||||||
rules.FrameIO(),
|
rules.FrameIO(),
|
||||||
|
rules.Freemius(),
|
||||||
rules.FreshbooksAccessToken(),
|
rules.FreshbooksAccessToken(),
|
||||||
rules.GoCardless(),
|
rules.GoCardless(),
|
||||||
// TODO figure out what makes sense for GCP
|
// TODO figure out what makes sense for GCP
|
||||||
@@ -108,9 +117,11 @@ func main() {
|
|||||||
rules.GitlabKubernetesAgentToken(),
|
rules.GitlabKubernetesAgentToken(),
|
||||||
rules.GitlabOauthAppSecret(),
|
rules.GitlabOauthAppSecret(),
|
||||||
rules.GitlabPat(),
|
rules.GitlabPat(),
|
||||||
|
rules.GitlabPatRoutable(),
|
||||||
rules.GitlabPipelineTriggerToken(),
|
rules.GitlabPipelineTriggerToken(),
|
||||||
rules.GitlabRunnerRegistrationToken(),
|
rules.GitlabRunnerRegistrationToken(),
|
||||||
rules.GitlabRunnerAuthenticationToken(),
|
rules.GitlabRunnerAuthenticationToken(),
|
||||||
|
rules.GitlabRunnerAuthenticationTokenRoutable(),
|
||||||
rules.GitlabScimToken(),
|
rules.GitlabScimToken(),
|
||||||
rules.GitlabSessionCookie(),
|
rules.GitlabSessionCookie(),
|
||||||
rules.GitterAccessToken(),
|
rules.GitterAccessToken(),
|
||||||
@@ -121,6 +132,7 @@ func main() {
|
|||||||
rules.HashiCorpTerraform(),
|
rules.HashiCorpTerraform(),
|
||||||
rules.HashicorpField(),
|
rules.HashicorpField(),
|
||||||
rules.Heroku(),
|
rules.Heroku(),
|
||||||
|
rules.HerokuV2(),
|
||||||
rules.HubSpot(),
|
rules.HubSpot(),
|
||||||
rules.HuggingFaceAccessToken(),
|
rules.HuggingFaceAccessToken(),
|
||||||
rules.HuggingFaceOrganizationApiToken(),
|
rules.HuggingFaceOrganizationApiToken(),
|
||||||
@@ -141,12 +153,16 @@ func main() {
|
|||||||
rules.LinkedinClientSecret(),
|
rules.LinkedinClientSecret(),
|
||||||
rules.LobAPIToken(),
|
rules.LobAPIToken(),
|
||||||
rules.LobPubAPIToken(),
|
rules.LobPubAPIToken(),
|
||||||
|
rules.LookerClientID(),
|
||||||
|
rules.LookerClientSecret(),
|
||||||
rules.MailChimp(),
|
rules.MailChimp(),
|
||||||
rules.MailGunPubAPIToken(),
|
rules.MailGunPubAPIToken(),
|
||||||
rules.MailGunPrivateAPIToken(),
|
rules.MailGunPrivateAPIToken(),
|
||||||
rules.MailGunSigningKey(),
|
rules.MailGunSigningKey(),
|
||||||
rules.MapBox(),
|
rules.MapBox(),
|
||||||
rules.MattermostAccessToken(),
|
rules.MattermostAccessToken(),
|
||||||
|
rules.MaxMindLicenseKey(),
|
||||||
|
rules.Meraki(),
|
||||||
rules.MessageBirdAPIToken(),
|
rules.MessageBirdAPIToken(),
|
||||||
rules.MessageBirdClientID(),
|
rules.MessageBirdClientID(),
|
||||||
rules.NetlifyAccessToken(),
|
rules.NetlifyAccessToken(),
|
||||||
@@ -154,6 +170,7 @@ func main() {
|
|||||||
rules.NewRelicUserKey(),
|
rules.NewRelicUserKey(),
|
||||||
rules.NewRelicBrowserAPIKey(),
|
rules.NewRelicBrowserAPIKey(),
|
||||||
rules.NewRelicInsertKey(),
|
rules.NewRelicInsertKey(),
|
||||||
|
rules.Notion(),
|
||||||
rules.NPM(),
|
rules.NPM(),
|
||||||
rules.NugetConfigPassword(),
|
rules.NugetConfigPassword(),
|
||||||
rules.NytimesAccessToken(),
|
rules.NytimesAccessToken(),
|
||||||
@@ -161,6 +178,7 @@ func main() {
|
|||||||
rules.OktaAccessToken(),
|
rules.OktaAccessToken(),
|
||||||
rules.OpenAI(),
|
rules.OpenAI(),
|
||||||
rules.OpenshiftUserToken(),
|
rules.OpenshiftUserToken(),
|
||||||
|
rules.PerplexityAPIKey(),
|
||||||
rules.PlaidAccessID(),
|
rules.PlaidAccessID(),
|
||||||
rules.PlaidSecretKey(),
|
rules.PlaidSecretKey(),
|
||||||
rules.PlaidAccessToken(),
|
rules.PlaidAccessToken(),
|
||||||
@@ -171,6 +189,7 @@ func main() {
|
|||||||
rules.Prefect(),
|
rules.Prefect(),
|
||||||
rules.PrivateAIToken(),
|
rules.PrivateAIToken(),
|
||||||
rules.PrivateKey(),
|
rules.PrivateKey(),
|
||||||
|
rules.PrivateKeyPKCS12File(),
|
||||||
rules.PulumiAPIToken(),
|
rules.PulumiAPIToken(),
|
||||||
rules.PyPiUploadToken(),
|
rules.PyPiUploadToken(),
|
||||||
rules.RapidAPIAccessToken(),
|
rules.RapidAPIAccessToken(),
|
||||||
@@ -182,6 +201,11 @@ func main() {
|
|||||||
rules.SendGridAPIToken(),
|
rules.SendGridAPIToken(),
|
||||||
rules.SendInBlueAPIToken(),
|
rules.SendInBlueAPIToken(),
|
||||||
rules.SentryAccessToken(),
|
rules.SentryAccessToken(),
|
||||||
|
rules.SentryOrgToken(),
|
||||||
|
rules.SentryUserToken(),
|
||||||
|
rules.SettlemintApplicationAccessToken(),
|
||||||
|
rules.SettlemintPersonalAccessToken(),
|
||||||
|
rules.SettlemintServiceAccessToken(),
|
||||||
rules.ShippoAPIToken(),
|
rules.ShippoAPIToken(),
|
||||||
rules.ShopifyAccessToken(),
|
rules.ShopifyAccessToken(),
|
||||||
rules.ShopifyCustomAccessToken(),
|
rules.ShopifyCustomAccessToken(),
|
||||||
@@ -199,6 +223,8 @@ func main() {
|
|||||||
rules.SlackLegacyToken(),
|
rules.SlackLegacyToken(),
|
||||||
rules.SlackWebHookUrl(),
|
rules.SlackWebHookUrl(),
|
||||||
rules.Snyk(),
|
rules.Snyk(),
|
||||||
|
rules.Sonar(),
|
||||||
|
rules.SourceGraph(),
|
||||||
rules.StripeAccessToken(),
|
rules.StripeAccessToken(),
|
||||||
rules.SquareAccessToken(),
|
rules.SquareAccessToken(),
|
||||||
rules.SquareSpaceAccessToken(),
|
rules.SquareSpaceAccessToken(),
|
||||||
@@ -228,29 +254,48 @@ func main() {
|
|||||||
// ensure rules have unique ids
|
// ensure rules have unique ids
|
||||||
ruleLookUp := make(map[string]config.Rule, len(configRules))
|
ruleLookUp := make(map[string]config.Rule, len(configRules))
|
||||||
for _, rule := range configRules {
|
for _, rule := range configRules {
|
||||||
|
if err := rule.Validate(); err != nil {
|
||||||
|
logging.Fatal().Err(err).
|
||||||
|
Str("rule-id", rule.RuleID).
|
||||||
|
Msg("Failed to validate rule")
|
||||||
|
}
|
||||||
|
|
||||||
// check if rule is in ruleLookUp
|
// check if rule is in ruleLookUp
|
||||||
if _, ok := ruleLookUp[rule.RuleID]; ok {
|
if _, ok := ruleLookUp[rule.RuleID]; ok {
|
||||||
log.Fatal().Msgf("rule id %s is not unique", rule.RuleID)
|
logging.Fatal().
|
||||||
|
Str("rule-id", rule.RuleID).
|
||||||
|
Msg("rule id is not unique")
|
||||||
}
|
}
|
||||||
// TODO: eventually change all the signatures to get ride of this
|
// TODO: eventually change all the signatures to get ride of this
|
||||||
// nasty dereferencing.
|
// nasty dereferencing.
|
||||||
ruleLookUp[rule.RuleID] = *rule
|
ruleLookUp[rule.RuleID] = *rule
|
||||||
|
|
||||||
|
// Slices are de-duplicated with a map, every iteration has a different order.
|
||||||
|
// This is an awkward workaround.
|
||||||
|
for _, allowlist := range rule.Allowlists {
|
||||||
|
slices.Sort(allowlist.Commits)
|
||||||
|
slices.Sort(allowlist.StopWords)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(templatePath)
|
tmpl, err := template.ParseFiles(templatePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Failed to parse template")
|
logging.Fatal().Err(err).Msg("Failed to parse template")
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create(gitleaksConfigPath)
|
f, err := os.Create(gitleaksConfigPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Failed to create rules.toml")
|
logging.Fatal().Err(err).Msg("Failed to create rules.toml")
|
||||||
}
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
cfg := base.CreateGlobalConfig()
|
cfg := base.CreateGlobalConfig()
|
||||||
cfg.Rules = ruleLookUp
|
cfg.Rules = ruleLookUp
|
||||||
|
for _, allowlist := range cfg.Allowlists {
|
||||||
|
slices.Sort(allowlist.Commits)
|
||||||
|
slices.Sort(allowlist.StopWords)
|
||||||
|
}
|
||||||
if err = tmpl.Execute(f, cfg); err != nil {
|
if err = tmpl.Execute(f, cfg); err != nil {
|
||||||
log.Fatal().Err(err).Msg("could not execute template")
|
logging.Fatal().Err(err).Msg("could not execute template")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
"regexp"
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://developer.1password.com/docs/service-accounts/security/?token-example=encoded
|
// https://developer.1password.com/docs/service-accounts/security/?token-example=encoded
|
||||||
@@ -33,10 +33,49 @@ export OP_SERVICE_ACCOUNT_TOKEN=ops_eyJzaWduSW5BZGRyZXNzIjoibXkuMXBhc3N3b3JkLmNv
|
|||||||
serviceAccountToken:
|
serviceAccountToken:
|
||||||
fn::secret: ops_eyJzaWduSW5B..[Redacted]`,
|
fn::secret: ops_eyJzaWduSW5B..[Redacted]`,
|
||||||
`: To start using this service account, run the following command:
|
`: To start using this service account, run the following command:
|
||||||
:
|
:
|
||||||
: export OP_SERVICE_ACCOUNT_TOKEN=ops_eyJzaWduSW5BZGRyZXNzIjoiaHR0cHM6...`,
|
: export OP_SERVICE_ACCOUNT_TOKEN=ops_eyJzaWduSW5BZGRyZXNzIjoiaHR0cHM6...`,
|
||||||
// Low entropy.
|
// Low entropy.
|
||||||
`ops_eyJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`,
|
`ops_eyJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`,
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reference:
|
||||||
|
// - https://1passwordstatic.com/files/security/1password-white-paper.pdf
|
||||||
|
func OnePasswordSecretKey() *config.Rule {
|
||||||
|
// 1Password secret keys include several hyphens but these are only for readability
|
||||||
|
// and are stripped during 1Password login. This means that the following are technically
|
||||||
|
// the same valid key:
|
||||||
|
// - A3ASWWYB798JRYLJVD423DC286TVMH43EB
|
||||||
|
// - A-3-A-S-W-W-Y-B-7-9-8-J-R-Y-L-J-V-D-4-2-3-D-C-2-8-6-T-V-M-H-4-3-E-B
|
||||||
|
// But in practice, when these keys are added to a vault, exported in an emergency kit, or
|
||||||
|
// copied, they have hyphens that follow one of two patterns I can find:
|
||||||
|
// - A3-ASWWYB-798JRY-LJVD4-23DC2-86TVM-H43EB (every key I've generated has this pattern)
|
||||||
|
// - A3-ASWWYB-798JRYLJVD4-23DC2-86TVM-H43EB (the whitepaper includes this example, which could just be a typo)
|
||||||
|
// To avoid a complicated regex that checks for every possible situation it's probably best
|
||||||
|
// to scan for the these two patterns.
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Uncovered a possible 1Password secret key, potentially compromising access to secrets in vaults.",
|
||||||
|
RuleID: "1password-secret-key",
|
||||||
|
Regex: regexp.MustCompile(`\bA3-[A-Z0-9]{6}-(?:(?:[A-Z0-9]{11})|(?:[A-Z0-9]{6}-[A-Z0-9]{5}))-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}\b`),
|
||||||
|
Entropy: 3.8,
|
||||||
|
Keywords: []string{"A3-"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("1password", secrets.NewSecret(`A3-[A-Z0-9]{6}-[A-Z0-9]{11}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}`))
|
||||||
|
tps = append(tps, utils.GenerateSampleSecrets("1password", secrets.NewSecret(`A3-[A-Z0-9]{6}-[A-Z0-9]{6}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}-[A-Z0-9]{5}`))...)
|
||||||
|
tps = append(tps,
|
||||||
|
// from whitepaper
|
||||||
|
`A3-ASWWYB-798JRYLJVD4-23DC2-86TVM-H43EB`,
|
||||||
|
`A3-ASWWYB-798JRY-LJVD4-23DC2-86TVM-H43EB`,
|
||||||
|
)
|
||||||
|
fps := []string{
|
||||||
|
// low entropy
|
||||||
|
`A3-XXXXXX-XXXXXXXXXXX-XXXXX-XXXXX-XXXXX`,
|
||||||
|
// lowercase
|
||||||
|
`A3-xXXXXX-XXXXXX-XXXXX-XXXXX-XXXXX-XXXXX`,
|
||||||
|
}
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -16,8 +16,6 @@ func AdafruitAPIKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("adafruit", secrets.NewSecret(utils.AlphaNumericExtendedShort("32")))
|
||||||
utils.GenerateSampleSecret("adafruit", secrets.NewSecret(utils.AlphaNumericExtendedShort("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -17,9 +17,7 @@ func AdobeClientID() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("adobe", secrets.NewSecret(utils.Hex("32")))
|
||||||
utils.GenerateSampleSecret("adobe", secrets.NewSecret(utils.Hex("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,8 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AgeSecretKey() *config.Rule {
|
func AgeSecretKey() *config.Rule {
|
||||||
@@ -17,8 +16,6 @@ func AgeSecretKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("age", `AGE-SECRET-KEY-1QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ`) // gitleaks:allow
|
||||||
`apiKey := "AGE-SECRET-KEY-1QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ`, // gitleaks:allow
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Airtable() *config.Rule {
|
func AirtableApiKey() *config.Rule {
|
||||||
// define rule
|
// define rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Uncovered a possible Airtable API Key, potentially compromising database access and leading to data leakage or alteration.",
|
Description: "Uncovered a possible Airtable API Key, potentially compromising database access and leading to data leakage or alteration.",
|
||||||
@@ -16,8 +18,20 @@ func Airtable() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("airtable", secrets.NewSecret(utils.AlphaNumeric("17")))
|
||||||
utils.GenerateSampleSecret("airtable", secrets.NewSecret(utils.AlphaNumeric("17"))),
|
return utils.Validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AirtablePersonalAccessToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Uncovered a possible Airtable Personal AccessToken, potentially compromising database access and leading to data leakage or alteration.",
|
||||||
|
RuleID: "airtable-personnal-access-token",
|
||||||
|
Regex: regexp.MustCompile(`\b(pat[[:alnum:]]{14}\.[a-f0-9]{64})\b`),
|
||||||
|
Keywords: []string{"airtable"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("airtable", "pat"+secrets.NewSecret(utils.AlphaNumeric("14")+"\\."+utils.Hex("64")))
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -16,8 +16,6 @@ func AlgoliaApiKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("algolia", secrets.NewSecret(utils.Hex("32")))
|
||||||
"algolia_key := " + secrets.NewSecret(utils.Hex("32")),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -35,8 +35,6 @@ func AlibabaSecretKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("alibaba", secrets.NewSecret(utils.AlphaNumeric("30")))
|
||||||
utils.GenerateSampleSecret("alibaba", secrets.NewSecret(utils.AlphaNumeric("30"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func AnthropicApiKey() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "anthropic-api-key",
|
||||||
|
Description: "Identified an Anthropic API Key, which may compromise AI assistant integrations and expose sensitive data to unauthorized access.",
|
||||||
|
Regex: utils.GenerateUniqueTokenRegex(`sk-ant-api03-[a-zA-Z0-9_\-]{93}AA`, false),
|
||||||
|
Keywords: []string{
|
||||||
|
"sk-ant-api03",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
// Valid API key example
|
||||||
|
"sk-ant-api03-abc123xyz-456def789ghij-klmnopqrstuvwx-3456yza789bcde-1234fghijklmnopby56aaaogaopaaaabc123xyzAA",
|
||||||
|
// Generate additional random test keys
|
||||||
|
utils.GenerateSampleSecret("anthropic", "sk-ant-api03-"+secrets.NewSecret(utils.AlphaNumericExtendedShort("93"))+"AA"),
|
||||||
|
}
|
||||||
|
|
||||||
|
fps := []string{
|
||||||
|
// Too short key (missing characters)
|
||||||
|
"sk-ant-api03-abc123xyz-456de-klMnopqrstuvwx-3456yza789bcde-1234fghijklmnopAA",
|
||||||
|
// Wrong suffix
|
||||||
|
"sk-ant-api03-abc123xyz-456def789ghij-klmnopqrstuvwx-3456yza789bcde-1234fghijklmnopby56aaaogaopaaaabc123xyzBB",
|
||||||
|
// Wrong prefix (admin key, not API key)
|
||||||
|
"sk-ant-admin01-abc123xyz-456def789ghij-klmnopqrstuvwx-3456yza789bcde-1234fghijklmnopby56aaaogaopaaaabc123xyzAA",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AnthropicAdminApiKey() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "anthropic-admin-api-key",
|
||||||
|
Description: "Detected an Anthropic Admin API Key, risking unauthorized access to administrative functions and sensitive AI model configurations.",
|
||||||
|
Regex: utils.GenerateUniqueTokenRegex(`sk-ant-admin01-[a-zA-Z0-9_\-]{93}AA`, false),
|
||||||
|
Keywords: []string{
|
||||||
|
"sk-ant-admin01",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
// Valid admin key example
|
||||||
|
"sk-ant-admin01-abc12fake-456def789ghij-klmnopqrstuvwx-3456yza789bcde-12fakehijklmnopby56aaaogaopaaaabc123xyzAA",
|
||||||
|
// Generate additional random test keys
|
||||||
|
utils.GenerateSampleSecret("anthropic", "sk-ant-admin01-"+secrets.NewSecret(utils.AlphaNumericExtendedShort("93"))+"AA"),
|
||||||
|
}
|
||||||
|
|
||||||
|
fps := []string{
|
||||||
|
// Too short key (missing characters)
|
||||||
|
"sk-ant-admin01-abc123xyz-456de-klMnopqrstuvwx-3456yza789bcde-1234fghijklmnopAA",
|
||||||
|
// Wrong suffix
|
||||||
|
"sk-ant-admin01-abc123xyz-456def789ghij-klmnopqrstuvwx-3456yza789bcde-1234fghijklmnopby56aaaogaopaaaabc123xyzBB",
|
||||||
|
// Wrong prefix (API key, not admin key)
|
||||||
|
"sk-ant-api03-abc123xyz-456def789ghij-klmnopqrstuvwx-3456yza789bcde-1234fghijklmnopby56aaaogaopaaaabc123xyzAA",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ArtifactoryApiKey() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "artifactory-api-key",
|
||||||
|
Description: "Detected an Artifactory api key, posing a risk unauthorized access to the central repository.",
|
||||||
|
Regex: regexp.MustCompile(`\bAKCp[A-Za-z0-9]{69}\b`),
|
||||||
|
Entropy: 4.5,
|
||||||
|
Keywords: []string{"AKCp"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
"artifactoryApiKey := \"AKCp" + secrets.NewSecret(utils.AlphaNumeric("69")) + "\"",
|
||||||
|
}
|
||||||
|
// false positives
|
||||||
|
fps := []string{
|
||||||
|
`lowEntropy := AKCpXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`,
|
||||||
|
"wrongStart := \"AkCp" + secrets.NewSecret(utils.AlphaNumeric("69")) + "\"",
|
||||||
|
"wrongLength := \"AkCp" + secrets.NewSecret(utils.AlphaNumeric("59")) + "\"",
|
||||||
|
"partOfAlongUnrelatedBlob gYnkgAkCp" + secrets.NewSecret(utils.AlphaNumeric("69")) + "VyZSB2",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArtifactoryReferenceToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "artifactory-reference-token",
|
||||||
|
Description: "Detected an Artifactory reference token, posing a risk of impersonation and unauthorized access to the central repository.",
|
||||||
|
Regex: regexp.MustCompile(`\bcmVmd[A-Za-z0-9]{59}\b`),
|
||||||
|
Entropy: 4.5,
|
||||||
|
Keywords: []string{"cmVmd"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
"artifactoryRefToken := \"cmVmd" + secrets.NewSecret(utils.AlphaNumeric("59")) + "\"",
|
||||||
|
}
|
||||||
|
// false positives
|
||||||
|
fps := []string{
|
||||||
|
`lowEntropy := cmVmdXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`,
|
||||||
|
"wrongStart := \"cmVMd" + secrets.NewSecret(utils.AlphaNumeric("59")) + "\"",
|
||||||
|
"wrongLength := \"cmVmd" + secrets.NewSecret(utils.AlphaNumeric("49")) + "\"",
|
||||||
|
"partOfAlongUnrelatedBlob gYnkgcmVmd" + secrets.NewSecret(utils.AlphaNumeric("59")) + "VyZSB2",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -16,9 +16,7 @@ func AsanaClientID() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("asana", secrets.NewSecret(utils.Numeric("16")))
|
||||||
utils.GenerateSampleSecret("asana", secrets.NewSecret(utils.Numeric("16"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,8 +31,6 @@ func AsanaClientSecret() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("asana", secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
utils.GenerateSampleSecret("asana", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -11,15 +11,26 @@ func Atlassian() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Detected an Atlassian API token, posing a threat to project management and collaboration tool security and data confidentiality.",
|
Description: "Detected an Atlassian API token, posing a threat to project management and collaboration tool security and data confidentiality.",
|
||||||
RuleID: "atlassian-api-token",
|
RuleID: "atlassian-api-token",
|
||||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
Regex: utils.MergeRegexps(
|
||||||
"atlassian", "confluence", "jira"}, utils.AlphaNumeric("24"), true),
|
utils.GenerateSemiGenericRegex(
|
||||||
Keywords: []string{"atlassian", "confluence", "jira"},
|
[]string{"(?-i:ATLASSIAN|[Aa]tlassian)", "(?-i:CONFLUENCE|[Cc]onfluence)", "(?-i:JIRA|[Jj]ira)"},
|
||||||
|
`[a-z0-9]{20}[a-f0-9]{4}`, // The last 4 characters are an MD5 hash.
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
utils.GenerateUniqueTokenRegex(`ATATT3[A-Za-z0-9_\-=]{186}`, false),
|
||||||
|
),
|
||||||
|
Entropy: 3.5,
|
||||||
|
Keywords: []string{"atlassian", "confluence", "jira", "atatt3"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("atlassian", secrets.NewSecret(utils.AlphaNumeric("20")+"[a-f0-9]{4}"))
|
||||||
utils.GenerateSampleSecret("atlassian", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
tps = append(tps, utils.GenerateSampleSecrets("confluence", secrets.NewSecret(utils.AlphaNumeric("20")+"[a-f0-9]{4}"))...)
|
||||||
utils.GenerateSampleSecret("confluence", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
tps = append(tps, utils.GenerateSampleSecrets("jira", secrets.NewSecret(utils.AlphaNumeric("20")+"[a-f0-9]{4}"))...)
|
||||||
}
|
tps = append(tps, `JIRA_API_TOKEN=HXe8DGg1iJd2AopzyxkFB7F2`)
|
||||||
return utils.Validate(r, tps, nil)
|
tps = append(tps, utils.GenerateSampleSecrets("jira", "ATATT3xFfGF0K3irG5tKKi-6u-wwaXQFeGwZ-IHR-hQ3CulkKtMSuteRQFfLZ6jihHThzZCg_UjnDt-4Wl_gIRf4zrZJs5JqaeuBhsfJ4W5GD6yGg3W7903gbvaxZPBjxIQQ7BgFDSkPS8oPispw4KLz56mdK-G6CIvLO6hHRrZHY0Q3tvJ6JxE=C63992E6")...)
|
||||||
|
|
||||||
|
fps := []string{"getPagesInConfluenceSpace,searchConfluenceUsingCql"}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,8 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
@@ -26,8 +26,6 @@ func Authress() *config.Rule {
|
|||||||
account_id := "acc_" + utils.AlphaNumeric("10")
|
account_id := "acc_" + utils.AlphaNumeric("10")
|
||||||
signature_key := utils.AlphaNumericExtendedShort("40")
|
signature_key := utils.AlphaNumericExtendedShort("40")
|
||||||
|
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("authress", secrets.NewSecret(fmt.Sprintf(`%s\.%s\.%s\.%s`, service_client_id, access_key_id, account_id, signature_key)))
|
||||||
utils.GenerateSampleSecret("authress", secrets.NewSecret(fmt.Sprintf(`%s\.%s\.%s\.%s`, service_client_id, access_key_id, account_id, signature_key))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -3,17 +3,16 @@ package rules
|
|||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func AWS() *config.Rule {
|
func AWS() *config.Rule {
|
||||||
// define rule
|
// define rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Identified a pattern that may indicate AWS credentials, risking unauthorized cloud resource access and data breaches on AWS platforms.",
|
|
||||||
RuleID: "aws-access-token",
|
RuleID: "aws-access-token",
|
||||||
Regex: utils.GenerateUniqueTokenRegex("(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}", false),
|
Description: "Identified a pattern that may indicate AWS credentials, risking unauthorized cloud resource access and data breaches on AWS platforms.",
|
||||||
|
Regex: regexp.MustCompile(`\b((?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z2-7]{16})\b`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
// https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-unique-ids
|
// https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-unique-ids
|
||||||
@@ -23,7 +22,7 @@ func AWS() *config.Rule {
|
|||||||
"ABIA", // AWS STS service bearer token
|
"ABIA", // AWS STS service bearer token
|
||||||
"ACCA", // Context-specific credential
|
"ACCA", // Context-specific credential
|
||||||
},
|
},
|
||||||
Allowlists: []config.Allowlist{
|
Allowlists: []*config.Allowlist{
|
||||||
{
|
{
|
||||||
Regexes: []*regexp.Regexp{
|
Regexes: []*regexp.Regexp{
|
||||||
regexp.MustCompile(`.+EXAMPLE$`),
|
regexp.MustCompile(`.+EXAMPLE$`),
|
||||||
@@ -33,14 +32,12 @@ func AWS() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("AWS", "AKIALALEMEL33243OLIB") // gitleaks:allow
|
||||||
utils.GenerateSampleSecret("AWS", "AKIALALEMEL33243OLIB"), // gitleaks:allow
|
// current AWS tokens cannot contain [0,1,8,9], so their entropy is slightly lower than expected.
|
||||||
// current AWS tokens cannot contain [0,1,8,9], so their entropy is slightly lower than expected.
|
tps = append(tps, utils.GenerateSampleSecrets("AWS", "AKIA"+secrets.NewSecret("[A-Z2-7]{16}"))...)
|
||||||
utils.GenerateSampleSecret("AWS", "AKIA"+secrets.NewSecret("[A-Z2-7]{16}")),
|
tps = append(tps, utils.GenerateSampleSecrets("AWS", "ASIA"+secrets.NewSecret("[A-Z2-7]{16}"))...)
|
||||||
utils.GenerateSampleSecret("AWS", "ASIA"+secrets.NewSecret("[A-Z2-7]{16}")),
|
tps = append(tps, utils.GenerateSampleSecrets("AWS", "ABIA"+secrets.NewSecret("[A-Z2-7]{16}"))...)
|
||||||
utils.GenerateSampleSecret("AWS", "ABIA"+secrets.NewSecret("[A-Z2-7]{16}")),
|
tps = append(tps, utils.GenerateSampleSecrets("AWS", "ACCA"+secrets.NewSecret("[A-Z2-7]{16}"))...)
|
||||||
utils.GenerateSampleSecret("AWS", "ACCA"+secrets.NewSecret("[A-Z2-7]{16}")),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
`key = AKIAXXXXXXXXXXXXXXXX`, // Low entropy
|
`key = AKIAXXXXXXXXXXXXXXXX`, // Low entropy
|
||||||
`aws_access_key: AKIAIOSFODNN7EXAMPLE`, // Placeholder
|
`aws_access_key: AKIAIOSFODNN7EXAMPLE`, // Placeholder
|
||||||
@@ -50,3 +47,63 @@ func AWS() *config.Rule {
|
|||||||
}
|
}
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AmazonBedrockAPIKeyLongLived() *config.Rule {
|
||||||
|
// https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-how.html
|
||||||
|
// https://medium.com/@adan.alvarez/api-keys-for-bedrock-a-brief-security-overview-2133ed9a2b3f
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "aws-amazon-bedrock-api-key-long-lived",
|
||||||
|
Description: "Identified a pattern that may indicate long-lived Amazon Bedrock API keys, risking unauthorized Amazon Bedrock usage",
|
||||||
|
Regex: utils.GenerateUniqueTokenRegex(`ABSK[A-Za-z0-9+/]{109,269}={0,2}`, false),
|
||||||
|
Entropy: 3,
|
||||||
|
Keywords: []string{
|
||||||
|
"ABSK", // Amazon Bedrock API Key (long-lived)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
// Valid API key example
|
||||||
|
"ABSKQmVkcm9ja0FQSUtleS1EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXM=",
|
||||||
|
// Generate additional random test keys
|
||||||
|
utils.GenerateSampleSecret("bedrock", "ABSKQmVkcm9ja0FQSUtleS1"+secrets.NewSecret(utils.AlphaNumeric("108"))+"="),
|
||||||
|
utils.GenerateSampleSecret("bedrock", "ABSKQmVkcm9ja0FQSUtleS1"+secrets.NewSecret(utils.AlphaNumeric("246"))),
|
||||||
|
}
|
||||||
|
|
||||||
|
fps := []string{
|
||||||
|
// Too short key (missing characters)
|
||||||
|
"ABSKQmVkcm9ja0FQSUtleS1EXAMPLE",
|
||||||
|
// Too long
|
||||||
|
"ABSKQmVkcm9ja0FQSUtleS1EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLE=",
|
||||||
|
// Wrong prefix
|
||||||
|
"AXSKQmVkcm9ja0FQSUtleS1EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLEEXM=",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
|
func AmazonBedrockAPIKeyShortLived() *config.Rule {
|
||||||
|
// https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys-how.html
|
||||||
|
// https://github.com/aws/aws-bedrock-token-generator-js/blob/86277e1489354192c64ffc8f995601daacc1f715/src/token.ts#L21
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "aws-amazon-bedrock-api-key-short-lived",
|
||||||
|
Description: "Identified a pattern that may indicate short-lived Amazon Bedrock API keys, risking unauthorized Amazon Bedrock usage",
|
||||||
|
Regex: regexp.MustCompile(`bedrock-api-key-YmVkcm9jay5hbWF6b25hd3MuY29t`),
|
||||||
|
Entropy: 3,
|
||||||
|
Keywords: []string{
|
||||||
|
"bedrock-api-key-", // Amazon Bedrock API Key (short lived)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("AmazonBedrockAPIKeyShortLived", `bedrock-api-key-YmVkcm9jay5hbWF6b25hd3MuY29t`)
|
||||||
|
|
||||||
|
fps := []string{
|
||||||
|
// Too short key (missing characters)
|
||||||
|
"bedrock-api-key-",
|
||||||
|
// Wrong prefix
|
||||||
|
"bedrock-api-key-YmVkcm9jay5hbWF6b25hd3MuY29x",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -2,11 +2,11 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
|
||||||
"regexp"
|
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// References:
|
// References:
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ func Beamer() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("beamer", "b_"+secrets.NewSecret(utils.AlphaNumericExtended("44")))
|
||||||
utils.GenerateSampleSecret("beamer", "b_"+secrets.NewSecret(utils.AlphaNumericExtended("44"))),
|
fps := []string{
|
||||||
|
`│ ├── R21A-A-V010SP13RC181024R16900-CN-B_250K-Release-OTA-97B6C6C59241976086FABDC41472150C.bfu`,
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,7 @@ func BitBucketClientID() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("bitbucket", secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
utils.GenerateSampleSecret("bitbucket", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,8 +31,6 @@ func BitBucketClientSecret() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("bitbucket", secrets.NewSecret(utils.AlphaNumeric("64")))
|
||||||
utils.GenerateSampleSecret("bitbucket", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,7 @@ func BittrexAccessKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("bittrex", secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
utils.GenerateSampleSecret("bittrex", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,8 +31,6 @@ func BittrexSecretKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("bittrex", secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
utils.GenerateSampleSecret("bittrex", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ClickHouseCloud() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "clickhouse-cloud-api-secret-key",
|
||||||
|
Description: "Identified a pattern that may indicate clickhouse cloud API secret key, risking unauthorized clickhouse cloud api access and data breaches on ClickHouse Cloud platforms.",
|
||||||
|
Regex: regexp.MustCompile(`\b(4b1d[A-Za-z0-9]{38})\b`),
|
||||||
|
Entropy: 3,
|
||||||
|
Keywords: []string{
|
||||||
|
"4b1d", // Prefix
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("ClickHouse", "4b1dbRdW3rOcB7xLthrM4BTBGK1qPLkHigpN1bXD6z")
|
||||||
|
tps = append(tps, utils.GenerateSampleSecrets("ClickHouse", "4b1d"+secrets.NewSecret("[A-Za-z0-9]{38}"))...)
|
||||||
|
fps := []string{
|
||||||
|
`key = 4b1dXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`, // Low entropy
|
||||||
|
`key = adf4b1dbRdW3rOcB7xLthrM4BTBGK1qPLkHigpN1bXD6z`, // Not start of a word
|
||||||
|
}
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Clojars() *config.Rule {
|
func Clojars() *config.Rule {
|
||||||
@@ -19,8 +18,6 @@ func Clojars() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("clojars", "CLOJARS_"+secrets.NewSecret(utils.AlphaNumeric("60")))
|
||||||
utils.GenerateSampleSecret("clojars", "CLOJARS_"+secrets.NewSecret(utils.AlphaNumeric("60"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,7 +36,8 @@ func CloudflareGlobalAPIKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := global_keys
|
tps := utils.GenerateSampleSecrets("cloudflare", secrets.NewSecret(utils.Hex("37")))
|
||||||
|
tps = append(tps, global_keys...)
|
||||||
fps := append(api_keys, origin_ca_keys...)
|
fps := append(api_keys, origin_ca_keys...)
|
||||||
|
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
@@ -52,7 +54,8 @@ func CloudflareAPIKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := api_keys
|
tps := utils.GenerateSampleSecrets("cloudflare", secrets.NewSecret(utils.AlphaNumericExtendedShort("40")))
|
||||||
|
tps = append(tps, api_keys...)
|
||||||
fps := append(global_keys, origin_ca_keys...)
|
fps := append(global_keys, origin_ca_keys...)
|
||||||
|
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
@@ -70,7 +73,8 @@ func CloudflareOriginCAKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := origin_ca_keys
|
tps := utils.GenerateSampleSecrets("cloudflare", "v1.0-aaa334dc886f30631ba0a610-0d98ef66290d7e50aac7c27b5986c99e6f3f1084c881d8ac0eae5de1d1aa0644076ff57022069b3237d19afe60ad045f207ef2b16387ee37b749441b2ae2e9ebe5b4606e846475d4a5")
|
||||||
|
tps = append(tps, origin_ca_keys...)
|
||||||
fps := append(global_keys, api_keys...)
|
fps := append(global_keys, api_keys...)
|
||||||
|
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ func CodecovAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("codecov", secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
utils.GenerateSampleSecret("codecov", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -19,9 +19,6 @@ func CoinbaseAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("coinbase", secrets.NewSecret(utils.AlphaNumericExtendedShort("64")))
|
||||||
utils.GenerateSampleSecret("coinbase",
|
|
||||||
secrets.NewSecret(utils.AlphaNumericExtendedShort("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,10 @@
|
|||||||
# If you would like to contribute new rules, please use
|
# If you would like to contribute new rules, please use
|
||||||
# cmd/generate/config/main.go and follow the contributing guidelines
|
# cmd/generate/config/main.go and follow the contributing guidelines
|
||||||
# at https://github.com/gitleaks/gitleaks/blob/master/CONTRIBUTING.md
|
# at https://github.com/gitleaks/gitleaks/blob/master/CONTRIBUTING.md
|
||||||
|
#
|
||||||
|
# How the hell does secret scanning work? Read this:
|
||||||
|
# https://lookingatcomputer.substack.com/p/regex-is-almost-all-you-need
|
||||||
|
#
|
||||||
# This is the default gitleaks configuration file.
|
# This is the default gitleaks configuration file.
|
||||||
# Rules and allowlists are defined within this file.
|
# Rules and allowlists are defined within this file.
|
||||||
# Rules instruct gitleaks on what should be considered a secret.
|
# Rules instruct gitleaks on what should be considered a secret.
|
||||||
@@ -10,26 +13,33 @@
|
|||||||
|
|
||||||
title = "{{.Title}}"
|
title = "{{.Title}}"
|
||||||
|
|
||||||
[allowlist]
|
# minVersion indicates the minimum Gitleaks version required to use this config.
|
||||||
description = "{{.Allowlist.Description}}"
|
# If the running version is older, a warning will be logged and not all
|
||||||
{{- with .Allowlist.RegexTarget }}
|
# config-enabled features are guaranteed to work.
|
||||||
regexTarget = "{{ . }}"{{ end -}}
|
minVersion = "v8.25.0"
|
||||||
{{- with .Allowlist.Regexes }}
|
|
||||||
regexes = [{{ range $i, $regex := . }}
|
{{ with .Allowlists }}{{ range $i, $allowlist := . }}{{ if or $allowlist.Regexes $allowlist.Paths $allowlist.Commits $allowlist.StopWords }}# TODO: change to [[allowlists]]{{println}}[allowlist]
|
||||||
'''{{ $regex }}''',{{ end }}
|
{{- with .Description }}{{println}}description = "{{ . }}"{{ end }}
|
||||||
|
{{- with .MatchCondition }}{{println}}condition = "{{ .String }}"{{ end }}
|
||||||
|
{{- with .Commits -}}{{println}}commits = [
|
||||||
|
{{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
|
||||||
]{{ end }}
|
]{{ end }}
|
||||||
{{- with .Allowlist.Paths }}
|
{{- with .Paths }}{{println}}paths = [{{ range $j, $path := . }}
|
||||||
paths = [{{ range $i, $path := . }}
|
|
||||||
'''{{ $path }}''',{{ end }}
|
'''{{ $path }}''',{{ end }}
|
||||||
]{{ end }}
|
]{{ end }}
|
||||||
{{- with .Allowlist.StopWords }}{{println}}stopwords = [{{ range $j, $stopword := . }}
|
{{- if and .RegexTarget .Regexes }}{{println}}regexTarget = "{{ .RegexTarget }}"{{ end -}}
|
||||||
"{{ $stopword }}",{{ end }}
|
{{- with .Regexes }}{{println}}regexes = [{{ range $i, $regex := . }}
|
||||||
|
'''{{ $regex }}''',{{ end }}
|
||||||
]{{ end }}
|
]{{ end }}
|
||||||
|
{{- with .StopWords }}{{println}}stopwords = [{{ range $j, $stopword := . }}
|
||||||
|
"{{ $stopword }}",{{ end }}
|
||||||
|
]{{ end }}{{ end }}{{ end }}{{ end }}{{println}}
|
||||||
|
|
||||||
{{ range $i, $rule := .Rules }}[[rules]]
|
{{- range $i, $rule := .Rules }}{{println}}[[rules]]
|
||||||
id = "{{$rule.RuleID}}"
|
id = "{{$rule.RuleID}}"
|
||||||
description = "{{$rule.Description}}"
|
description = "{{$rule.Description}}"
|
||||||
regex = '''{{$rule.Regex}}'''
|
{{- with $rule.Regex }}
|
||||||
|
regex = '''{{ . }}'''{{ end -}}
|
||||||
{{- with $rule.Path }}
|
{{- with $rule.Path }}
|
||||||
path = '''{{ . }}'''{{ end -}}
|
path = '''{{ . }}'''{{ end -}}
|
||||||
{{- with $rule.SecretGroup }}
|
{{- with $rule.SecretGroup }}
|
||||||
@@ -46,16 +56,9 @@ keywords = [{{ range $j, $keyword := . }}"{{ $keyword }}"{{ end }}]{{end}}{{ end
|
|||||||
tags = [
|
tags = [
|
||||||
{{ range $j, $tag := . }}"{{ $tag }}",{{ end }}
|
{{ range $j, $tag := . }}"{{ $tag }}",{{ end }}
|
||||||
]{{ end }}
|
]{{ end }}
|
||||||
|
{{- with $rule.Allowlists }}{{ range $i, $allowlist := . }}{{ if or $allowlist.Regexes $allowlist.Paths $allowlist.Commits $allowlist.StopWords }}{{println}}[[rules.allowlists]]
|
||||||
{{- /*
|
{{- with .Description }}{{println}}description = "{{ . }}"{{ end }}
|
||||||
* Use [rules.allowlist] for a while, allow people to catch up with the new syntax.
|
{{- with .MatchCondition }}{{println}}condition = "{{ .String }}"{{ end }}
|
||||||
* TODO: Remove this a few major versions after 8.21.0
|
|
||||||
* https://github.com/gitleaks/gitleaks/issues/1571
|
|
||||||
*/}}
|
|
||||||
{{- if eq (len $rule.Allowlists) 1 }}{{ with index $rule.Allowlists 0}}{{ if or .Regexes .Paths .Commits .StopWords }}
|
|
||||||
# NOTE: Gitleaks >= v8.21.0 should use [[rules.allowlists] instead.
|
|
||||||
[rules.allowlist]
|
|
||||||
{{- with .MatchCondition }}{{println}}condition = "{{ .MatchCondition.String }}"{{ end }}
|
|
||||||
{{- with .Commits -}}{{println}}commits = [
|
{{- with .Commits -}}{{println}}commits = [
|
||||||
{{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
|
{{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
|
||||||
]{{ end }}
|
]{{ end }}
|
||||||
@@ -68,25 +71,5 @@ tags = [
|
|||||||
]{{ end }}
|
]{{ end }}
|
||||||
{{- with .StopWords }}{{println}}stopwords = [{{ range $j, $stopword := . }}
|
{{- with .StopWords }}{{println}}stopwords = [{{ range $j, $stopword := . }}
|
||||||
"{{ $stopword }}",{{ end }}
|
"{{ $stopword }}",{{ end }}
|
||||||
]{{ end }}{{ end }}{{ end }}
|
]{{ end }}{{ end }}{{ end }}{{ end }}
|
||||||
{{ else }}
|
{{ end }}
|
||||||
{{ with $rule.Allowlists }}{{ range $i, $allowlist := . }}{{ if or $allowlist.Regexes $allowlist.Paths $allowlist.Commits $allowlist.StopWords }}
|
|
||||||
[[rules.allowlists]]
|
|
||||||
{{ with $allowlist.MatchCondition }}condition = "{{ .String }}"
|
|
||||||
{{ end -}}
|
|
||||||
{{- with $allowlist.Commits }}commits = [
|
|
||||||
{{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
|
|
||||||
]{{ end }}
|
|
||||||
{{- with $allowlist.Paths }}paths = [
|
|
||||||
{{ range $j, $path := . }}'''{{ $path }}''',{{ end }}
|
|
||||||
]{{ end }}
|
|
||||||
{{- with $allowlist.RegexTarget }}regexTarget = "{{ . }}"
|
|
||||||
{{ end -}}
|
|
||||||
{{- with $allowlist.Regexes }}regexes = [{{ range $i, $regex := . }}
|
|
||||||
'''{{ $regex }}''',{{ end }}
|
|
||||||
]{{ end }}
|
|
||||||
{{ with $allowlist.StopWords }}stopwords = [{{ range $j, $stopword := . }}
|
|
||||||
"{{ $stopword }}",{{ end }}
|
|
||||||
]{{ end }}{{ end }}{{ end }}
|
|
||||||
{{ end }}{{ end }}
|
|
||||||
{{ end -}}
|
|
||||||
@@ -18,9 +18,7 @@ func ConfluentSecretKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("confluent", secrets.NewSecret(utils.AlphaNumeric("64")))
|
||||||
utils.GenerateSampleSecret("confluent", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +35,6 @@ func ConfluentAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("confluent", secrets.NewSecret(utils.AlphaNumeric("16")))
|
||||||
utils.GenerateSampleSecret("confluent", secrets.NewSecret(utils.AlphaNumeric("16"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,6 @@ func Contentful() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("contentful", secrets.NewSecret(utils.AlphaNumeric("43")))
|
||||||
utils.GenerateSampleSecret("contentful", secrets.NewSecret(utils.AlphaNumeric("43"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,29 +2,29 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
|
||||||
"regexp"
|
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://curl.se/docs/manpage.html#-u
|
// https://curl.se/docs/manpage.html#-u
|
||||||
func CurlBasicAuth() *config.Rule {
|
func CurlBasicAuth() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "curl-auth-user",
|
RuleID: "curl-auth-user",
|
||||||
// TODO: Description: "",
|
Description: "Discovered a potential basic authorization token provided in a curl command, which could compromise the curl accessed resource.",
|
||||||
Regex: regexp.MustCompile(`\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})(?:"([^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)`),
|
Regex: regexp.MustCompile(`\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})("(:[^"]{3,}|[^:"]{3,}:|[^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)`),
|
||||||
Keywords: []string{"curl"},
|
Keywords: []string{"curl"},
|
||||||
Entropy: 2,
|
Entropy: 2,
|
||||||
Allowlists: []config.Allowlist{
|
Allowlists: []*config.Allowlist{
|
||||||
{
|
{
|
||||||
Regexes: []*regexp.Regexp{
|
Regexes: []*regexp.Regexp{
|
||||||
regexp.MustCompile(`[^:]+:(change(it|me)|pass(word)?|pwd|test|token|\*+|x+)`), // common placeholder passwords
|
regexp.MustCompile(`[^:]+:(?:change(?:it|me)|pass(?:word)?|pwd|test|token|\*+|x+)`), // common placeholder passwords
|
||||||
regexp.MustCompile(`['"]?<[^>]+>['"]?:['"]?<[^>]+>|<[^:]+:[^>]+>['"]?`), // <placeholder>
|
regexp.MustCompile(`['"]?<[^>]+>['"]?:['"]?<[^>]+>|<[^:]+:[^>]+>['"]?`), // <placeholder>
|
||||||
regexp.MustCompile(`[^:]+:\[[^]]+]`), // [placeholder]
|
regexp.MustCompile(`[^:]+:\[[^]]+]`), // [placeholder]
|
||||||
regexp.MustCompile(`['"]?[^:]+['"]?:['"]?\$(\d|\w+|\{(\d|\w+)})['"]?`), // $1 or $VARIABLE
|
regexp.MustCompile(`['"]?[^:]+['"]?:['"]?\$(?:\d|\w+|\{(?:\d|\w+)})['"]?`), // $1 or $VARIABLE
|
||||||
regexp.MustCompile(`\$\([^)]+\):\$\([^)]+\)`), // $(cat login.txt)
|
regexp.MustCompile(`\$\([^)]+\):\$\([^)]+\)`), // $(cat login.txt)
|
||||||
regexp.MustCompile(`['"]?\$?{{[^}]+}}['"]?:['"]?\$?{{[^}]+}}['"]?`), // ${{ secrets.FOO }} or {{ .Values.foo }}
|
regexp.MustCompile(`['"]?\$?{{[^}]+}}['"]?:['"]?\$?{{[^}]+}}['"]?`), // ${{ secrets.FOO }} or {{ .Values.foo }}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -38,6 +38,8 @@ func CurlBasicAuth() *config.Rule {
|
|||||||
-H 'Content-type: text/plain' \
|
-H 'Content-type: text/plain' \
|
||||||
-d 'world' \
|
-d 'world' \
|
||||||
-u developer:yqDVtkqPECriaLRi`, // different line
|
-u developer:yqDVtkqPECriaLRi`, // different line
|
||||||
|
`curl -u ":d2LkV78zLx!t" https://localhost:9200`, // empty username
|
||||||
|
`curl -u "d2LkV78zLx!t:" https://localhost:9200`, // empty password
|
||||||
|
|
||||||
// long
|
// long
|
||||||
`curl -sw '%{http_code}' -X POST --user 'johns:h0pk1ns~21s' $GItHUB_API_URL/$GIT_COMMIT --data`,
|
`curl -sw '%{http_code}' -X POST --user 'johns:h0pk1ns~21s' $GItHUB_API_URL/$GIT_COMMIT --data`,
|
||||||
@@ -65,6 +67,7 @@ func CurlBasicAuth() *config.Rule {
|
|||||||
`curl -u "${_username}:${_password}"`,
|
`curl -u "${_username}:${_password}"`,
|
||||||
`curl -u "${username}":"${password}"`,
|
`curl -u "${username}":"${password}"`,
|
||||||
`curl -k -X POST -I -u "SRVC_JENKINS:${APPID}"`,
|
`curl -k -X POST -I -u "SRVC_JENKINS:${APPID}"`,
|
||||||
|
`curl -u ":" https://localhost:9200`, // empty username and password
|
||||||
|
|
||||||
// long
|
// long
|
||||||
`curl -sw '%{http_code}' -X POST --user '$USERNAME:$PASSWORD' $GItHUB_API_URL/$GIT_COMMIT --data`,
|
`curl -sw '%{http_code}' -X POST --user '$USERNAME:$PASSWORD' $GItHUB_API_URL/$GIT_COMMIT --data`,
|
||||||
@@ -99,14 +102,14 @@ func CurlHeaderAuth() *config.Rule {
|
|||||||
// language=regexp
|
// language=regexp
|
||||||
authPat := `(?i)(?:Authorization:[ \t]{0,5}(?:Basic[ \t]([a-z0-9+/]{8,}={0,3})|(?:Bearer|(?:Api-)?Token)[ \t]([\w=~@.+/-]{8,})|([\w=~@.+/-]{8,}))|(?:(?:X-(?:[a-z]+-)?)?(?:Api-?)?(?:Key|Token)):[ \t]{0,5}([\w=~@.+/-]{8,}))`
|
authPat := `(?i)(?:Authorization:[ \t]{0,5}(?:Basic[ \t]([a-z0-9+/]{8,}={0,3})|(?:Bearer|(?:Api-)?Token)[ \t]([\w=~@.+/-]{8,})|([\w=~@.+/-]{8,}))|(?:(?:X-(?:[a-z]+-)?)?(?:Api-?)?(?:Key|Token)):[ \t]{0,5}([\w=~@.+/-]{8,}))`
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "curl-auth-header",
|
RuleID: "curl-auth-header",
|
||||||
// TODO: Description: "",
|
Description: "Discovered a potential authorization token provided in a curl command header, which could compromise the curl accessed resource.",
|
||||||
Regex: regexp.MustCompile(
|
Regex: regexp.MustCompile(
|
||||||
// language=regexp
|
// language=regexp
|
||||||
fmt.Sprintf(`\bcurl\b(?:.*?|.*?(?:[\r\n]{1,2}.*?){1,5})[ \t\n\r](?:-H|--header)(?:=|[ \t]{0,5})(?:"%s"|'%s')(?:\B|\s|\z)`, authPat, authPat)),
|
fmt.Sprintf(`\bcurl\b(?:.*?|.*?(?:[\r\n]{1,2}.*?){1,5})[ \t\n\r](?:-H|--header)(?:=|[ \t]{0,5})(?:"%s"|'%s')(?:\B|\s|\z)`, authPat, authPat)),
|
||||||
Entropy: 2.75,
|
Entropy: 2.75,
|
||||||
Keywords: []string{"curl"},
|
Keywords: []string{"curl"},
|
||||||
//Allowlists: []config.Allowlist{
|
//Allowlists: []*config.Allowlist{
|
||||||
// {
|
// {
|
||||||
// Regexes: []*regexp.Regexp{},
|
// Regexes: []*regexp.Regexp{},
|
||||||
// },
|
// },
|
||||||
|
|||||||
@@ -17,10 +17,8 @@ func Databricks() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("databricks", "dapi"+secrets.NewSecret(utils.Hex("32")))
|
||||||
utils.GenerateSampleSecret("databricks", "dapi"+secrets.NewSecret(utils.Hex("32"))),
|
tps = append(tps, `token = dapif13ac4b49d1cb31f69f678e39602e381-2`) // gitleaks:ignore
|
||||||
`token = dapif13ac4b49d1cb31f69f678e39602e381-2`, // gitleaks:ignore
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
`DATABRICKS_TOKEN=dapi123456789012345678a9bc01234defg5`,
|
`DATABRICKS_TOKEN=dapi123456789012345678a9bc01234defg5`,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ func DatadogtokenAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("datadog", secrets.NewSecret(utils.AlphaNumeric("40")))
|
||||||
utils.GenerateSampleSecret("datadog", secrets.NewSecret(utils.AlphaNumeric("40"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,6 @@ func DefinedNetworkingAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("dnkey", "dnkey-"+secrets.NewSecret(utils.AlphaNumericExtended("26"))+"-"+secrets.NewSecret(utils.AlphaNumericExtended("52")))
|
||||||
utils.GenerateSampleSecret("dnkey", "dnkey-"+secrets.NewSecret(utils.AlphaNumericExtended("26"))+"-"+secrets.NewSecret(utils.AlphaNumericExtended("52"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -15,9 +15,7 @@ func DigitalOceanPAT() *config.Rule {
|
|||||||
Keywords: []string{"dop_v1_"},
|
Keywords: []string{"dop_v1_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("do", "dop_v1_"+secrets.NewSecret(utils.Hex("64")))
|
||||||
utils.GenerateSampleSecret("do", "dop_v1_"+secrets.NewSecret(utils.Hex("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,9 +28,7 @@ func DigitalOceanOAuthToken() *config.Rule {
|
|||||||
Keywords: []string{"doo_v1_"},
|
Keywords: []string{"doo_v1_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("do", "doo_v1_"+secrets.NewSecret(utils.Hex("64")))
|
||||||
utils.GenerateSampleSecret("do", "doo_v1_"+secrets.NewSecret(utils.Hex("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,8 +41,6 @@ func DigitalOceanRefreshToken() *config.Rule {
|
|||||||
Keywords: []string{"dor_v1_"},
|
Keywords: []string{"dor_v1_"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("do", "dor_v1_"+secrets.NewSecret(utils.Hex("64")))
|
||||||
utils.GenerateSampleSecret("do", "dor_v1_"+secrets.NewSecret(utils.Hex("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,7 @@ func DiscordAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("discord", secrets.NewSecret(utils.Hex("64")))
|
||||||
utils.GenerateSampleSecret("discord", secrets.NewSecret(utils.Hex("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,9 +31,7 @@ func DiscordClientID() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("discord", secrets.NewSecret(utils.Numeric("18")))
|
||||||
utils.GenerateSampleSecret("discord", secrets.NewSecret(utils.Numeric("18"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
// Low entropy
|
// Low entropy
|
||||||
`discord=000000000000000000`,
|
`discord=000000000000000000`,
|
||||||
@@ -54,9 +50,7 @@ func DiscordClientSecret() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("discord", secrets.NewSecret(utils.Numeric("32")))
|
||||||
utils.GenerateSampleSecret("discord", secrets.NewSecret(utils.Numeric("32"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
// Low entropy
|
// Low entropy
|
||||||
`discord=00000000000000000000000000000000`,
|
`discord=00000000000000000000000000000000`,
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Doppler() *config.Rule {
|
func Doppler() *config.Rule {
|
||||||
@@ -19,9 +18,7 @@ func Doppler() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("doppler", "dp.pt."+secrets.NewSecret(utils.AlphaNumeric("43")))
|
||||||
utils.GenerateSampleSecret("doppler", "dp.pt."+secrets.NewSecret(utils.AlphaNumeric("43"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ func DroneciAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("droneci", secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
utils.GenerateSampleSecret("droneci", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -17,9 +17,7 @@ func DropBoxAPISecret() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("dropbox", secrets.NewSecret(utils.AlphaNumeric("15")))
|
||||||
utils.GenerateSampleSecret("dropbox", secrets.NewSecret(utils.AlphaNumeric("15"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Duffel() *config.Rule {
|
func Duffel() *config.Rule {
|
||||||
@@ -19,8 +18,6 @@ func Duffel() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("duffel", "duffel_test_"+secrets.NewSecret(utils.AlphaNumericExtended("43")))
|
||||||
utils.GenerateSampleSecret("duffel", "duffel_test_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Dynatrace() *config.Rule {
|
func Dynatrace() *config.Rule {
|
||||||
@@ -15,12 +14,10 @@ func Dynatrace() *config.Rule {
|
|||||||
Description: "Detected a Dynatrace API token, potentially risking application performance monitoring and data exposure.",
|
Description: "Detected a Dynatrace API token, potentially risking application performance monitoring and data exposure.",
|
||||||
Regex: regexp.MustCompile(`dt0c01\.(?i)[a-z0-9]{24}\.[a-z0-9]{64}`),
|
Regex: regexp.MustCompile(`dt0c01\.(?i)[a-z0-9]{24}\.[a-z0-9]{64}`),
|
||||||
Entropy: 4,
|
Entropy: 4,
|
||||||
Keywords: []string{"dt0c01"},
|
Keywords: []string{"dt0c01."},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("dynatrace", "dt0c01."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("64")))
|
||||||
utils.GenerateSampleSecret("dynatrace", "dt0c01."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func EasyPost() *config.Rule {
|
func EasyPost() *config.Rule {
|
||||||
@@ -13,16 +12,22 @@ func EasyPost() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "easypost-api-token",
|
RuleID: "easypost-api-token",
|
||||||
Description: "Identified an EasyPost API token, which could lead to unauthorized postal and shipment service access and data exposure.",
|
Description: "Identified an EasyPost API token, which could lead to unauthorized postal and shipment service access and data exposure.",
|
||||||
Regex: regexp.MustCompile(`\bEZAK(?i)[a-z0-9]{54}`),
|
Regex: regexp.MustCompile(`\bEZAK(?i)[a-z0-9]{54}\b`),
|
||||||
Entropy: 2,
|
Entropy: 2,
|
||||||
Keywords: []string{"EZAK"},
|
Keywords: []string{"EZAK"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("EZAK", "EZAK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`))
|
||||||
utils.GenerateSampleSecret("EZAK", "EZAK"+secrets.NewSecret(utils.AlphaNumeric("54"))),
|
tps = append(tps,
|
||||||
|
"EZAK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`),
|
||||||
|
"example.com?t=EZAK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`)+"&q=1",
|
||||||
|
)
|
||||||
|
fps := []string{
|
||||||
|
// random base64 encoded string
|
||||||
|
`...6wqX6fNUXA/rYqRvfQ+EZAKGqQRiRyqAFRQshGPWOIAwNWGORfKHSBnVNFtVmWYoW6PH23lkqbbDWep95C/3VmWq/edti6...`, // gitleaks:allow
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EasyPostTestAPI() *config.Rule {
|
func EasyPostTestAPI() *config.Rule {
|
||||||
@@ -30,14 +35,21 @@ func EasyPostTestAPI() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "easypost-test-api-token",
|
RuleID: "easypost-test-api-token",
|
||||||
Description: "Detected an EasyPost test API token, risking exposure of test environments and potentially sensitive shipment data.",
|
Description: "Detected an EasyPost test API token, risking exposure of test environments and potentially sensitive shipment data.",
|
||||||
Regex: regexp.MustCompile(`\bEZTK(?i)[a-z0-9]{54}`),
|
Regex: regexp.MustCompile(`\bEZTK(?i)[a-z0-9]{54}\b`),
|
||||||
Entropy: 2,
|
Entropy: 2,
|
||||||
Keywords: []string{"EZTK"},
|
Keywords: []string{"EZTK"},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("EZTK", secrets.NewSecret(`EZTK[a-zA-Z0-9]{54}`))
|
||||||
utils.GenerateSampleSecret("EZTK", "EZTK"+secrets.NewSecret(utils.AlphaNumeric("54"))),
|
tps = append(tps, secrets.NewSecret(`EZTK[a-zA-Z0-9]{54}`))
|
||||||
|
tps = append(tps,
|
||||||
|
"EZTK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`),
|
||||||
|
"example.com?t=EZTK"+secrets.NewSecret(`[a-zA-Z0-9]{54}`)+"&q=1",
|
||||||
|
)
|
||||||
|
fps := []string{
|
||||||
|
// random base64 encoded string
|
||||||
|
`...6wqX6fNUXA/rYqRvfQ+EZTKGqQRiRyqAFRQshGPWOIAwNWGORfKHSBnVNFtVmWYoW6PH23lkqbbDWep95C/3VmWq/edti6...`, // gitleaks:allow
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
@@ -20,11 +21,9 @@ func EtsyAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("ETSY", secrets.NewSecret(utils.AlphaNumeric("24")))
|
||||||
utils.GenerateSampleSecret("ETSY", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
tps = append(tps, utils.GenerateSampleSecrets("etsy", secrets.NewSecret(utils.AlphaNumeric("24")))...)
|
||||||
utils.GenerateSampleSecret("etsy", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
tps = append(tps, utils.GenerateSampleSecrets("Etsy", secrets.NewSecret(utils.AlphaNumeric("24")))...)
|
||||||
utils.GenerateSampleSecret("Etsy", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
fmt.Sprintf(`SetSysctl = "%s"`, secrets.NewSecret(utils.AlphaNumeric("24"))),
|
fmt.Sprintf(`SetSysctl = "%s"`, secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||||
` if err := sysctl.SetSysctl(sysctlBridgeCallIPTables); err != nil {`,
|
` if err := sysctl.SetSysctl(sysctlBridgeCallIPTables); err != nil {`,
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ func FacebookSecret() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("facebook", secrets.NewSecret(utils.Hex("32")))
|
||||||
utils.GenerateSampleSecret("facebook", secrets.NewSecret(utils.Hex("32"))),
|
tps = append(tps,
|
||||||
`facebook_app_secret = "6dca6432e45d933e13650d1882bd5e69"`, // gitleaks:allow
|
`facebook_app_secret = "6dca6432e45d933e13650d1882bd5e69"`, // gitleaks:allow
|
||||||
`facebook_client_access_token: 26f5fd13099f2c1331aafb86f6489692`, // gitleaks:allow
|
`facebook_client_access_token: 26f5fd13099f2c1331aafb86f6489692`, // gitleaks:allow
|
||||||
}
|
)
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,14 +34,15 @@ func FacebookAccessToken() *config.Rule {
|
|||||||
RuleID: "facebook-access-token",
|
RuleID: "facebook-access-token",
|
||||||
Description: "Discovered a Facebook Access Token, posing a risk of unauthorized access to Facebook accounts and personal data exposure.",
|
Description: "Discovered a Facebook Access Token, posing a risk of unauthorized access to Facebook accounts and personal data exposure.",
|
||||||
Regex: utils.GenerateUniqueTokenRegex(`\d{15,16}(\||%)[0-9a-z\-_]{27,40}`, true),
|
Regex: utils.GenerateUniqueTokenRegex(`\d{15,16}(\||%)[0-9a-z\-_]{27,40}`, true),
|
||||||
|
Keywords: []string{"facebook"},
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
`{"access_token":"911602140448729|AY-lRJZq9BoDLobvAiP25L7RcMg","token_type":"bearer"}`, // gitleaks:allow
|
`{"facebook access_token":"911602140448729|AY-lRJZq9BoDLobvAiP25L7RcMg","token_type":"bearer"}`, // gitleaks:allow
|
||||||
`1308742762612587|rhoK1cbv0DOU_RTX_87O4MkX7AI`, // gitleaks:allow
|
`facebook 1308742762612587|rhoK1cbv0DOU_RTX_87O4MkX7AI`, // gitleaks:allow
|
||||||
`1477036645700765|wRPf2v3mt2JfMqCLK8n7oltrEmc`, // gitleaks:allow
|
`facebook 1477036645700765|wRPf2v3mt2JfMqCLK8n7oltrEmc`, // gitleaks:allow
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -52,8 +53,8 @@ func FacebookPageAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "facebook-page-access-token",
|
RuleID: "facebook-page-access-token",
|
||||||
Description: "Discovered a Facebook Page Access Token, posing a risk of unauthorized access to Facebook accounts and personal data exposure.",
|
Description: "Discovered a Facebook Page Access Token, posing a risk of unauthorized access to Facebook accounts and personal data exposure.",
|
||||||
Regex: utils.GenerateUniqueTokenRegex("EAA[MC](?i)"+utils.AlphaNumeric("20,"), false),
|
Regex: utils.GenerateUniqueTokenRegex("EAA[MC](?i)[a-z0-9]{100,}", false),
|
||||||
Entropy: 3,
|
Entropy: 4,
|
||||||
Keywords: []string{"EAAM", "EAAC"},
|
Keywords: []string{"EAAM", "EAAC"},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,10 +63,16 @@ func FacebookPageAccessToken() *config.Rule {
|
|||||||
`EAAM9GOnCB9kBO2frzOAWGN2zMnZClQshlWydZCrBNdodesbwimx1mfVJgqZBP5RSpMfUzWhtjTTXHG5I1UlvlwRZCgjm3ZBVGeTYiqAAoxyED6HaUdhpGVNoPUwAuAWWFsi9OvyYBQt22DGLqMIgD7VktuCTTZCWKasz81Q822FPhMTB9VFFyClNzQ0NLZClt9zxpsMMrUZCo1VU1rL3CKavir5QTfBjfCEzHNlWAUDUV2YZD`, // gitleaks:allow
|
`EAAM9GOnCB9kBO2frzOAWGN2zMnZClQshlWydZCrBNdodesbwimx1mfVJgqZBP5RSpMfUzWhtjTTXHG5I1UlvlwRZCgjm3ZBVGeTYiqAAoxyED6HaUdhpGVNoPUwAuAWWFsi9OvyYBQt22DGLqMIgD7VktuCTTZCWKasz81Q822FPhMTB9VFFyClNzQ0NLZClt9zxpsMMrUZCo1VU1rL3CKavir5QTfBjfCEzHNlWAUDUV2YZD`, // gitleaks:allow
|
||||||
`EAAM9GOnCB9kBO2zXpAtRBmCrsPPjdA3KeBl4tqsEpcYd09cpjm9MZCBIklZBjIQBKGIJgFwm8IE17G5pipsfRBRBEHMWxvJsL7iHLUouiprxKRQfAagw8BEEDucceqxTiDhVW2IZAQNNbf0d1JhcapAGntx5S1Csm4j0GgZB3DuUfI2HJ9aViTtdfH2vjBy0wtpXm2iamevohGfoF4NgyRHusDLjqy91uYMkfrkc`, // gitleaks:allow
|
`EAAM9GOnCB9kBO2zXpAtRBmCrsPPjdA3KeBl4tqsEpcYd09cpjm9MZCBIklZBjIQBKGIJgFwm8IE17G5pipsfRBRBEHMWxvJsL7iHLUouiprxKRQfAagw8BEEDucceqxTiDhVW2IZAQNNbf0d1JhcapAGntx5S1Csm4j0GgZB3DuUfI2HJ9aViTtdfH2vjBy0wtpXm2iamevohGfoF4NgyRHusDLjqy91uYMkfrkc`, // gitleaks:allow
|
||||||
`- name: FACEBOOK_TOKEN
|
`- name: FACEBOOK_TOKEN
|
||||||
value: "EAACEdEose0cBA1bad3afsf2aew"`, // gitleaks:allow
|
value: "EAACEdEose0cBA1bad3afsf286JZCOV1XmV4NobAXqUXZA7U9F1UaaOdQZABvz73030MJoC3gGoQrE8IEoMl4gFA6MmQadlJQBqtRsgIcIhtelIJOJaew"`, // gitleaks:allow
|
||||||
}
|
}
|
||||||
fps := []string{
|
fps := []string{
|
||||||
`eaaaC0b75a9329fded2ffa9a02b47e0117831b82`,
|
`eaaaC0b75a9329fded2ffa9a02b47e0117831b82`,
|
||||||
|
`"strict-uri-encode@npm:^2.0.0":
|
||||||
|
version: 2.0.0
|
||||||
|
resolution: "strict-uri-encode@npm:2.0.0"
|
||||||
|
checksum: eaac4cf978b6fbd480f1092cab8b233c9b949bcabfc9b598dd79a758f7243c28765ef7639c876fa72940dac687181b35486ea01ff7df3e65ce3848c64822c581
|
||||||
|
languageName: node
|
||||||
|
linkType: hard`,
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,6 @@ func FastlyAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("fastly", secrets.NewSecret(utils.AlphaNumericExtended("32")))
|
||||||
utils.GenerateSampleSecret("fastly", secrets.NewSecret(utils.AlphaNumericExtended("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -17,9 +17,7 @@ func FinicityClientSecret() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("finicity", secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("finicity", secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,8 +32,6 @@ func FinicityAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("finicity", secrets.NewSecret(utils.Hex("32")))
|
||||||
utils.GenerateSampleSecret("finicity", secrets.NewSecret(utils.Hex("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -19,8 +19,6 @@ func FinnhubAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("finnhub", secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("finnhub", secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -19,8 +19,6 @@ func FlickrAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("flickr", secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
utils.GenerateSampleSecret("flickr", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FlutterwavePublicKey() *config.Rule {
|
func FlutterwavePublicKey() *config.Rule {
|
||||||
@@ -19,9 +18,7 @@ func FlutterwavePublicKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("flutterwavePubKey", "FLWPUBK_TEST-"+secrets.NewSecret(utils.Hex("32"))+"-X")
|
||||||
utils.GenerateSampleSecret("flutterwavePubKey", "FLWPUBK_TEST-"+secrets.NewSecret(utils.Hex("32"))+"-X"),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,9 +33,7 @@ func FlutterwaveSecretKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(utils.Hex("32"))+"-X")
|
||||||
utils.GenerateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(utils.Hex("32"))+"-X"),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,8 +48,6 @@ func FlutterwaveEncKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(utils.Hex("12")))
|
||||||
utils.GenerateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(utils.Hex("12"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -20,23 +20,26 @@ func FlyIOAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
// fo1_
|
||||||
// fo1_
|
tps := utils.GenerateSampleSecrets("fly", secrets.NewSecret(`fo1_[\w-]{43}`))
|
||||||
utils.GenerateSampleSecret("fly", secrets.NewSecret(`fo1_[\w-]{43}`)),
|
tps = append(tps,
|
||||||
`Fly access token: fo1_8rz-j7r2eqJ2U7affEOO3HJN0j63DInyog3eV-glQSc
|
`Fly access token: fo1_8rz-j7r2eqJ2U7affEOO3HJN0j63DInyog3eV-glQSc
|
||||||
`,
|
`,
|
||||||
`=============================================================================================================
|
`=============================================================================================================
|
||||||
|
|
||||||
fo1_BtKlzvfztw0M2hlLgTdsfPgDFiwM2jJjQXXy6I2pjuQ
|
fo1_BtKlzvfztw0M2hlLgTdsfPgDFiwM2jJjQXXy6I2pjuQ
|
||||||
fly deploy`,
|
fly deploy`)
|
||||||
// fm1
|
// fm1
|
||||||
utils.GenerateSampleSecret("fly", secrets.NewSecret(`fm1[ar]_[a-zA-Z0-9+\/]{100,}={0,3}`)),
|
tps = append(tps, utils.GenerateSampleSecrets("fly", secrets.NewSecret(`fm1[ar]_[a-zA-Z0-9+\/]{100,}={0,3}`))...)
|
||||||
|
tps = append(tps,
|
||||||
`ENV FLY_API_TOKEN="FlyV1 fm1r_lJPECAAAAAAAAMqcxBBLMJKXYKJiT0CI58XmukX/wrVodHlwczovL2FwaS5mbHkuaW8vdjGWAJLOAAFmXh8Lk7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxxDy5OfA2M6K6aLEoEDKxehojbj+8ZT9IrXCF5sL/r8m6/1gylwySsNxpD40wnpd/G2ZdjwVaQev1kEuFUgzERxPbtWHDNa+NYIZwbKN6b7/JxdbUprq0M10HI4fwtlxhqhdA/mMaMw70EC4TsfJyghIL98KP4ry5AaXiroRdjrSsFExc/xRCDZKUA5GBzgATuNsfBZGCp2J1aWxkZXIfondnHwHEIMa6NWc4b52S+UY7vjPdwKrz00Uzrc1830mOHzQNLun7,fm1a_lJPERxPbtWHDNa+NYIZwbKN6b7/JxdbUprq0M10HI4fwtlxhqhdA/mMaMw70EC4TsfJyghIL98KP4ry4AaXiroRdjrSsFExc/xRCxBCVlAoRzKV/+qYkxuipIbIcw7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxlgSSzmS4Y7nPAAAAASCwgdcKkc4AAUktDMQQURck2h+upbiOrW66Nf5SA8QgrD03xlWju1WQi0AUhlk7YYFzOLDfhRyJ6nEziO37NUE="`,
|
`ENV FLY_API_TOKEN="FlyV1 fm1r_lJPECAAAAAAAAMqcxBBLMJKXYKJiT0CI58XmukX/wrVodHlwczovL2FwaS5mbHkuaW8vdjGWAJLOAAFmXh8Lk7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxxDy5OfA2M6K6aLEoEDKxehojbj+8ZT9IrXCF5sL/r8m6/1gylwySsNxpD40wnpd/G2ZdjwVaQev1kEuFUgzERxPbtWHDNa+NYIZwbKN6b7/JxdbUprq0M10HI4fwtlxhqhdA/mMaMw70EC4TsfJyghIL98KP4ry5AaXiroRdjrSsFExc/xRCDZKUA5GBzgATuNsfBZGCp2J1aWxkZXIfondnHwHEIMa6NWc4b52S+UY7vjPdwKrz00Uzrc1830mOHzQNLun7,fm1a_lJPERxPbtWHDNa+NYIZwbKN6b7/JxdbUprq0M10HI4fwtlxhqhdA/mMaMw70EC4TsfJyghIL98KP4ry4AaXiroRdjrSsFExc/xRCxBCVlAoRzKV/+qYkxuipIbIcw7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxlgSSzmS4Y7nPAAAAASCwgdcKkc4AAUktDMQQURck2h+upbiOrW66Nf5SA8QgrD03xlWju1WQi0AUhlk7YYFzOLDfhRyJ6nEziO37NUE="`,
|
||||||
// fm2
|
)
|
||||||
utils.GenerateSampleSecret("fly", secrets.NewSecret(`fm2_[a-zA-Z0-9+\/]{100,}={0,3}`)),
|
// fm2
|
||||||
|
tps = append(tps, utils.GenerateSampleSecrets("fly", secrets.NewSecret(`fm2_[a-zA-Z0-9+\/]{100,}={0,3}`))...)
|
||||||
|
tps = append(tps,
|
||||||
`# FLY_API_TOKEN: FlyV1 fm2_lJPECAAAAAAAAyZtxBD1hSZ7L5leXsj64ZbDlkm/wrVodHRwczovL2FwaS5mbHkuaW8vdjGWAJLOAAwMDB8Lk7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxxDwDnhgJj/ML/nRKMiAYgnvXfNacrGWffj5TdfgGY2LU0ZetT7WzTLQQMO8cN2nRTztl/xLjnnZg5pBwFonETmhNA6Yl0X1tatt8ezA0UjVQiJr93VQ7qAmD5GG2Ce5txhbQv3tmIGsvaC7BOkIqAiR273bhZkO44AYsrCPr2XF8W6Twk7NyU+3UUeDwjw2SlAORgc4APu7vHwWRgqdidWlsZGVyH6J3Zx8BxCAlmLbu1HQDg8ZAGKKmEt4Mbnbqli6lbzBDHsawhcUF4A==,fm2_lJPETmhNA6Yl0X1tatt8ezA0UjVQiJr93VQ7qAmD5GG2Ce5txhbQv3tmIGsvaC7BOkIqAij273bhZkO44AYsrCPr2XF8W6Twk7NyU+3UUeDwj8QQbn07DOV+7SmoLj/uT+dbr8O5aHR0cHM6Ly9hcGkuZmx5LmlvL2FhYS92MZgEks5mqfbvzwAAAAE9PYz9F84AC7QACpHOAAu0AAzEEFfW3B+SzffV/KrAYa8qqpnEIIlD6DqZMZQ9Kt7fEenCCOLA+tUSJ+kmEFIUcc83npOI`,
|
`# FLY_API_TOKEN: FlyV1 fm2_lJPECAAAAAAAAyZtxBD1hSZ7L5leXsj64ZbDlkm/wrVodHRwczovL2FwaS5mbHkuaW8vdjGWAJLOAAwMDB8Lk7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxxDwDnhgJj/ML/nRKMiAYgnvXfNacrGWffj5TdfgGY2LU0ZetT7WzTLQQMO8cN2nRTztl/xLjnnZg5pBwFonETmhNA6Yl0X1tatt8ezA0UjVQiJr93VQ7qAmD5GG2Ce5txhbQv3tmIGsvaC7BOkIqAiR273bhZkO44AYsrCPr2XF8W6Twk7NyU+3UUeDwjw2SlAORgc4APu7vHwWRgqdidWlsZGVyH6J3Zx8BxCAlmLbu1HQDg8ZAGKKmEt4Mbnbqli6lbzBDHsawhcUF4A==,fm2_lJPETmhNA6Yl0X1tatt8ezA0UjVQiJr93VQ7qAmD5GG2Ce5txhbQv3tmIGsvaC7BOkIqAij273bhZkO44AYsrCPr2XF8W6Twk7NyU+3UUeDwj8QQbn07DOV+7SmoLj/uT+dbr8O5aHR0cHM6Ly9hcGkuZmx5LmlvL2FhYS92MZgEks5mqfbvzwAAAAE9PYz9F84AC7QACpHOAAu0AAzEEFfW3B+SzffV/KrAYa8qqpnEIIlD6DqZMZQ9Kt7fEenCCOLA+tUSJ+kmEFIUcc83npOI`,
|
||||||
`"BindToParentToken": "FlyV1 fm2_lJPEEKnzKy0lkwV3B+WIlmrdwejEEFv5qmevHU4fMs+2Gr6oOiPC2SAyOTc0NWI4ZmJlNjBlNjJmZTgzNTkxOThhZWE4MjY0M5IMxAMBAgPEIH7VG8u74KwO62hmx8SZO8WaU5o1g3W2IVc7QN6T1VTr",`,
|
`"BindToParentToken": "FlyV1 fm2_lJPEEKnzKy0lkwV3B+WIlmrdwejEEFv5qmevHU4fMs+2Gr6oOiPC2SAyOTc0NWI4ZmJlNjBlNjJmZTgzNTkxOThhZWE4MjY0M5IMxAMBAgPEIH7VG8u74KwO62hmx8SZO8WaU5o1g3W2IVc7QN6T1VTr",`,
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
// fo1_
|
// fo1_
|
||||||
`resource "doppler_integration_flyio" "prod" {
|
`resource "doppler_integration_flyio" "prod" {
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FrameIO() *config.Rule {
|
func FrameIO() *config.Rule {
|
||||||
@@ -18,8 +17,6 @@ func FrameIO() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("frameio", "fio-u-"+secrets.NewSecret(utils.AlphaNumericExtended("64")))
|
||||||
utils.GenerateSampleSecret("frameio", "fio-u-"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Freemius() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "freemius-secret-key",
|
||||||
|
Description: "Detected a Freemius secret key, potentially exposing sensitive information.",
|
||||||
|
Regex: regexp.MustCompile(`(?i)["']secret_key["']\s*=>\s*["'](sk_[\S]{29})["']`),
|
||||||
|
Keywords: []string{"secret_key"},
|
||||||
|
Path: regexp.MustCompile(`(?i)\.php$`),
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := map[string]string{
|
||||||
|
"file.php": `$config = array(
|
||||||
|
"secret_key" => "sk_ubb4yN3mzqGR2x8#P7r5&@*xC$utE",
|
||||||
|
);`,
|
||||||
|
}
|
||||||
|
// It's only used in PHP SDK snippet.
|
||||||
|
// see https://freemius.com/help/documentation/wordpress-sdk/integrating-freemius-sdk/
|
||||||
|
fps := map[string]string{
|
||||||
|
// Invalid format: missing quotes around `secret_key`.
|
||||||
|
"foo.php": `$config = array(
|
||||||
|
secret_key => "sk_abcdefghijklmnopqrstuvwxyz123",
|
||||||
|
);`,
|
||||||
|
// Invalid format: missing quotes around the key value.
|
||||||
|
"bar.php": `$config = array(
|
||||||
|
"secret_key" => sk_abcdefghijklmnopqrstuvwxyz123,
|
||||||
|
);`,
|
||||||
|
// Invalid: different key name.
|
||||||
|
"baz.php": `$config = array(
|
||||||
|
"other_key" => "sk_abcdefghijklmnopqrstuvwxyz123",
|
||||||
|
);`,
|
||||||
|
// Invalid: file extension, should validate only .php files.
|
||||||
|
"foo.html": `$config = array(
|
||||||
|
"secret_key" => "sk_ubb4yN3mzqGR2x8#P7r5&@*xC$utE",
|
||||||
|
);`,
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.ValidateWithPaths(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -19,8 +19,6 @@ func FreshbooksAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("freshbooks", secrets.NewSecret(utils.AlphaNumeric("64")))
|
||||||
utils.GenerateSampleSecret("freshbooks", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO this one could probably use some work
|
// TODO this one could probably use some work
|
||||||
@@ -31,23 +30,61 @@ func GCPAPIKey() *config.Rule {
|
|||||||
RuleID: "gcp-api-key",
|
RuleID: "gcp-api-key",
|
||||||
Description: "Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.",
|
Description: "Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.",
|
||||||
Regex: utils.GenerateUniqueTokenRegex(`AIza[\w-]{35}`, false),
|
Regex: utils.GenerateUniqueTokenRegex(`AIza[\w-]{35}`, false),
|
||||||
Entropy: 3.0,
|
Entropy: 4,
|
||||||
Keywords: []string{
|
Keywords: []string{"AIza"},
|
||||||
"AIza",
|
Allowlists: []*config.Allowlist{
|
||||||
|
{
|
||||||
|
Regexes: []*regexp.Regexp{
|
||||||
|
// example keys from https://github.com/firebase/firebase-android-sdk
|
||||||
|
regexp.MustCompile(`AIzaSyabcdefghijklmnopqrstuvwxyz1234567`),
|
||||||
|
regexp.MustCompile(`AIzaSyAnLA7NfeLquW1tJFpx_eQCxoX-oo6YyIs`),
|
||||||
|
regexp.MustCompile(`AIzaSyCkEhVjf3pduRDt6d1yKOMitrUEke8agEM`),
|
||||||
|
regexp.MustCompile(`AIzaSyDMAScliyLx7F0NPDEJi1QmyCgHIAODrlU`),
|
||||||
|
regexp.MustCompile(`AIzaSyD3asb-2pEZVqMkmL6M9N6nHZRR_znhrh0`),
|
||||||
|
regexp.MustCompile(`AIzayDNSXIbFmlXbIE6mCzDLQAqITYefhixbX4A`),
|
||||||
|
regexp.MustCompile(`AIzaSyAdOS2zB6NCsk1pCdZ4-P6GBdi_UUPwX7c`),
|
||||||
|
regexp.MustCompile(`AIzaSyASWm6HmTMdYWpgMnjRBjxcQ9CKctWmLd4`),
|
||||||
|
regexp.MustCompile(`AIzaSyANUvH9H9BsUccjsu2pCmEkOPjjaXeDQgY`),
|
||||||
|
regexp.MustCompile(`AIzaSyA5_iVawFQ8ABuTZNUdcwERLJv_a_p4wtM`),
|
||||||
|
regexp.MustCompile(`AIzaSyA4UrcGxgwQFTfaI3no3t7Lt1sjmdnP5sQ`),
|
||||||
|
regexp.MustCompile(`AIzaSyDSb51JiIcB6OJpwwMicseKRhhrOq1cS7g`),
|
||||||
|
regexp.MustCompile(`AIzaSyBF2RrAIm4a0mO64EShQfqfd2AFnzAvvuU`),
|
||||||
|
regexp.MustCompile(`AIzaSyBcE-OOIbhjyR83gm4r2MFCu4MJmprNXsw`),
|
||||||
|
regexp.MustCompile(`AIzaSyB8qGxt4ec15vitgn44duC5ucxaOi4FmqE`),
|
||||||
|
regexp.MustCompile(`AIzaSyA8vmApnrHNFE0bApF4hoZ11srVL_n0nvY`),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gcp", secrets.NewSecret(`AIza[\w-]{35}`))
|
||||||
utils.GenerateSampleSecret("gcp", secrets.NewSecret(`AIza[\w-]{35}`)),
|
tps = append(tps,
|
||||||
// non-word character at end
|
// non-word character at end
|
||||||
`AIzaSyNHxIf32IQ1a1yjl3ZJIqKZqzLAK1XhDk-`, // gitleaks:allow
|
`AIzaSyNHxIf32IQ1a1yjl3ZJIqKZqzLAK1XhDk-`, // gitleaks:allow
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
`GWw4hjABFzZCGiRpmlDyDdo87Jn9BN9THUA47muVRNunLxsa82tMAdvmrhOqNkRKiYMEAFbTJAIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDq`, // text boundary start
|
`GWw4hjABFzZCGiRpmlDyDdo87Jn9BN9THUA47muVRNunLxsa82tMAdvmrhOqNkRKiYMEAFbTJAIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDq`, // text boundary start
|
||||||
`AIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDqabcd123`, // text boundary end
|
`AIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDqabcd123`, // text boundary end
|
||||||
`apiKey: "AIzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"`, // not enough entropy
|
`apiKey: "AIzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"`, // not enough entropy
|
||||||
`AIZASYCO2CXRMC9ELSKLHLHRMBSWDEVEDZTLO2O`, // incorrect case
|
`AIZASYCO2CXRMC9ELSKLHLHRMBSWDEVEDZTLO2O`, // incorrect case
|
||||||
|
// example keys from https://github.com/firebase/firebase-android-sdk
|
||||||
|
`AIzaSyabcdefghijklmnopqrstuvwxyz1234567`,
|
||||||
|
`AIzaSyAnLA7NfeLquW1tJFpx_eQCxoX-oo6YyIs`,
|
||||||
|
`AIzaSyCkEhVjf3pduRDt6d1yKOMitrUEke8agEM`,
|
||||||
|
`AIzaSyDMAScliyLx7F0NPDEJi1QmyCgHIAODrlU`,
|
||||||
|
`AIzaSyD3asb-2pEZVqMkmL6M9N6nHZRR_znhrh0`,
|
||||||
|
`AIzayDNSXIbFmlXbIE6mCzDLQAqITYefhixbX4A`,
|
||||||
|
`AIzaSyAdOS2zB6NCsk1pCdZ4-P6GBdi_UUPwX7c`,
|
||||||
|
`AIzaSyASWm6HmTMdYWpgMnjRBjxcQ9CKctWmLd4`,
|
||||||
|
`AIzaSyANUvH9H9BsUccjsu2pCmEkOPjjaXeDQgY`,
|
||||||
|
`AIzaSyA5_iVawFQ8ABuTZNUdcwERLJv_a_p4wtM`,
|
||||||
|
`AIzaSyA4UrcGxgwQFTfaI3no3t7Lt1sjmdnP5sQ`,
|
||||||
|
`AIzaSyDSb51JiIcB6OJpwwMicseKRhhrOq1cS7g`,
|
||||||
|
`AIzaSyBF2RrAIm4a0mO64EShQfqfd2AFnzAvvuU`,
|
||||||
|
`AIzaSyBcE-OOIbhjyR83gm4r2MFCu4MJmprNXsw`,
|
||||||
|
`AIzaSyB8qGxt4ec15vitgn44duC5ucxaOi4FmqE`,
|
||||||
|
`AIzaSyA8vmApnrHNFE0bApF4hoZ11srVL_n0nvY`,
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
"regexp"
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GenericCredential() *config.Rule {
|
func GenericCredential() *config.Rule {
|
||||||
@@ -19,11 +19,10 @@ func GenericCredential() *config.Rule {
|
|||||||
"credential",
|
"credential",
|
||||||
"creds",
|
"creds",
|
||||||
"key",
|
"key",
|
||||||
"passwd",
|
"passw(?:or)?d",
|
||||||
"password",
|
|
||||||
"secret",
|
"secret",
|
||||||
"token",
|
"token",
|
||||||
}, `[\w.=-]{10,150}`, true),
|
}, `[\w.=-]{10,150}|[a-z0-9][a-z0-9+/]{11,}={0,3}`, true),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"access",
|
"access",
|
||||||
"api",
|
"api",
|
||||||
@@ -37,72 +36,132 @@ func GenericCredential() *config.Rule {
|
|||||||
"token",
|
"token",
|
||||||
},
|
},
|
||||||
Entropy: 3.5,
|
Entropy: 3.5,
|
||||||
Allowlists: []config.Allowlist{
|
Allowlists: []*config.Allowlist{
|
||||||
|
{
|
||||||
|
// NOTE: this is a goofy hack to get around the fact there golang's regex engine does not support positive lookaheads.
|
||||||
|
// Ideally we would want to ensure the secret contains both numbers and alphabetical characters, not just alphabetical characters.
|
||||||
|
Regexes: []*regexp.Regexp{
|
||||||
|
regexp.MustCompile(`^[a-zA-Z_.-]+$`),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Description: "Allowlist for Generic API Keys",
|
Description: "Allowlist for Generic API Keys",
|
||||||
MatchCondition: config.AllowlistMatchOr,
|
MatchCondition: config.AllowlistMatchOr,
|
||||||
|
RegexTarget: "match",
|
||||||
Regexes: []*regexp.Regexp{
|
Regexes: []*regexp.Regexp{
|
||||||
regexp.MustCompile(`(?i)(` +
|
regexp.MustCompile(`(?i)(?:` +
|
||||||
// Access
|
// Access
|
||||||
`accessor` +
|
`access(?:ibility|or)` +
|
||||||
|
`|access[_.-]?id` +
|
||||||
|
`|random[_.-]?access` +
|
||||||
// API
|
// API
|
||||||
`|api[_.-]?(version|id)` + // version/id -> not a secret
|
`|api[_.-]?(?:id|name|version)` + // id/name/version -> not a secret
|
||||||
`|rapid|capital` + // common words containing "api"
|
`|rapid|capital` + // common words containing "api"
|
||||||
|
`|[a-z0-9-]*?api[a-z0-9-]*?:jar:` + // Maven META-INF dependencies that contain "api" in the name.
|
||||||
// Auth
|
// Auth
|
||||||
`|author` +
|
`|author` +
|
||||||
|
`|X-MS-Exchange-Organization-Auth` + // email header
|
||||||
|
`|Authentication-Results` + // email header
|
||||||
// Credentials
|
// Credentials
|
||||||
`|(?-i:(?:c|jobC)redentials?Id|withCredentials)` + // Jenkins plugins
|
`|(?:credentials?[_.-]?id|withCredentials)` + // Jenkins plugins
|
||||||
// Key
|
// Key
|
||||||
`|key[_.-]?(alias|board|code|ring|stone|storetype|word|up|down|left|right)` +
|
`|(?:bucket|foreign|hot|idx|natural|primary|pub(?:lic)?|schema|sequence)[_.-]?key` +
|
||||||
|
`|(?:turkey)` +
|
||||||
|
`|key[_.-]?(?:alias|board|code|frame|id|length|mesh|name|pair|press(?:ed)?|ring|selector|signature|size|stone|storetype|word|up|down|left|right)` +
|
||||||
|
// Azure KeyVault
|
||||||
|
`|key[_.-]?vault[_.-]?(?:id|name)|keyVaultToStoreSecrets` +
|
||||||
|
`|key(?:store|tab)[_.-]?(?:file|path)` +
|
||||||
`|issuerkeyhash` + // part of ssl cert
|
`|issuerkeyhash` + // part of ssl cert
|
||||||
`|(bucket|primary|foreign|natural|hot)[_.-]?key` +
|
|
||||||
`|(?-i:[DdMm]onkey|[DM]ONKEY)|keying` + // common words containing "key"
|
`|(?-i:[DdMm]onkey|[DM]ONKEY)|keying` + // common words containing "key"
|
||||||
// Secret
|
// Secret
|
||||||
`|(secret)[_.-]?name` + // name of e.g. env variable
|
`|(?:secret)[_.-]?(?:length|name|size)` + // name of e.g. env variable
|
||||||
|
`|UserSecretsId` + // https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-8.0&tabs=linux
|
||||||
|
|
||||||
// Token
|
// Token
|
||||||
|
`|(?:csrf)[_.-]?token` +
|
||||||
|
`|(?:io\.jsonwebtoken[ \t]?:[ \t]?[\w-]+)` + // Maven library coordinates. (e.g., https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt)
|
||||||
|
|
||||||
// General
|
// General
|
||||||
`|public[_.-]?(key|token)` + // public key -> not a secret
|
`|(?:api|credentials|token)[_.-]?(?:endpoint|ur[il])` +
|
||||||
`|(key|token)[_.-]?file` +
|
`|public[_.-]?token` +
|
||||||
|
`|(?:key|token)[_.-]?file` +
|
||||||
|
// Empty variables capturing the next line (e.g., .env files)
|
||||||
|
`|(?-i:(?:[A-Z_]+=\n[A-Z_]+=|[a-z_]+=\n[a-z_]+=)(?:\n|\z))` +
|
||||||
|
`|(?-i:(?:[A-Z.]+=\n[A-Z.]+=|[a-z.]+=\n[a-z.]+=)(?:\n|\z))` +
|
||||||
`)`),
|
`)`),
|
||||||
},
|
},
|
||||||
RegexTarget: "match",
|
StopWords: append(DefaultStopWords,
|
||||||
StopWords: DefaultStopWords,
|
"6fe4476ee5a1832882e326b506d14126", // https://github.com/yarnpkg/berry/issues/6201
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
RegexTarget: "line",
|
||||||
|
Regexes: []*regexp.Regexp{
|
||||||
|
// Docker build secrets (https://docs.docker.com/build/building/secrets/#using-build-secrets).
|
||||||
|
regexp.MustCompile(`--mount=type=secret,`),
|
||||||
|
// https://github.com/gitleaks/gitleaks/issues/1800
|
||||||
|
regexp.MustCompile(`import[ \t]+{[ \t\w,]+}[ \t]+from[ \t]+['"][^'"]+['"]`),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MatchCondition: config.AllowlistMatchAnd,
|
||||||
|
RegexTarget: "line",
|
||||||
|
Regexes: []*regexp.Regexp{
|
||||||
|
regexp.MustCompile(`LICENSE[^=]*=\s*"[^"]+`),
|
||||||
|
regexp.MustCompile(`LIC_FILES_CHKSUM[^=]*=\s*"[^"]+`),
|
||||||
|
regexp.MustCompile(`SRC[^=]*=\s*"[a-zA-Z0-9]+`),
|
||||||
|
},
|
||||||
|
Paths: []*regexp.Regexp{
|
||||||
|
regexp.MustCompile(`\.bb$`),
|
||||||
|
regexp.MustCompile(`\.bbappend$`),
|
||||||
|
regexp.MustCompile(`\.bbclass$`),
|
||||||
|
regexp.MustCompile(`\.inc$`),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443") //gitleaks:allow
|
||||||
|
tps = append(tps, utils.GenerateSampleSecrets("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB")...)
|
||||||
|
tps = append(tps,
|
||||||
// Access
|
// Access
|
||||||
`'access_token': 'eyJ0eXAioiJKV1slS3oASx=='`,
|
`'access_token': 'eyJ0eXAioiJKV1slS3oASx=='`,
|
||||||
|
|
||||||
// API
|
// API
|
||||||
`some_api_token_123 = "` + newPlausibleSecret(`[a-zA-Z0-9]{60}`) + `"`,
|
`some_api_token_123 = "`+newPlausibleSecret(`[a-zA-Z0-9]{60}`)+`"`,
|
||||||
|
|
||||||
// Auth
|
// Auth
|
||||||
|
`"user_auth": "am9obmRvZTpkMDY5NGIxYi1jMTcxLTQ4ODYt+TMyYS0wMmUwOWQ1/mIwNjc="`,
|
||||||
|
|
||||||
// Credentials
|
// Credentials
|
||||||
`"credentials" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`,
|
`"credentials" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`,
|
||||||
`creds = ` + newPlausibleSecret(`[a-zA-Z0-9]{30}`),
|
`creds = `+newPlausibleSecret(`[a-zA-Z0-9]{30}`),
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
`private-key: ` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{100}`),
|
`private-key: `+newPlausibleSecret(`[a-zA-Z0-9\-_.=]{100}`),
|
||||||
|
|
||||||
// Password
|
// Password
|
||||||
`passwd = ` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
|
`passwd = `+newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
|
||||||
|
// TODO: `ID=dbuser;password=` + newPlausibleSecret(`[a-zA-Z0-9+/]{30}={0,3}`) + `;"`,
|
||||||
|
|
||||||
// Secret
|
// Secret
|
||||||
`"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",`,
|
`"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",`,
|
||||||
`mySecretString=` + newPlausibleSecret(`[a-zA-Z0-9]{30}`),
|
`mySecretString=`+newPlausibleSecret(`[a-zA-Z0-9]{30}`),
|
||||||
`todo_secret_do_not_commit = ` + newPlausibleSecret(`[a-zA-Z0-9]{30}`),
|
`todo_secret_do_not_commit = `+newPlausibleSecret(`[a-zA-Z0-9]{30}`),
|
||||||
|
|
||||||
// Token
|
// Token
|
||||||
utils.GenerateSampleSecret("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443"), //gitleaks:allow
|
` utils.GetEnvOrDefault("api_token", "dafa7817-e246-48f3-91a7-e87653d587b8")`,
|
||||||
utils.GenerateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"),
|
// `"env": {
|
||||||
}
|
//"API_TOKEN": "Lj2^5O%xi214"`,
|
||||||
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
// Access
|
// Access
|
||||||
`"accessor":"rA1wk0Y45YCufyfq",`,
|
`"accessor":"rA1wk0Y45YCufyfq",`,
|
||||||
|
`report_access_id: e8e4df51-2054-49b0-ab1c-516ac95c691d`,
|
||||||
|
`accessibilityYesOptionId = "0736f5ef-7e88-499a-80cc-90c85d2a5180"`,
|
||||||
|
`_RandomAccessIterator>
|
||||||
|
_LIBCPP_CONSTEXPR_AFTER_CXX11 `,
|
||||||
|
|
||||||
// API
|
// API
|
||||||
`this.ultraPictureBox1.Name = "ultraPictureBox1";`,
|
`this.ultraPictureBox1.Name = "ultraPictureBox1";`,
|
||||||
@@ -110,19 +169,33 @@ func GenericCredential() *config.Rule {
|
|||||||
`event-bus-message-api:rc0.15.0_20231217_1420-SNAPSHOT'`,
|
`event-bus-message-api:rc0.15.0_20231217_1420-SNAPSHOT'`,
|
||||||
`COMMUNICATION_API_VERSION=rc0.13.0_20230412_0712-SNAPSHOT`,
|
`COMMUNICATION_API_VERSION=rc0.13.0_20230412_0712-SNAPSHOT`,
|
||||||
`MantleAPI_version=9a038989604e8da62ecddbe2094b16ce1b778be1`,
|
`MantleAPI_version=9a038989604e8da62ecddbe2094b16ce1b778be1`,
|
||||||
|
`[DEBUG] org.slf4j.slf4j-api:jar:1.7.8.:compile (version managed from default)`,
|
||||||
|
`[DEBUG] org.neo4j.neo4j-graphdb-api:jar:3.5.12:test`,
|
||||||
|
`apiUrl=apigee.corpint.com`,
|
||||||
|
`X-API-Name": "NRG0-Hermes-INTERNAL-API",`,
|
||||||
|
// TODO: Jetbrains IML files (requires line-level allowlist).
|
||||||
|
// `<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.directory.api:api-asn1-api:1.0.0-M20" level="projcet" />`
|
||||||
|
|
||||||
// Auth
|
// Auth
|
||||||
`author = "james.fake@ymail.com",`,
|
`author = "james.fake@ymail.com",`,
|
||||||
|
`X-MS-Exchange-Organization-AuthSource: sm02915.int.contoso.com`,
|
||||||
|
`Authentication-Results: 5h.ca.iphmx.com`,
|
||||||
|
|
||||||
// Credentials
|
// Credentials
|
||||||
`withCredentials([usernamePassword(credentialsId: '29f63271-dc2f-4734-8221-5b31b5169bac', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {`,
|
`withCredentials([usernamePassword(credentialsId: '29f63271-dc2f-4734-8221-5b31b5169bac', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {`,
|
||||||
`credentialsId: 'ff083f76-7804-4ef1-80e4-fe975bb9141b'`,
|
`credentialsId: 'ff083f76-7804-4ef1-80e4-fe975bb9141b'`,
|
||||||
`jobCredentialsId: 'f4aeb6bc-2a25-458a-8111-9be9e502c0e7'`,
|
`jobCredentialsId: 'f4aeb6bc-2a25-458a-8111-9be9e502c0e7'`,
|
||||||
` "credentialId": "B9mTcFSck2LzJO2S3ols63",`,
|
` "credentialId": "B9mTcFSck2LzJO2S3ols63",`,
|
||||||
|
`environment {
|
||||||
|
CREDENTIALS_ID = "K8S_CRED"
|
||||||
|
}`,
|
||||||
|
`dev.credentials.url=dev-lb1.api.f4ke.com:5215`,
|
||||||
|
|
||||||
// Key
|
// Key
|
||||||
`keyword: "Befaehigung_P2"`,
|
`keyword: "Befaehigung_P2"`,
|
||||||
`public_key = "9Cnzj4p4WGeKLs1Pt8QuKUpRKfFLfRYC9AIKjbJTWit"`,
|
`public_key = "9Cnzj4p4WGeKLs1Pt8QuKUpRKfFLfRYC9AIKjbJTWit"`,
|
||||||
|
`pub const X509_pubkey_st = struct_X509_pubkey_st;`,
|
||||||
|
`|| pIdxKey->default_rc==0`,
|
||||||
`monkeys-audio:mx64-uwp=fail`,
|
`monkeys-audio:mx64-uwp=fail`,
|
||||||
`primaryKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
|
`primaryKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
|
||||||
`foreignKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
|
`foreignKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
|
||||||
@@ -132,9 +205,42 @@ func GenericCredential() *config.Rule {
|
|||||||
`minisat-master-keying:x64-uwp=fail`,
|
`minisat-master-keying:x64-uwp=fail`,
|
||||||
`IceSSL.KeyFile=s_rsa1024_priv.pem`,
|
`IceSSL.KeyFile=s_rsa1024_priv.pem`,
|
||||||
`"bucket_key": "SalesResults-1.2"`,
|
`"bucket_key": "SalesResults-1.2"`,
|
||||||
//`<TAR key="REF_ID_923.properties" value="/opts/config/alias/"/>`,
|
|
||||||
`<key tag="SecurityIdentifier" name="SecurityIdentifier" type="STRING" />`,
|
`<key tag="SecurityIdentifier" name="SecurityIdentifier" type="STRING" />`,
|
||||||
//`packageKey":` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
|
// `packageKey":` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
|
||||||
|
`schemaKey = 'DOC_Vector_5_32'`,
|
||||||
|
`sequenceKey = "18"`,
|
||||||
|
`app.keystore.file=env/cert.p12`,
|
||||||
|
`-DKEYTAB_FILE=/tmp/app.keytab`,
|
||||||
|
` doc.Security.KeySize = PdfEncryptionKeySize.Key128Bit;`,
|
||||||
|
`o.keySelector=n,o.haKey=!1,`,
|
||||||
|
// TODO: Requires line-level allowlists.
|
||||||
|
` "key_name": "prod5zyxlmy-cmk",`,
|
||||||
|
` "kms_key_id": "555ea4a3-d53a-4412-9c66-3a7cb667b0d6",`,
|
||||||
|
` "key_vault_name": "web21prqodx24021",`,
|
||||||
|
` keyVaultToStoreSecrets: cmp2-qat-1208358310`, // e.g., https://github.com/2uasimojo/community-operators-prod/blob/9e51e4c8e0b5caaa3087e8e18e6fb918b2c36643/operators/azure-service-operator/1.0.59040/manifests/azure.microsoft.com_cosmosdbs.yaml#L50
|
||||||
|
`,apiKey:"6fe4476ee5a1832882e326b506d14126",`,
|
||||||
|
`const validKeyChars = "0123456789abcdefghijklmnopqrstuvwxyz_-."`,
|
||||||
|
`const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"`,
|
||||||
|
`key_length = XSalsa20.key_length`,
|
||||||
|
`pub const SN_id_Gost28147_89_None_KeyMeshing = "id-Gost28147-89-None-KeyMeshing"`,
|
||||||
|
`KeyPair = X25519.KeyPair`,
|
||||||
|
`BlindKeySignatures = Ed25519.BlindKeySignatures`,
|
||||||
|
`AVEncVideoMaxKeyframeDistance, "2987123a-ba93-4704-b489-ec1e5f25292c"`,
|
||||||
|
` keyPressed = kVK_Return.u16`,
|
||||||
|
`timezone_mapping = {
|
||||||
|
"Turkey Standard Time": "Europe/Istanbul",
|
||||||
|
}`, // https://github.com/gitleaks/gitleaks/issues/1799
|
||||||
|
// `<add key="SchemaTable" value="G:\SchemaTable.xml" />`,
|
||||||
|
//` { key: '9df21e95-3848-409d-8f94-c675cdfee839', value: 'Americas' },`,
|
||||||
|
// `<TAR key="REF_ID_923.properties" value="/opts/config/alias/"/>`,
|
||||||
|
// `secret:
|
||||||
|
// secretName: app-decryption-secret
|
||||||
|
// items:
|
||||||
|
// - key: app-k8s.yml
|
||||||
|
// path: app-k8s.yml`,
|
||||||
|
|
||||||
|
// TODO: https://learn.microsoft.com/en-us/windows/apps/design/style/xaml-theme-resources
|
||||||
|
//`<Color x:Key="NormalBrushGradient1">#FFBAE4FF</Color>`,
|
||||||
|
|
||||||
// Password
|
// Password
|
||||||
`password combination.
|
`password combination.
|
||||||
@@ -144,19 +250,38 @@ R5: Regulatory--21`,
|
|||||||
|
|
||||||
// Secret
|
// Secret
|
||||||
`LLM_SECRET_NAME = "NEXUS-GPT4-API-KEY"`,
|
`LLM_SECRET_NAME = "NEXUS-GPT4-API-KEY"`,
|
||||||
|
` <UserSecretsId>79a3edd0-2092-40a2-a04d-dcb46d5ca9ed</UserSecretsId>`,
|
||||||
|
`secret_length = X25519.secret_length`,
|
||||||
|
`secretSize must be >= XXH3_SECRET_SIZE_MIN`,
|
||||||
|
`# get build time secret for authentication
|
||||||
|
#RUN --mount=type=secret,id=jfrog_secret \
|
||||||
|
# JFROG_SECRET = $(cat /run/secrets/jfrog_secret) && \`,
|
||||||
|
|
||||||
// Token
|
// Token
|
||||||
|
` access_token_url='https://github.com/login/oauth/access_token',`,
|
||||||
`publicToken = "9Cnzj4p4WGeKLs1Pt8QuKUpRKfFLfRYC9AIKjbJTWit"`,
|
`publicToken = "9Cnzj4p4WGeKLs1Pt8QuKUpRKfFLfRYC9AIKjbJTWit"`,
|
||||||
`<SourceFile SourceLocation="F:\Extracts\" TokenFile="RTL_INST_CODE.cer">`,
|
`<SourceFile SourceLocation="F:\Extracts\" TokenFile="RTL_INST_CODE.cer">`,
|
||||||
|
`notes = "Maven - io.jsonwebtoken:jjwt-jackson-0.11.2"`,
|
||||||
|
`csrf-token=Mj2qykJO5rELyHgezQ69nzUX0i3OH67V7+V4eUrLfpuyOuxmiW9rhROG/Whikle15syazJOkrjJa3U2AbhIvUw==`,
|
||||||
|
// TODO: `TOKEN_AUDIENCE = "25872395-ed3a-4703-b647-22ec53f3683c"`,
|
||||||
|
|
||||||
// General
|
// General
|
||||||
`clientId = "73082700-1f09-405b-80d0-3131bfd6272d"`,
|
`clientId = "73082700-1f09-405b-80d0-3131bfd6272d"`,
|
||||||
|
`GITHUB_API_KEY=
|
||||||
|
DYNATRACE_API_KEY=`,
|
||||||
|
`snowflake.password=
|
||||||
|
jdbc.snowflake.url=`,
|
||||||
|
`import { chain_Anvil1_Key, chain_Anvil2_Key } from '../blockchain-tests/pallets/supported-chains/consts';`,
|
||||||
|
|
||||||
|
// Yocto/BitBake
|
||||||
|
`SRCREV_moby = "43fc912ef59a83054ea7f6706df4d53a7dea4d80"`,
|
||||||
|
`LIC_FILES_CHKSUM = "file://${WORKDIR}/license.html;md5=5c94767cedb5d6987c902ac850ded2c6"`,
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPlausibleSecret(regex string) string {
|
func newPlausibleSecret(regex string) string {
|
||||||
allowList := config.Allowlist{StopWords: DefaultStopWords}
|
allowList := &config.Allowlist{StopWords: DefaultStopWords}
|
||||||
// attempt to generate a random secret,
|
// attempt to generate a random secret,
|
||||||
// retrying until it contains at least one digit and no stop words
|
// retrying until it contains at least one digit and no stop words
|
||||||
// TODO: currently the DefaultStopWords list contains many short words,
|
// TODO: currently the DefaultStopWords list contains many short words,
|
||||||
@@ -166,7 +291,7 @@ func newPlausibleSecret(regex string) string {
|
|||||||
if !regexp.MustCompile(`[1-9]`).MatchString(secret) {
|
if !regexp.MustCompile(`[1-9]`).MatchString(secret) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if allowList.ContainsStopWord(secret) {
|
if ok, _ := allowList.ContainsStopWord(secret); ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return secret
|
return secret
|
||||||
|
|||||||
@@ -2,17 +2,16 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var githubAllowlist = []config.Allowlist{
|
var githubAllowlist = []*config.Allowlist{
|
||||||
{
|
{
|
||||||
Paths: []*regexp.Regexp{
|
Paths: []*regexp.Regexp{
|
||||||
// https://github.com/octokit/auth-token.js/?tab=readme-ov-file#createtokenauthtoken-options
|
// https://github.com/octokit/auth-token.js/?tab=readme-ov-file#createtokenauthtoken-options
|
||||||
regexp.MustCompile(`(^|/)@octokit/auth-token/README\.md$`),
|
regexp.MustCompile(`(?:^|/)@octokit/auth-token/README\.md$`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -29,9 +28,7 @@ func GitHubPat() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("github", "ghp_"+secrets.NewSecret(utils.AlphaNumeric("36")))
|
||||||
utils.GenerateSampleSecret("github", "ghp_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
}
|
}
|
||||||
@@ -49,9 +46,7 @@ func GitHubFineGrainedPat() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("github", "github_pat_"+secrets.NewSecret(utils.AlphaNumeric("82")))
|
||||||
utils.GenerateSampleSecret("github", "github_pat_"+secrets.NewSecret(utils.AlphaNumeric("82"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"github_pat_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
"github_pat_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
}
|
}
|
||||||
@@ -69,9 +64,7 @@ func GitHubOauth() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("github", "gho_"+secrets.NewSecret(utils.AlphaNumeric("36")))
|
||||||
utils.GenerateSampleSecret("github", "gho_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"gho_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
"gho_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
}
|
}
|
||||||
@@ -90,10 +83,8 @@ func GitHubApp() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("github", "ghs_"+secrets.NewSecret(utils.AlphaNumeric("36")))
|
||||||
utils.GenerateSampleSecret("github", "ghu_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
tps = append(tps, utils.GenerateSampleSecrets("github", "ghu_"+secrets.NewSecret(utils.AlphaNumeric("36")))...)
|
||||||
utils.GenerateSampleSecret("github", "ghs_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"ghu_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
"ghu_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
"ghs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
"ghs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
@@ -112,9 +103,7 @@ func GitHubRefresh() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("github", "ghr_"+secrets.NewSecret(utils.AlphaNumeric("36")))
|
||||||
utils.GenerateSampleSecret("github", "ghr_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"ghr_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
"ghr_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// overview with all GitLab tokens:
|
// overview with all GitLab tokens:
|
||||||
@@ -14,15 +12,13 @@ import (
|
|||||||
|
|
||||||
func GitlabCiCdJobToken() *config.Rule {
|
func GitlabCiCdJobToken() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Identified a GitLab CI/CD Job Token, potential access to projects and some APIs on behalf of a user while the CI job is running.",
|
|
||||||
RuleID: "gitlab-cicd-job-token",
|
RuleID: "gitlab-cicd-job-token",
|
||||||
|
Description: "Identified a GitLab CI/CD Job Token, potential access to projects and some APIs on behalf of a user while the CI job is running.",
|
||||||
Regex: regexp.MustCompile(`glcbt-[0-9a-zA-Z]{1,5}_[0-9a-zA-Z_-]{20}`),
|
Regex: regexp.MustCompile(`glcbt-[0-9a-zA-Z]{1,5}_[0-9a-zA-Z_-]{20}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"glcbt-"},
|
Keywords: []string{"glcbt-"},
|
||||||
}
|
}
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "glcbt-"+secrets.NewSecret(utils.AlphaNumeric("5"))+"_"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("gitlab", "glcbt-"+secrets.NewSecret(utils.AlphaNumeric("5"))+"_"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,71 +38,61 @@ func GitlabDeployToken() *config.Rule {
|
|||||||
|
|
||||||
func GitlabFeatureFlagClientToken() *config.Rule {
|
func GitlabFeatureFlagClientToken() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Identified a GitLab feature flag client token, risks exposing user lists and features flags used by an application.",
|
|
||||||
RuleID: "gitlab-feature-flag-client-token",
|
RuleID: "gitlab-feature-flag-client-token",
|
||||||
|
Description: "Identified a GitLab feature flag client token, risks exposing user lists and features flags used by an application.",
|
||||||
Regex: regexp.MustCompile(`glffct-[0-9a-zA-Z_\-]{20}`),
|
Regex: regexp.MustCompile(`glffct-[0-9a-zA-Z_\-]{20}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"glffct-"},
|
Keywords: []string{"glffct-"},
|
||||||
}
|
}
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "glffct-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("gitlab", "glffct-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitlabFeedToken() *config.Rule {
|
func GitlabFeedToken() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Identified a GitLab feed token, risking exposure of user data.",
|
|
||||||
RuleID: "gitlab-feed-token",
|
RuleID: "gitlab-feed-token",
|
||||||
|
Description: "Identified a GitLab feed token, risking exposure of user data.",
|
||||||
Regex: regexp.MustCompile(`glft-[0-9a-zA-Z_\-]{20}`),
|
Regex: regexp.MustCompile(`glft-[0-9a-zA-Z_\-]{20}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"glft-"},
|
Keywords: []string{"glft-"},
|
||||||
}
|
}
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "glft-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("gitlab", "glft-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitlabIncomingMailToken() *config.Rule {
|
func GitlabIncomingMailToken() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Identified a GitLab incoming mail token, risking manipulation of data sent by mail.",
|
|
||||||
RuleID: "gitlab-incoming-mail-token",
|
RuleID: "gitlab-incoming-mail-token",
|
||||||
|
Description: "Identified a GitLab incoming mail token, risking manipulation of data sent by mail.",
|
||||||
Regex: regexp.MustCompile(`glimt-[0-9a-zA-Z_\-]{25}`),
|
Regex: regexp.MustCompile(`glimt-[0-9a-zA-Z_\-]{25}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"glimt-"},
|
Keywords: []string{"glimt-"},
|
||||||
}
|
}
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "glimt-"+secrets.NewSecret(utils.AlphaNumeric("25")))
|
||||||
utils.GenerateSampleSecret("gitlab", "glimt-"+secrets.NewSecret(utils.AlphaNumeric("25"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitlabKubernetesAgentToken() *config.Rule {
|
func GitlabKubernetesAgentToken() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Identified a GitLab Kubernetes Agent token, risking access to repos and registry of projects connected via agent.",
|
|
||||||
RuleID: "gitlab-kubernetes-agent-token",
|
RuleID: "gitlab-kubernetes-agent-token",
|
||||||
|
Description: "Identified a GitLab Kubernetes Agent token, risking access to repos and registry of projects connected via agent.",
|
||||||
Regex: regexp.MustCompile(`glagent-[0-9a-zA-Z_\-]{50}`),
|
Regex: regexp.MustCompile(`glagent-[0-9a-zA-Z_\-]{50}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"glagent-"},
|
Keywords: []string{"glagent-"},
|
||||||
}
|
}
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "glagent-"+secrets.NewSecret(utils.AlphaNumeric("50")))
|
||||||
utils.GenerateSampleSecret("gitlab", "glagent-"+secrets.NewSecret(utils.AlphaNumeric("50"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitlabOauthAppSecret() *config.Rule {
|
func GitlabOauthAppSecret() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Identified a GitLab OIDC Application Secret, risking access to apps using GitLab as authentication provider.",
|
|
||||||
RuleID: "gitlab-oauth-app-secret",
|
RuleID: "gitlab-oauth-app-secret",
|
||||||
|
Description: "Identified a GitLab OIDC Application Secret, risking access to apps using GitLab as authentication provider.",
|
||||||
Regex: regexp.MustCompile(`gloas-[0-9a-zA-Z_\-]{64}`),
|
Regex: regexp.MustCompile(`gloas-[0-9a-zA-Z_\-]{64}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"gloas-"},
|
Keywords: []string{"gloas-"},
|
||||||
}
|
}
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "gloas-"+secrets.NewSecret(utils.AlphaNumeric("64")))
|
||||||
utils.GenerateSampleSecret("gitlab", "gloas-"+secrets.NewSecret(utils.AlphaNumeric("64"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,15 +105,31 @@ func GitlabPat() *config.Rule {
|
|||||||
Keywords: []string{"glpat-"},
|
Keywords: []string{"glpat-"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
// validate
|
||||||
utils.GenerateSampleSecret("gitlab", "glpat-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
tps := utils.GenerateSampleSecrets("gitlab", "glpat-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"glpat-XXXXXXXXXXX-XXXXXXXX",
|
"glpat-XXXXXXXXXXX-XXXXXXXX",
|
||||||
}
|
}
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GitlabPatRoutable() *config.Rule {
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "gitlab-pat-routable",
|
||||||
|
Description: "Identified a GitLab Personal Access Token (routable), risking unauthorized access to GitLab repositories and codebase exposure.",
|
||||||
|
Regex: regexp.MustCompile(`\bglpat-[0-9a-zA-Z_-]{27,300}\.[0-9a-z]{2}[0-9a-z]{7}\b`),
|
||||||
|
Entropy: 4,
|
||||||
|
Keywords: []string{"glpat-"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("gitlab", "glpat-"+secrets.NewSecret(utils.AlphaNumeric("27"))+"."+secrets.NewSecret(utils.AlphaNumeric("2"))+secrets.NewSecret(utils.AlphaNumeric("7")))
|
||||||
|
fps := []string{
|
||||||
|
"glpat-xxxxxxxx-xxxxxxxxxxxxxxxxxx.xxxxxxxxx",
|
||||||
|
}
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
func GitlabPipelineTriggerToken() *config.Rule {
|
func GitlabPipelineTriggerToken() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "gitlab-ptt",
|
RuleID: "gitlab-ptt",
|
||||||
@@ -137,9 +139,8 @@ func GitlabPipelineTriggerToken() *config.Rule {
|
|||||||
Keywords: []string{"glptt-"},
|
Keywords: []string{"glptt-"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
// validate
|
||||||
utils.GenerateSampleSecret("gitlab", "glptt-"+secrets.NewSecret(utils.Hex("40"))),
|
tps := utils.GenerateSampleSecrets("gitlab", "glptt-"+secrets.NewSecret(utils.Hex("40")))
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"glptt-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
"glptt-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||||
}
|
}
|
||||||
@@ -155,9 +156,7 @@ func GitlabRunnerRegistrationToken() *config.Rule {
|
|||||||
Keywords: []string{"GR1348941"},
|
Keywords: []string{"GR1348941"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "GR1348941"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("gitlab", "GR1348941"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"GR134894112312312312312312312",
|
"GR134894112312312312312312312",
|
||||||
"GR1348941XXXXXXXXXXXXXXXXXXXX",
|
"GR1348941XXXXXXXXXXXXXXXXXXXX",
|
||||||
@@ -167,45 +166,57 @@ func GitlabRunnerRegistrationToken() *config.Rule {
|
|||||||
|
|
||||||
func GitlabRunnerAuthenticationToken() *config.Rule {
|
func GitlabRunnerAuthenticationToken() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Discovered a GitLab Runner Authentication Token, posing a risk to CI/CD pipeline integrity and unauthorized access.",
|
|
||||||
RuleID: "gitlab-runner-authentication-token",
|
RuleID: "gitlab-runner-authentication-token",
|
||||||
|
Description: "Discovered a GitLab Runner Authentication Token, posing a risk to CI/CD pipeline integrity and unauthorized access.",
|
||||||
Regex: regexp.MustCompile(`glrt-[0-9a-zA-Z_\-]{20}`),
|
Regex: regexp.MustCompile(`glrt-[0-9a-zA-Z_\-]{20}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"glrt-"},
|
Keywords: []string{"glrt-"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "glrt-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("gitlab", "glrt-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GitlabRunnerAuthenticationTokenRoutable() *config.Rule {
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "gitlab-runner-authentication-token-routable",
|
||||||
|
Description: "Discovered a GitLab Runner Authentication Token (Routable), posing a risk to CI/CD pipeline integrity and unauthorized access.",
|
||||||
|
Regex: regexp.MustCompile(`\bglrt-t\d_[0-9a-zA-Z_\-]{27,300}\.[0-9a-z]{2}[0-9a-z]{7}\b`),
|
||||||
|
Entropy: 4,
|
||||||
|
Keywords: []string{"glrt-"},
|
||||||
|
}
|
||||||
|
|
||||||
|
tps := utils.GenerateSampleSecrets("gitlab", "glrt-t"+secrets.NewSecret(utils.Numeric("1"))+"_"+secrets.NewSecret(utils.AlphaNumeric("27"))+"."+secrets.NewSecret(utils.AlphaNumeric("2"))+secrets.NewSecret(utils.AlphaNumeric("7")))
|
||||||
|
fps := []string{
|
||||||
|
"glrt-tx_xxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxx",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
func GitlabScimToken() *config.Rule {
|
func GitlabScimToken() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Discovered a GitLab SCIM Token, posing a risk to unauthorized access for a organization or instance.",
|
|
||||||
RuleID: "gitlab-scim-token",
|
RuleID: "gitlab-scim-token",
|
||||||
|
Description: "Discovered a GitLab SCIM Token, posing a risk to unauthorized access for a organization or instance.",
|
||||||
Regex: regexp.MustCompile(`glsoat-[0-9a-zA-Z_\-]{20}`),
|
Regex: regexp.MustCompile(`glsoat-[0-9a-zA-Z_\-]{20}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"glsoat-"},
|
Keywords: []string{"glsoat-"},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitlab", "glsoat-"+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("gitlab", "glsoat-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GitlabSessionCookie() *config.Rule {
|
func GitlabSessionCookie() *config.Rule {
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Discovered a GitLab Session Cookie, posing a risk to unauthorized access to a user account.",
|
|
||||||
RuleID: "gitlab-session-cookie",
|
RuleID: "gitlab-session-cookie",
|
||||||
|
Description: "Discovered a GitLab Session Cookie, posing a risk to unauthorized access to a user account.",
|
||||||
Regex: regexp.MustCompile(`_gitlab_session=[0-9a-z]{32}`),
|
Regex: regexp.MustCompile(`_gitlab_session=[0-9a-z]{32}`),
|
||||||
Entropy: 3,
|
Entropy: 3,
|
||||||
Keywords: []string{"_gitlab_session="},
|
Keywords: []string{"_gitlab_session="},
|
||||||
}
|
}
|
||||||
|
|
||||||
tps := []string{
|
// validate
|
||||||
utils.GenerateSampleSecret("gitlab", "_gitlab_session="+secrets.NewSecret(utils.AlphaNumeric("32"))),
|
tps := utils.GenerateSampleSecrets("gitlab", "_gitlab_session="+secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -20,9 +20,6 @@ func GitterAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gitter", secrets.NewSecret(utils.AlphaNumericExtendedShort("40")))
|
||||||
utils.GenerateSampleSecret("gitter",
|
|
||||||
secrets.NewSecret(utils.AlphaNumericExtendedShort("40"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -20,8 +20,6 @@ func GoCardless() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("gocardless", "live_"+secrets.NewSecret(utils.AlphaNumericExtended("40")))
|
||||||
utils.GenerateSampleSecret("gocardless", "live_"+secrets.NewSecret(utils.AlphaNumericExtended("40"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -17,9 +17,7 @@ func GrafanaApiKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("grafana-api-key", "eyJrIjoi"+secrets.NewSecret(utils.AlphaNumeric("70")))
|
||||||
utils.GenerateSampleSecret("grafana-api-key", "eyJrIjoi"+secrets.NewSecret(utils.AlphaNumeric("70"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +32,8 @@ func GrafanaCloudApiToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("grafana-cloud-api-token", "glc_"+secrets.NewSecret(utils.AlphaNumeric("32")))
|
||||||
|
tps = append(tps,
|
||||||
utils.GenerateSampleSecret("grafana-cloud-api-token",
|
utils.GenerateSampleSecret("grafana-cloud-api-token",
|
||||||
"glc_"+
|
"glc_"+
|
||||||
secrets.NewSecret(utils.AlphaNumeric("32"))),
|
secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||||
@@ -42,7 +41,7 @@ func GrafanaCloudApiToken() *config.Rule {
|
|||||||
// TODO:
|
// TODO:
|
||||||
//` loki:
|
//` loki:
|
||||||
//endpoint: https://322137:glc_eyJvIjoiNzQ0NTg3IiwibiI7InN0YWlrLTQ3NTgzMC1obC13cml0ZS1oYW5kc29uJG9raSIsImsiOiI4M2w3cmdYUlBoMTUyMW1lMU023nl5UDUiLCJtIjp7IOIiOiJ1cyJ9fQ==@logs-prod4.grafana.net/loki/api/v1/push`,
|
//endpoint: https://322137:glc_eyJvIjoiNzQ0NTg3IiwibiI7InN0YWlrLTQ3NTgzMC1obC13cml0ZS1oYW5kc29uJG9raSIsImsiOiI4M2w3cmdYUlBoMTUyMW1lMU023nl5UDUiLCJtIjp7IOIiOiJ1cyJ9fQ==@logs-prod4.grafana.net/loki/api/v1/push`,
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
// Low entropy.
|
// Low entropy.
|
||||||
`glc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`,
|
`glc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`,
|
||||||
@@ -70,14 +69,10 @@ func GrafanaServiceAccountToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("grafana-service-account-token", "glsa_"+secrets.NewSecret(utils.AlphaNumeric("32"))+"_"+secrets.NewSecret(utils.Hex("8")))
|
||||||
utils.GenerateSampleSecret("grafana-service-account-token",
|
tps = append(tps,
|
||||||
"glsa_"+
|
|
||||||
secrets.NewSecret(utils.AlphaNumeric("32"))+
|
|
||||||
"_"+
|
|
||||||
secrets.NewSecret((utils.Hex("8")))),
|
|
||||||
`'Authorization': 'Bearer glsa_pITqMOBIfNH2KL4PkXJqmTyQl0D9QGxF_486f63e1'`,
|
`'Authorization': 'Bearer glsa_pITqMOBIfNH2KL4PkXJqmTyQl0D9QGxF_486f63e1'`,
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
"glsa_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_AAAAAAAA",
|
"glsa_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX_AAAAAAAA",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HarnessApiKey() *config.Rule {
|
func HarnessApiKey() *config.Rule {
|
||||||
@@ -19,10 +17,8 @@ func HarnessApiKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate a sample secret for validation
|
// Generate a sample secret for validation
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("harness", "pat."+secrets.NewSecret(utils.AlphaNumeric("22"))+"."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
utils.GenerateSampleSecret("harness", "pat."+secrets.NewSecret(utils.AlphaNumeric("22"))+"."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
tps = append(tps, utils.GenerateSampleSecrets("harness", "sat."+secrets.NewSecret(utils.AlphaNumeric("22"))+"."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("20")))...)
|
||||||
utils.GenerateSampleSecret("harness", "sat."+secrets.NewSecret(utils.AlphaNumeric("22"))+"."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
|
||||||
}
|
|
||||||
|
|
||||||
// validate the rule
|
// validate the rule
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
|
||||||
"regexp"
|
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func HashiCorpTerraform() *config.Rule {
|
func HashiCorpTerraform() *config.Rule {
|
||||||
@@ -20,10 +20,10 @@ func HashiCorpTerraform() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("hashicorpToken", secrets.NewSecret(utils.Hex("14"))+".atlasv1."+secrets.NewSecret(utils.AlphaNumericExtended("60,70")))
|
||||||
utils.GenerateSampleSecret("hashicorpToken", secrets.NewSecret(utils.Hex("14"))+".atlasv1."+secrets.NewSecret(utils.AlphaNumericExtended("60,70"))),
|
tps = append(tps,
|
||||||
`#token = "hE1hlYILrSqpqh.atlasv1.ARjZuyzl33F71WR55s6ln5GQ1HWIwTDDH3MiRjz7OnpCfaCb1RCF5zGaSncCWmJdcYA"`,
|
`#token = "hE1hlYILrSqpqh.atlasv1.ARjZuyzl33F71WR55s6ln5GQ1HWIwTDDH3MiRjz7OnpCfaCb1RCF5zGaSncCWmJdcYA"`,
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
`token = "xxxxxxxxxxxxxx.atlasv1.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"`, // low entropy
|
`token = "xxxxxxxxxxxxxx.atlasv1.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"`, // low entropy
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
"regexp"
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func VaultServiceToken() *config.Rule {
|
func VaultServiceToken() *config.Rule {
|
||||||
@@ -15,7 +15,7 @@ func VaultServiceToken() *config.Rule {
|
|||||||
Regex: utils.GenerateUniqueTokenRegex(`(?:hvs\.[\w-]{90,120}|s\.(?i:[a-z0-9]{24}))`, false),
|
Regex: utils.GenerateUniqueTokenRegex(`(?:hvs\.[\w-]{90,120}|s\.(?i:[a-z0-9]{24}))`, false),
|
||||||
Entropy: 3.5,
|
Entropy: 3.5,
|
||||||
Keywords: []string{"hvs.", "s."},
|
Keywords: []string{"hvs.", "s."},
|
||||||
Allowlists: []config.Allowlist{
|
Allowlists: []*config.Allowlist{
|
||||||
{
|
{
|
||||||
Regexes: []*regexp.Regexp{
|
Regexes: []*regexp.Regexp{
|
||||||
// https://github.com/gitleaks/gitleaks/issues/1490#issuecomment-2334166357
|
// https://github.com/gitleaks/gitleaks/issues/1490#issuecomment-2334166357
|
||||||
@@ -28,12 +28,13 @@ func VaultServiceToken() *config.Rule {
|
|||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
// Old
|
// Old
|
||||||
utils.GenerateSampleSecret("vault", "s."+secrets.NewSecret(utils.AlphaNumeric("24"))),
|
utils.GenerateSampleSecret("vault", secrets.NewSecret(`s\.[0-9][a-zA-Z0-9]{23}`)),
|
||||||
`token: s.ZC9Ecf4M5g9o34Q6RkzGsj0z`,
|
`token: s.ZC9Ecf4M5g9o34Q6RkzGsj0z`,
|
||||||
// New
|
// New
|
||||||
utils.GenerateSampleSecret("vault", "hvs."+secrets.NewSecret(utils.AlphaNumericExtendedShort("90"))),
|
utils.GenerateSampleSecret("vault", secrets.NewSecret(`hvs\.[0-9][\w\-]{89}`)),
|
||||||
`-vaultToken hvs.CAESIP2jTxc9S2K7Z6CtcFWQv7-044m_oSsxnPE1H3nF89l3GiYKHGh2cy5sQmlIZVNyTWJNcDRsYWJpQjlhYjVlb1cQh6PL8wEYAg"`, // longer than 100 chars
|
`-vaultToken hvs.CAESIP2jTxc9S2K7Z6CtcFWQv7-044m_oSsxnPE1H3nF89l3GiYKHGh2cy5sQmlIZVNyTWJNcDRsYWJpQjlhYjVlb1cQh6PL8wEYAg"`, // longer than 100 chars
|
||||||
}
|
}
|
||||||
|
|
||||||
fps := []string{
|
fps := []string{
|
||||||
// Old
|
// Old
|
||||||
` credentials: new AWS.SharedIniFileCredentials({ profile: '<YOUR_PROFILE>' })`, // word boundary start
|
` credentials: new AWS.SharedIniFileCredentials({ profile: '<YOUR_PROFILE>' })`, // word boundary start
|
||||||
@@ -60,9 +61,7 @@ func VaultBatchToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("vault", "hvb."+secrets.NewSecret(utils.AlphaNumericExtendedShort("138")))
|
||||||
utils.GenerateSampleSecret("vault", "hvb."+secrets.NewSecret(utils.AlphaNumericExtendedShort("138"))),
|
tps = append(tps, `hvb.AAAAAQJgxDgqsGNorpoOR7hPZ5SU-ynBvCl764jyRP_fnX7WvkdkDzGjbLNGdPdtlY33Als2P36yDZueqzfdGw9RsaTeaYXSH7E4RYSWuRoQ9YRKIw8o7mDDY2ZcT3KOB7RwtW1w1FN2eDqcy_sbCjXPaM1iBVH-mqMSYRmRd2nb5D1SJPeBzIYRqSglLc31wUGN7xEzyrKUczqOKsIcybQA`) // gitleaks:allow
|
||||||
`hvb.AAAAAQJgxDgqsGNorpoOR7hPZ5SU-ynBvCl764jyRP_fnX7WvkdkDzGjbLNGdPdtlY33Als2P36yDZueqzfdGw9RsaTeaYXSH7E4RYSWuRoQ9YRKIw8o7mDDY2ZcT3KOB7RwtW1w1FN2eDqcy_sbCjXPaM1iBVH-mqMSYRmRd2nb5D1SJPeBzIYRqSglLc31wUGN7xEzyrKUczqOKsIcybQA`, // gitleaks:allow
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -16,9 +17,29 @@ func Heroku() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("heroku", secrets.NewSecret(utils.Hex8_4_4_4_12()))
|
||||||
|
tps = append(tps,
|
||||||
`const HEROKU_KEY = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
`const HEROKU_KEY = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
`heroku_api_key = "832d2129-a846-4e27-99f4-7004b6ad53ef"`, // gitleaks:allow
|
`heroku_api_key = "832d2129-a846-4e27-99f4-7004b6ad53ef"`, // gitleaks:allow
|
||||||
|
)
|
||||||
|
return utils.Validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func HerokuV2() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Detected a Heroku API Key, potentially compromising cloud application deployments and operational security.",
|
||||||
|
RuleID: "heroku-api-key-v2",
|
||||||
|
Regex: utils.GenerateUniqueTokenRegex(`(HRKU-AA[0-9a-zA-Z_-]{58})`, false),
|
||||||
|
Entropy: 4,
|
||||||
|
Keywords: []string{"HRKU-AA"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("heroku", secrets.NewSecret(`\b(HRKU-AA[0-9a-zA-Z_-]{58})\b`))
|
||||||
|
tps = append(tps,
|
||||||
|
`const KEY = "HRKU-AAlQ1aVoHDujJ9QsDHdHlHO0hbzhoERRSO45ZQusSYHg_____w4_hLrAym_u""`,
|
||||||
|
`API_Key = "HRKU-AAy9Ppr_HD2pPuTyIiTYInO0hbzhoERRSO93ZQusSYHgaD7_WQ07FnF7L9FX"`,
|
||||||
|
)
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -17,8 +18,9 @@ func HubSpot() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("hubspot", secrets.NewSecret(utils.Hex8_4_4_4_12()))
|
||||||
|
tps = append(tps,
|
||||||
`const hubspotKey = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
`const hubspotKey = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||||
}
|
)
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,8 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
|
||||||
"regexp"
|
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
@@ -18,7 +17,7 @@ func HuggingFaceAccessToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "huggingface-access-token",
|
RuleID: "huggingface-access-token",
|
||||||
Description: "Discovered a Hugging Face Access token, which could lead to unauthorized access to AI models and sensitive data.",
|
Description: "Discovered a Hugging Face Access token, which could lead to unauthorized access to AI models and sensitive data.",
|
||||||
Regex: regexp.MustCompile(`(?:^|[\\'"` + "`" + ` >=:])(hf_[a-zA-Z]{34})(?:$|[\\'"` + "`" + ` <])`),
|
Regex: utils.GenerateUniqueTokenRegex("hf_(?i:[a-z]{34})", false),
|
||||||
Entropy: 2,
|
Entropy: 2,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"hf_",
|
"hf_",
|
||||||
@@ -26,7 +25,8 @@ func HuggingFaceAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("huggingface", "hf_"+secrets.NewSecret("[a-zA-Z]{34}"))
|
||||||
|
tps = append(tps,
|
||||||
`huggingface-cli login --token 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`,
|
`huggingface-cli login --token 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`,
|
||||||
`huggingface-cli login --token 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`,
|
`huggingface-cli login --token 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`,
|
||||||
`huggingface-cli login --token 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`,
|
`huggingface-cli login --token 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`,
|
||||||
@@ -40,11 +40,11 @@ func HuggingFaceAccessToken() *config.Rule {
|
|||||||
`use_auth_token='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')`,
|
`use_auth_token='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')`,
|
||||||
`CI_HUB_USER_TOKEN = "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"`,
|
`CI_HUB_USER_TOKEN = "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"`,
|
||||||
`- Change line 5 and add your Hugging Face token, that is, instead of 'hf_token = "ADD_YOUR_HUGGING_FACE_TOKEN_HERE"', you will need to change it to something like'hf_token = "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"'`,
|
`- Change line 5 and add your Hugging Face token, that is, instead of 'hf_token = "ADD_YOUR_HUGGING_FACE_TOKEN_HERE"', you will need to change it to something like'hf_token = "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"'`,
|
||||||
` " hf_token = \"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\"\n",`,
|
//TODO: ` " hf_token = \"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\"\n",`,
|
||||||
`# Not critical, only usable on the sandboxed CI instance.
|
`# Not critical, only usable on the sandboxed CI instance.
|
||||||
TOKEN = "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"`,
|
TOKEN = "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"`,
|
||||||
` parser.add_argument("--hf_token", type=str, default='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', help="Hugging Face Access Token to access PyAnnote gated models")`,
|
` parser.add_argument("--hf_token", type=str, default='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', help="Hugging Face Access Token to access PyAnnote gated models")`,
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
`- (id)hf_requiredCharacteristicTypesForDisplayMetadata;`,
|
`- (id)hf_requiredCharacteristicTypesForDisplayMetadata;`,
|
||||||
`amazon.de#@#div[data-cel-widget="desktop-rhf_SponsoredProductsRemoteRHFSearchEXPSubsK2ClickPagination"]`,
|
`amazon.de#@#div[data-cel-widget="desktop-rhf_SponsoredProductsRemoteRHFSearchEXPSubsK2ClickPagination"]`,
|
||||||
@@ -72,7 +72,7 @@ func HuggingFaceOrganizationApiToken() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "huggingface-organization-api-token",
|
RuleID: "huggingface-organization-api-token",
|
||||||
Description: "Uncovered a Hugging Face Organization API token, potentially compromising AI organization accounts and associated data.",
|
Description: "Uncovered a Hugging Face Organization API token, potentially compromising AI organization accounts and associated data.",
|
||||||
Regex: regexp.MustCompile(`(?:^|[\\'"` + "`" + ` >=:\(,)])(api_org_[a-zA-Z]{34})(?:$|[\\'"` + "`" + ` <\),])`),
|
Regex: utils.GenerateUniqueTokenRegex("api_org_(?i:[a-z]{34})", false),
|
||||||
|
|
||||||
Entropy: 2,
|
Entropy: 2,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
@@ -81,14 +81,15 @@ func HuggingFaceOrganizationApiToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("huggingface", "api_org_"+secrets.NewSecret("[a-zA-Z]{34}"))
|
||||||
|
tps = append(tps,
|
||||||
`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`,
|
`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`,
|
||||||
"`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`",
|
"`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`",
|
||||||
`\'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'\`,
|
`\'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'\`,
|
||||||
`\"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\"`,
|
//TODO: `\"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\"`,
|
||||||
`,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,`,
|
//TODO: `,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,`,
|
||||||
`(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)`,
|
//TODO: `(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)`,
|
||||||
`<foo>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</foo>`,
|
//TODO: `<foo>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</foo>`,
|
||||||
`def test_private_space(self):
|
`def test_private_space(self):
|
||||||
hf_token = "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" # Intentionally revealing this key for testing purposes
|
hf_token = "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" # Intentionally revealing this key for testing purposes
|
||||||
io = gr.load(`,
|
io = gr.load(`,
|
||||||
@@ -96,7 +97,7 @@ func HuggingFaceOrganizationApiToken() *config.Rule {
|
|||||||
`"news_train_dataset = datasets.load_dataset('nlpHakdang/aihub-news30k', data_files = \"train_news_text.csv\", use_auth_token='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')\n",`,
|
`"news_train_dataset = datasets.load_dataset('nlpHakdang/aihub-news30k', data_files = \"train_news_text.csv\", use_auth_token='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')\n",`,
|
||||||
`os.environ['HUGGINGFACEHUB_API_TOKEN'] = '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'`,
|
`os.environ['HUGGINGFACEHUB_API_TOKEN'] = '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'`,
|
||||||
fmt.Sprintf("api_org_%s", secrets.NewSecret(`[a-zA-Z]{34}`)),
|
fmt.Sprintf("api_org_%s", secrets.NewSecret(`[a-zA-Z]{34}`)),
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
`public static final String API_ORG_EXIST = "APIOrganizationExist";`,
|
`public static final String API_ORG_EXIST = "APIOrganizationExist";`,
|
||||||
`const api_org_controller = require('../../controllers/api/index').organizations;`,
|
`const api_org_controller = require('../../controllers/api/index').organizations;`,
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ func InfracostAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("ico", "ico-"+secrets.NewSecret("[A-Za-z0-9]{32}"))
|
||||||
utils.GenerateSampleSecret("ico", "ico-"+secrets.NewSecret("[A-Za-z0-9]{32}")),
|
tps = append(tps,
|
||||||
` variable {
|
` variable {
|
||||||
name = "INFRACOST_API_KEY"
|
name = "INFRACOST_API_KEY"
|
||||||
secret_value = "ico-mlCr1Mn3SRcRiZMObUZOTHLcgtH2Lpgt"
|
secret_value = "ico-mlCr1Mn3SRcRiZMObUZOTHLcgtH2Lpgt"
|
||||||
@@ -29,7 +29,7 @@ func InfracostAPIToken() *config.Rule {
|
|||||||
//'X-Api-Key': 'ico-EeDdSfctrmjD14f45f45te5gJ7l6lw4o6M36sXT62a6',
|
//'X-Api-Key': 'ico-EeDdSfctrmjD14f45f45te5gJ7l6lw4o6M36sXT62a6',
|
||||||
//'Content-Type': 'application/json',
|
//'Content-Type': 'application/json',
|
||||||
//}`,
|
//}`,
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
// Low entropy
|
// Low entropy
|
||||||
`ico-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`,
|
`ico-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`,
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ func Intercom() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("intercom", secrets.NewSecret(utils.AlphaNumericExtended("60")))
|
||||||
utils.GenerateSampleSecret("intercom", secrets.NewSecret(utils.AlphaNumericExtended("60"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,8 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
@@ -55,11 +55,10 @@ func JFrogIdentityToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("jfrog", secrets.NewSecret(utils.AlphaNumeric("64")))
|
||||||
utils.GenerateSampleSecret("jfrog", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
tps = append(tps, utils.GenerateSampleSecrets("artifactory", secrets.NewSecret(utils.AlphaNumeric("64")))...)
|
||||||
utils.GenerateSampleSecret("artifactory", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
tps = append(tps, utils.GenerateSampleSecrets("bintray", secrets.NewSecret(utils.AlphaNumeric("64")))...)
|
||||||
utils.GenerateSampleSecret("bintray", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
tps = append(tps, utils.GenerateSampleSecrets("xray", secrets.NewSecret(utils.AlphaNumeric("64")))...)
|
||||||
utils.GenerateSampleSecret("xray", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
tps = append(tps, fmt.Sprintf("\"artifactory\", \"%s\"", secrets.NewSecret(utils.AlphaNumeric("64"))))
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,11 @@ package rules
|
|||||||
import (
|
import (
|
||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
|
||||||
"regexp"
|
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func JWT() *config.Rule {
|
func JWT() *config.Rule {
|
||||||
@@ -20,7 +21,9 @@ func JWT() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{`eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0==`, // gitleaks:allow
|
tps := utils.GenerateSampleSecrets("jwt", secrets.NewSecret(`ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9\/\\_-]{17,}\.(?:[a-zA-Z0-9\/\\_-]{10,}={0,2})?`))
|
||||||
|
tps = append(tps,
|
||||||
|
`eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0==`, // gitleaks:allow
|
||||||
`JWT := eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0`, // gitleaks:allow
|
`JWT := eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwic3ViZSI6IjEyMzQ1Njc4OTAiLCJuYW1lZWEiOiJKb2huIERvZSIsInN1ZmV3YWZiIjoiMTIzNDU2Nzg5MCIsIm5hbWVmZWF3ZnciOiJKb2huIERvZSIsIm5hbWVhZmV3ZmEiOiJKb2huIERvZSIsInN1ZndhZndlYWIiOiIxMjM0NTY3ODkwIiwibmFtZWZ3YWYiOiJKb2huIERvZSIsInN1YmZ3YWYiOiIxMjM0NTY3ODkwIiwibmFtZndhZSI6IkpvaG4gRG9lIiwiaWZ3YWZhYXQiOjE1MTYyMzkwMjJ9.a_5icKBDo-8EjUlrfvz2k2k-FYaindQ0DEYNrlsnRG0`, // gitleaks:allow
|
||||||
`"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJRMzFDVlMxUFNDSjRPVEsyWVZFTSIsImF0X2hhc2giOiI4amItZFE2OXRtZEVueUZaMUttNWhnIiwiYXVkIjoiZXhhbXBsZS1hcHAiLCJlbWFpbCI6ImFkbWluQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV4cCI6IjE1OTQ2MDAxODIiLCJpYXQiOjE1OTQ1ODkzODQsImlzcyI6Imh0dHA6Ly8xMjcuMC4wLjE6NTU1Ni9kZXgiLCJuYW1lIjoiYWRtaW4iLCJzdWIiOiJDaVF3T0dFNE5qZzBZaTFrWWpnNExUUmlOek10T1RCaE9TMHpZMlF4TmpZeFpqVTBOallTQld4dlkyRnMifQ.nrbzIJz99Om7TvJ04jnSTmhvlM7aR9hMM1Aqjp2ONJ1UKYCvegBLrTu6cYR968_OpmnAGJ8vkd7sIjUjtR4zbw"`, // gitleaks:allow
|
`"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiJRMzFDVlMxUFNDSjRPVEsyWVZFTSIsImF0X2hhc2giOiI4amItZFE2OXRtZEVueUZaMUttNWhnIiwiYXVkIjoiZXhhbXBsZS1hcHAiLCJlbWFpbCI6ImFkbWluQGV4YW1wbGUuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV4cCI6IjE1OTQ2MDAxODIiLCJpYXQiOjE1OTQ1ODkzODQsImlzcyI6Imh0dHA6Ly8xMjcuMC4wLjE6NTU1Ni9kZXgiLCJuYW1lIjoiYWRtaW4iLCJzdWIiOiJDaVF3T0dFNE5qZzBZaTFrWWpnNExUUmlOek10T1RCaE9TMHpZMlF4TmpZeFpqVTBOallTQld4dlkyRnMifQ.nrbzIJz99Om7TvJ04jnSTmhvlM7aR9hMM1Aqjp2ONJ1UKYCvegBLrTu6cYR968_OpmnAGJ8vkd7sIjUjtR4zbw"`, // gitleaks:allow
|
||||||
`https://dai2-playlistserver.aws.syncbak.com/cpl/20980038/dai2v5/1.0/7b2264657669636554797065223a387d/master.m3u8?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkdyYXkyMDE2MDgyOSJ9.eyJtaWQiOiIyMDk4MDAzOCIsImNpZCI6MjE5MDMsInNpZCI6MTU4LCJtZDUiOiIwN2QxMmRjNjAwOTM2MGI0MmY3NjNkNTRiMWIwZjI1NCIsImlhdCI6MTY2MDkxMzU2MCwiZXhwIjoxNjkyNDQ5NTYwLCJpc3MiOiJTeW5jYmFrIChURykifQ.JrWVgwzIn_RcNuWhkzIjr1i4qjXU1v4n0KFrSzoTQvQ`, // gitleaks:allow `
|
`https://dai2-playlistserver.aws.syncbak.com/cpl/20980038/dai2v5/1.0/7b2264657669636554797065223a387d/master.m3u8?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkdyYXkyMDE2MDgyOSJ9.eyJtaWQiOiIyMDk4MDAzOCIsImNpZCI6MjE5MDMsInNpZCI6MTU4LCJtZDUiOiIwN2QxMmRjNjAwOTM2MGI0MmY3NjNkNTRiMWIwZjI1NCIsImlhdCI6MTY2MDkxMzU2MCwiZXhwIjoxNjkyNDQ5NTYwLCJpc3MiOiJTeW5jYmFrIChURykifQ.JrWVgwzIn_RcNuWhkzIjr1i4qjXU1v4n0KFrSzoTQvQ`, // gitleaks:allow `
|
||||||
@@ -61,7 +64,7 @@ func JWT() *config.Rule {
|
|||||||
// `eyJhbGciOiJFQ0RILUVTIiwiZW5jIjoiQTI1NkdDTSIsImVwayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMzg0Iiwia2V5X29wcyI6W10sImV4dCI6dHJ1ZSwieCI6IllUcEY3bGtTc3JvZVVUVFdCb21LNzBTN0FhVTJyc0ptMURpZ1ZzbjRMY2F5eUxFNFBabldkYmFVcE9jQVV5a1ciLCJ5IjoiLU5pS3loUktjSk52Nm02Z0ZJUWc4cy1Xd1VXUW9uT3A5dkQ4cHpoa2tUU3U2RzFlU2FUTVlhZGltQ2Q4V0ExMSJ9LCJhcHUiOiIiLCJhcHYiOiIifQ`,
|
// `eyJhbGciOiJFQ0RILUVTIiwiZW5jIjoiQTI1NkdDTSIsImVwayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMzg0Iiwia2V5X29wcyI6W10sImV4dCI6dHJ1ZSwieCI6IllUcEY3bGtTc3JvZVVUVFdCb21LNzBTN0FhVTJyc0ptMURpZ1ZzbjRMY2F5eUxFNFBabldkYmFVcE9jQVV5a1ciLCJ5IjoiLU5pS3loUktjSk52Nm02Z0ZJUWc4cy1Xd1VXUW9uT3A5dkQ4cHpoa2tUU3U2RzFlU2FUTVlhZGltQ2Q4V0ExMSJ9LCJhcHUiOiIiLCJhcHYiOiIifQ`,
|
||||||
`String tokenWithNoneAlg = "eyJhbGciOiJub25lIn0.eyJzdWIiOiJ0ZXN0LXVzZXIifQ.";`, // gitleaks:allow
|
`String tokenWithNoneAlg = "eyJhbGciOiJub25lIn0.eyJzdWIiOiJ0ZXN0LXVzZXIifQ.";`, // gitleaks:allow
|
||||||
`# Req: Invoke-RestMethod -Uri 'http://localhost:8085/users' -Headers @{ 'X-API-KEY' = 'eyJhbGciOiJub25lIn0.eyJ1c2VybmFtZSI6Im1vcnR5Iiwic3ViIjoiMTIzIn0.' }`, // gitleaks:allow
|
`# Req: Invoke-RestMethod -Uri 'http://localhost:8085/users' -Headers @{ 'X-API-KEY' = 'eyJhbGciOiJub25lIn0.eyJ1c2VybmFtZSI6Im1vcnR5Iiwic3ViIjoiMTIzIn0.' }`, // gitleaks:allow
|
||||||
}
|
)
|
||||||
fps := []string{}
|
fps := []string{}
|
||||||
return utils.Validate(r, tps, fps)
|
return utils.Validate(r, tps, fps)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ func KrakenAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("kraken", secrets.NewSecret(utils.AlphaNumericExtendedLong("80,90")))
|
||||||
utils.GenerateSampleSecret("kraken",
|
|
||||||
secrets.NewSecret(utils.AlphaNumericExtendedLong("80,90"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,22 +2,22 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KubernetesSecret validates if we detected a kubernetes secret which contains data!
|
// KubernetesSecret validates if we detected a kubernetes secret which contains data!
|
||||||
func KubernetesSecret() *config.Rule {
|
func KubernetesSecret() *config.Rule {
|
||||||
// Only match basic variations of `kind: secret`, we don't want things like `kind: ExternalSecret`.
|
// Only match basic variations of `kind: secret`, we don't want things like `kind: ExternalSecret`.
|
||||||
//language=regexp
|
//language=regexp
|
||||||
kindPat := `\bkind:[ \t]*["']?secret["']?`
|
kindPat := `\bkind:[ \t]*["']?\bsecret\b["']?`
|
||||||
// Only matches values (`key: value`) under `data:` that are:
|
// Only matches values (`key: value`) under `data:` that are:
|
||||||
// - valid base64 characters
|
// - valid base64 characters
|
||||||
// - longer than 10 characters (no "YmFyCg==")
|
// - longer than 10 characters (no "YmFyCg==")
|
||||||
//language=regexp
|
//language=regexp
|
||||||
dataPat := `\bdata:(?:.|\s){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9+/]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))`
|
dataPat := `\bdata:(?s:.){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9+/]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))`
|
||||||
|
|
||||||
// define rule
|
// define rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
@@ -25,13 +25,13 @@ func KubernetesSecret() *config.Rule {
|
|||||||
Description: "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments",
|
Description: "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments",
|
||||||
Regex: regexp.MustCompile(fmt.Sprintf(
|
Regex: regexp.MustCompile(fmt.Sprintf(
|
||||||
//language=regexp
|
//language=regexp
|
||||||
`(?i)(?:%s(?:.|\s){0,200}?%s|%s(?:.|\s){0,200}?%s)`, kindPat, dataPat, dataPat, kindPat)),
|
`(?i)(?:%s(?s:.){0,200}?%s|%s(?s:.){0,200}?%s)`, kindPat, dataPat, dataPat, kindPat)),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"secret",
|
"secret",
|
||||||
},
|
},
|
||||||
// Kubernetes secrets are usually yaml files.
|
// Kubernetes secrets are usually yaml files.
|
||||||
Path: regexp.MustCompile(`(?i)\.ya?ml$`),
|
Path: regexp.MustCompile(`(?i)\.ya?ml$`),
|
||||||
Allowlists: []config.Allowlist{
|
Allowlists: []*config.Allowlist{
|
||||||
{
|
{
|
||||||
Regexes: []*regexp.Regexp{
|
Regexes: []*regexp.Regexp{
|
||||||
// Ignore empty or placeholder values.
|
// Ignore empty or placeholder values.
|
||||||
@@ -41,6 +41,13 @@ func KubernetesSecret() *config.Rule {
|
|||||||
regexp.MustCompile(`[\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:\{\{[ \t\w"|$:=,.-]+}}|""|'')`),
|
regexp.MustCompile(`[\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:\{\{[ \t\w"|$:=,.-]+}}|""|'')`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// Avoid overreach between directives.
|
||||||
|
RegexTarget: "match",
|
||||||
|
Regexes: []*regexp.Regexp{
|
||||||
|
regexp.MustCompile(`(kind:(?s:.)+\n---\n(?s:.)+\bdata:|data:(?s:.)+\n---\n(?s:.)+\bkind:)`),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,6 +246,42 @@ metadata:
|
|||||||
name: kubernetes-dashboard-key-holder
|
name: kubernetes-dashboard-key-holder
|
||||||
namespace: kubernetes-dashboard
|
namespace: kubernetes-dashboard
|
||||||
type: Opaque
|
type: Opaque
|
||||||
|
`,
|
||||||
|
"overly-permissive3.yaml": ` kind: Secret
|
||||||
|
target:
|
||||||
|
name: mysecret
|
||||||
|
creationPolicy: Owner
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
kind: ConfigMap
|
||||||
|
data:
|
||||||
|
conversionStrategy: Default
|
||||||
|
decodingStrategy: None
|
||||||
|
key: secret/mysecret
|
||||||
|
property: foo
|
||||||
|
secretKey: foo`,
|
||||||
|
// https://github.com/gitleaks/gitleaks/issues/1644
|
||||||
|
"wrong-kind.yaml": `apiVersion: external-secrets.io/v1beta1
|
||||||
|
kind: ExternalSecret
|
||||||
|
metadata:
|
||||||
|
name: example
|
||||||
|
namespace: example-ns
|
||||||
|
spec:
|
||||||
|
refreshInterval: 15s
|
||||||
|
secretStoreRef:
|
||||||
|
name: example
|
||||||
|
kind: SecretStore
|
||||||
|
target:
|
||||||
|
name: mysecret
|
||||||
|
creationPolicy: Owner
|
||||||
|
data:
|
||||||
|
- remoteRef:
|
||||||
|
conversionStrategy: Default
|
||||||
|
decodingStrategy: None
|
||||||
|
key: secret/mysecret
|
||||||
|
property: foo
|
||||||
|
secretKey: foo
|
||||||
`,
|
`,
|
||||||
"sopssecret.yaml": `apiVersion: isindir.github.com/v1alpha3
|
"sopssecret.yaml": `apiVersion: isindir.github.com/v1alpha3
|
||||||
kind: SopsSecret
|
kind: SopsSecret
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ func KucoinAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("kucoin", secrets.NewSecret(utils.Hex("24")))
|
||||||
utils.GenerateSampleSecret("kucoin", secrets.NewSecret(utils.Hex("24"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,8 +36,6 @@ func KucoinSecretKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("kucoin", secrets.NewSecret(utils.Hex8_4_4_4_12()))
|
||||||
utils.GenerateSampleSecret("kucoin", secrets.NewSecret(utils.Hex8_4_4_4_12())),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -19,8 +19,6 @@ func LaunchDarklyAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("launchdarkly", secrets.NewSecret(utils.AlphaNumericExtended("40")))
|
||||||
utils.GenerateSampleSecret("launchdarkly", secrets.NewSecret(utils.AlphaNumericExtended("40"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,9 @@ package rules
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
"regexp"
|
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func LinearAPIToken() *config.Rule {
|
func LinearAPIToken() *config.Rule {
|
||||||
@@ -19,9 +18,7 @@ func LinearAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("linear", "lin_api_"+secrets.NewSecret(utils.AlphaNumeric("40")))
|
||||||
utils.GenerateSampleSecret("linear", "lin_api_"+secrets.NewSecret(utils.AlphaNumeric("40"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,8 +33,6 @@ func LinearClientSecret() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("linear", secrets.NewSecret(utils.Hex("32")))
|
||||||
utils.GenerateSampleSecret("linear", secrets.NewSecret(utils.Hex("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -6,48 +6,42 @@ import (
|
|||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func LinkedinClientID() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "linkedin-client-id",
|
||||||
|
Description: "Found a LinkedIn Client ID, risking unauthorized access to LinkedIn integrations and professional data exposure.",
|
||||||
|
Regex: utils.GenerateSemiGenericRegex([]string{"linked[_-]?in"}, utils.AlphaNumeric("14"), true),
|
||||||
|
Entropy: 2,
|
||||||
|
Keywords: []string{
|
||||||
|
"linkedin",
|
||||||
|
"linked_in",
|
||||||
|
"linked-in",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("linkedin", secrets.NewSecret(utils.AlphaNumeric("14")))
|
||||||
|
return utils.Validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
func LinkedinClientSecret() *config.Rule {
|
func LinkedinClientSecret() *config.Rule {
|
||||||
// define rule
|
// define rule
|
||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "linkedin-client-secret",
|
RuleID: "linkedin-client-secret",
|
||||||
Description: "Discovered a LinkedIn Client secret, potentially compromising LinkedIn application integrations and user data.",
|
Description: "Discovered a LinkedIn Client secret, potentially compromising LinkedIn application integrations and user data.",
|
||||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||||
"linkedin",
|
"linked[_-]?in",
|
||||||
"linked-in",
|
|
||||||
}, utils.AlphaNumeric("16"), true),
|
}, utils.AlphaNumeric("16"), true),
|
||||||
|
Entropy: 2,
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"linkedin",
|
"linkedin",
|
||||||
|
"linked_in",
|
||||||
"linked-in",
|
"linked-in",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("linkedin", secrets.NewSecret(utils.AlphaNumeric("16")))
|
||||||
utils.GenerateSampleSecret("linkedin", secrets.NewSecret(utils.AlphaNumeric("16"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func LinkedinClientID() *config.Rule {
|
|
||||||
// define rule
|
|
||||||
r := config.Rule{
|
|
||||||
RuleID: "linkedin-client-id",
|
|
||||||
Description: "Found a LinkedIn Client ID, risking unauthorized access to LinkedIn integrations and professional data exposure.",
|
|
||||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
|
||||||
"linkedin",
|
|
||||||
"linked-in",
|
|
||||||
}, utils.AlphaNumeric("14"), true),
|
|
||||||
|
|
||||||
Keywords: []string{
|
|
||||||
"linkedin",
|
|
||||||
"linked-in",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// validate
|
|
||||||
tps := []string{
|
|
||||||
utils.GenerateSampleSecret("linkedin", secrets.NewSecret(utils.AlphaNumeric("14"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -21,9 +21,7 @@ func LobPubAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("lob", "test_pub_"+secrets.NewSecret(utils.Hex("31")))
|
||||||
utils.GenerateSampleSecret("lob", "test_pub_"+secrets.NewSecret(utils.Hex("31"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,8 +38,6 @@ func LobAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("lob", "test_"+secrets.NewSecret(utils.Hex("35")))
|
||||||
utils.GenerateSampleSecret("lob", "test_"+secrets.NewSecret(utils.Hex("35"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func LookerClientID() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Found a Looker Client ID, risking unauthorized access to a Looker account and exposing sensitive data.",
|
||||||
|
RuleID: "looker-client-id",
|
||||||
|
Regex: utils.GenerateSemiGenericRegex([]string{"looker"}, utils.AlphaNumeric("20"), true),
|
||||||
|
Keywords: []string{"looker"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("looker", secrets.NewSecret(utils.AlphaNumeric("20")))
|
||||||
|
return utils.Validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func LookerClientSecret() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Found a Looker Client Secret, risking unauthorized access to a Looker account and exposing sensitive data.",
|
||||||
|
RuleID: "looker-client-secret",
|
||||||
|
Regex: utils.GenerateSemiGenericRegex([]string{"looker"}, utils.AlphaNumeric("24"), true),
|
||||||
|
Keywords: []string{"looker"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("looker", secrets.NewSecret(utils.AlphaNumeric("24")))
|
||||||
|
return utils.Validate(r, tps, nil)
|
||||||
|
}
|
||||||
@@ -19,11 +19,11 @@ func MailChimp() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("mailchimp", secrets.NewSecret(utils.Hex("32"))+"-us20")
|
||||||
utils.GenerateSampleSecret("mailchimp", secrets.NewSecret(utils.Hex("32"))+"-us20"),
|
tps = append(tps,
|
||||||
`mailchimp_api_key: cefa780880ba5f5696192a34f6292c35-us18`, // gitleaks:allow
|
`mailchimp_api_key: cefa780880ba5f5696192a34f6292c35-us18`, // gitleaks:allow
|
||||||
`MAILCHIMPE_KEY = "b5b9f8e50c640da28993e8b6a48e3e53-us18"`, // gitleaks:allow
|
`MAILCHIMPE_KEY = "b5b9f8e50c640da28993e8b6a48e3e53-us18"`, // gitleaks:allow
|
||||||
}
|
)
|
||||||
fps := []string{
|
fps := []string{
|
||||||
// False Negative
|
// False Negative
|
||||||
`MailchimpSDK.initialize(token: 3012a5754bbd716926f99c028f7ea428-us18)`, // gitleaks:allow
|
`MailchimpSDK.initialize(token: 3012a5754bbd716926f99c028f7ea428-us18)`, // gitleaks:allow
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ func MailGunPrivateAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("mailgun", "key-"+secrets.NewSecret(utils.Hex("32")))
|
||||||
utils.GenerateSampleSecret("mailgun", "key-"+secrets.NewSecret(utils.Hex("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,9 +36,7 @@ func MailGunPubAPIToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("mailgun", "pubkey-"+secrets.NewSecret(utils.Hex("32")))
|
||||||
utils.GenerateSampleSecret("mailgun", "pubkey-"+secrets.NewSecret(utils.Hex("32"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,8 +53,6 @@ func MailGunSigningKey() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("mailgun", secrets.NewSecret(utils.Hex("32"))+"-00001111-22223333")
|
||||||
utils.GenerateSampleSecret("mailgun", secrets.NewSecret(utils.Hex("32"))+"-00001111-22223333"),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,6 @@ func MapBox() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("mapbox", "pk."+secrets.NewSecret(utils.AlphaNumeric("60"))+"."+secrets.NewSecret(utils.AlphaNumeric("22")))
|
||||||
utils.GenerateSampleSecret("mapbox", "pk."+secrets.NewSecret(utils.AlphaNumeric("60"))+"."+secrets.NewSecret(utils.AlphaNumeric("22"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -19,8 +19,6 @@ func MattermostAccessToken() *config.Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := utils.GenerateSampleSecrets("mattermost", secrets.NewSecret(utils.AlphaNumeric("26")))
|
||||||
utils.GenerateSampleSecret("mattermost", secrets.NewSecret(utils.AlphaNumeric("26"))),
|
|
||||||
}
|
|
||||||
return utils.Validate(r, tps, nil)
|
return utils.Validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func MaxMindLicenseKey() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "maxmind-license-key",
|
||||||
|
Description: "Discovered a potential MaxMind license key.",
|
||||||
|
Regex: utils.GenerateUniqueTokenRegex(`[A-Za-z0-9]{6}_[A-Za-z0-9]{29}_mmk`, false),
|
||||||
|
Entropy: 4,
|
||||||
|
Keywords: []string{"_mmk"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := utils.GenerateSampleSecrets("maxmind", `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`) // gitleaks:allow
|
||||||
|
return utils.Validate(r, tps, nil)
|
||||||
|
}
|
||||||
Loaded 100 of 312 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user