Compare commits

..
Author SHA1 Message Date
Zachary Rice 778808a286 Update release.yml 2022-11-28 10:35:07 -06:00
Zachary Rice 7a957cd36b Update release.yml 2022-11-28 10:16:58 -06:00
Zachary Rice 3ca542796b Update release.yml 2022-11-28 09:54:14 -06:00
Zachary Rice 53793bef90 Update release.yml 2022-11-28 09:42:28 -06:00
Zach Rice 6492389e99 testing out adding more labels for docker releases 2022-11-28 09:40:23 -06:00
240 changed files with 4907 additions and 6601 deletions

No files matched your search

-8
View File
@@ -27,11 +27,3 @@ If applicable, add screenshots to help explain your problem.
Add any other context about the problem here. Add any other context about the problem here.
cc @zricethezav cc @zricethezav
<!--
Check out the Secret Scanning Discord Server for live discussions:
https://discord.gg/sydS6AHTUP
--->
+1 -2
View File
@@ -1,5 +1,5 @@
name: gitleaks name: gitleaks
on: [push, workflow_dispatch] on: [pull_request, push, workflow_dispatch]
jobs: jobs:
scan: scan:
name: gitleaks name: gitleaks
@@ -11,4 +11,3 @@ jobs:
- uses: gitleaks/gitleaks-action@v2 - uses: gitleaks/gitleaks-action@v2
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}
+7 -3
View File
@@ -2,7 +2,7 @@ name: Create and publish a Docker image
on: on:
release: release:
types: [published] types: [published, prereleased]
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
@@ -41,14 +41,18 @@ 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@v4
with: with:
images: | images: |
zricethezav/gitleaks zricethezav/gitleaks
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}
type=semver,pattern=v{{major}}.{{minor}}
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 uses: docker/build-push-action@v3
with: with:
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
context: . context: .
+2 -5
View File
@@ -1,9 +1,6 @@
name: Test name: Test
on: on:
push:
branches:
- "*"
pull_request: pull_request:
branches: branches:
- "*" - "*"
@@ -12,7 +9,7 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
@@ -26,4 +23,4 @@ jobs:
run: make test run: make test
- name: Validate Config - name: Validate Config
run: go generate ./... && git diff --exit-code run: cd cmd/generate/config && go run main.go
-3
View File
@@ -14,9 +14,6 @@ build
.gitleaks.toml .gitleaks.toml
cmd/generate/config/gitleaks.toml cmd/generate/config/gitleaks.toml
# test results
testdata/expected/report/*.got.*
# Test binary # Test binary
*.out *.out
-16
View File
@@ -716,9 +716,6 @@ testdata/expected/git/small-branch-foo.txt:aws-access-token:15
testdata/expected/git/small.txt:aws-access-token:15 testdata/expected/git/small.txt:aws-access-token:15
testdata/expected/git/small.txt:aws-access-token:44 testdata/expected/git/small.txt:aws-access-token:44
testdata/repos/nogit/main.go:aws-access-token:20 testdata/repos/nogit/main.go:aws-access-token:20
testdata/repos/nogit/api.go:aws-access-token:20
testdata/repos/small/api/ignoreCommit.go:aws-access-token:20
testdata/repos/small/api/ignoreGlobal.go:aws-access-token:20
3df8c3deb7bc1e34210bdbce114f1c6165bc6ac8:detect/detect_test.go:aws-access-token:513 3df8c3deb7bc1e34210bdbce114f1c6165bc6ac8:detect/detect_test.go:aws-access-token:513
3df8c3deb7bc1e34210bdbce114f1c6165bc6ac8:detect/detect_test.go:aws-access-token:492 3df8c3deb7bc1e34210bdbce114f1c6165bc6ac8:detect/detect_test.go:aws-access-token:492
3df8c3deb7bc1e34210bdbce114f1c6165bc6ac8:detect/detect_test.go:aws-access-token:414 3df8c3deb7bc1e34210bdbce114f1c6165bc6ac8:detect/detect_test.go:aws-access-token:414
@@ -752,17 +749,4 @@ acce01f2338434a78f6a4a06a097b0fd23280484:README.md:aws-access-token:220
111c8b47b65627db117bd20be85ff0aee8961eb9:detect/detect_test.go:private-key:567 111c8b47b65627db117bd20be85ff0aee8961eb9:detect/detect_test.go:private-key:567
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:512 99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:512
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:513 99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:513
69f161c0a0cc0f7858f7d0609d656f4edcedd84c:detect/detect_test.go:discord-api-token:326
9701bf1724d822c0d5bbb7627535dd639a37bf56:testdata/repos/staged/api/api.go:aws-access-token:7
9701bf1724d822c0d5bbb7627535dd639a37bf56:detect/detect_test.go:aws-access-token:505
9701bf1724d822c0d5bbb7627535dd639a37bf56:detect/detect_test.go:aws-access-token:506
9701bf1724d822c0d5bbb7627535dd639a37bf56:detect/detect_test.go:aws-access-token:507
9701bf1724d822c0d5bbb7627535dd639a37bf56:testdata/repos/staged/api/api.go:aws-access-token:6
9701bf1724d822c0d5bbb7627535dd639a37bf56:testdata/repos/staged/api/api.go:aws-access-token:7
91ff8f9b7020a16dac9b8b9ef98560ea1cb464f8:testdata/repos/small/api/ignoreCommit.go:aws-access-token:20
91ff8f9b7020a16dac9b8b9ef98560ea1cb464f8:testdata/repos/small/api/ignoreGlobal.go:aws-access-token:20
91ff8f9b7020a16dac9b8b9ef98560ea1cb464f8:testdata/repos/nogit/api.go:aws-access-token:20
adf617b3b4628e1160fa3d135b4c3dfd45c05e15:testdata/repos/nogit/api.go:aws-access-token:20
adf617b3b4628e1160fa3d135b4c3dfd45c05e15:testdata/repos/small/api/ignoreGlobal.go:aws-access-token:20
adf617b3b4628e1160fa3d135b4c3dfd45c05e15:testdata/repos/small/api/ignoreCommit.go:aws-access-token:20
-5
View File
@@ -9,8 +9,3 @@
description: Detect hardcoded secrets using Gitleaks description: Detect hardcoded secrets using Gitleaks
entry: zricethezav/gitleaks protect --verbose --redact --staged entry: zricethezav/gitleaks protect --verbose --redact --staged
language: docker_image language: docker_image
- id: gitleaks-system
name: Detect hardcoded secrets
description: Detect hardcoded secrets using Gitleaks
entry: gitleaks protect --verbose --redact --staged
language: system
+15 -11
View File
@@ -28,18 +28,18 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
func Beamer() *config.Rule { func Beamer() *config.Rule {
// Define Rule // Define Rule
r := config.Rule{ r := config.Rule{
// Human readable description of the rule // Human redable description of the rule
Description: "Beamer API token", Description: "Beamer API token",
// Unique ID for the rule // Unique ID for the rule
RuleID: "beamer-api-token", RuleID: "beamer-api-token",
// Regex capture group for the actual secret // Regex capture group for the actual secret
SecretGroup: 1,
// Regex used for detecting secrets. See regex section below for more details // Regex used for detecting secrets. See regex section below for more details
Regex: generateSemiGenericRegex([]string{"beamer"}, `b_[a-z0-9=_\-]{44}`, true) Regex: generateSemiGenericRegex([]string{"beamer"}, `b_[a-z0-9=_\-]{44}`),
// Keywords used for string matching on fragments (think of this as a prefilter) // Keywords used for string matching on fragments (think of this as a prefilter)
Keywords: []string{"beamer"}, Keywords: []string{"beamer"},
@@ -63,22 +63,22 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
The function signatures look like this: The function signatures look like this:
```golang ```golang
func generateSemiGenericRegex(identifiers []string, secretRegex string, isCaseInsensitive bool) *regexp.Regexp func generateSemiGenericRegex(identifiers []string, secretRegex string) *regexp.Regexp
func generateUniqueTokenRegex(secretRegex string, isCaseInsensitive bool) *regexp.Regexp func generateUniqueTokenRegex(secretRegex string) *regexp.Regexp
``` ```
`generateSemiGenericRegex` accepts a list of identifiers, a regex, and a boolean indicating whether the pattern should be case-insensitive. `generateSemiGenericRegex` accepts a list of identifiers and a regex.
The list of identifiers _should_ match the list of `Keywords` in the rule The list of identifiers _should_ match the list of `Keywords` in the rule
definition above. Both `identifiers` in the `generateSemiGenericRegex` definition above. Both `identifiers` in the `generateSemiGenericRegex`
function _and_ `Keywords` act as filters for Gitleaks telling the program function _and_ `Keywords` act as filters for Gitleaks telling the program
"_at least one of these strings must be present to be considered a leak_" "_at least one of these strings must be present to be considered a leak_"
`generateUniqueToken` just accepts a regex and a boolean indicating whether the pattern should be case-insensitive. If you are writing a rule for a `generateUniqueToken` just accepts a regex. If you are writing a rule for a
token that is unique enough not to require an identifier then you can use token that is unique enough not to require an identifier then you can use
this function. For example, Pulumi's API Token has the prefix `pul-` which is this function. For example, Pulumi's API Token has the prefix `pul-` which is
unique enough to use `generateUniqueToken`. But something like Beamer's API unique enough to use `generateUniqueToken`. But something like Beamer's API
token that has a `b_` prefix is not unique enough to use `generateUniqueToken`, token that has a `b_` prefix is not unqiue enough to use `generateUniqueToken`,
so instead we use `generateSemiGenericRegex` and require a `beamer` so instead we use `generateSemiGenericRegex` and require a `beamer`
identifier is part of the rule. identifier is part of the rule.
If a token's prefix has more than `3` characters then you could If a token's prefix has more than `3` characters then you could
@@ -88,11 +88,15 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
validation part. You can use `generateSampleSecret` to create a secret for the validation part. You can use `generateSampleSecret` to create a secret for the
true positives (`tps` in the example above) used in `validate`. true positives (`tps` in the example above) used in `validate`.
1. Update `cmd/generate/config/main.go`. Extend `configRules` slice with 1. Update `cmd/generate/config/main.go`. Add a line like
the `rules.Beamer(),` in `main()`. Try and keep `configRules = append(configRules, rules.Beamer())` in `main()`. Try and keep
this alphabetically pretty please. this alphabetically pretty please.
1. Run `go generate ./...` 1. Change directories into `cmd/generate/config` and run `go run main.go`
```
cd cmd/generate/config && go run main.go
```
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 -1
View File
@@ -5,8 +5,10 @@ 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/cmd.Version=${VERSION}
FROM alpine:3.16 FROM alpine:3.16
RUN apk add --no-cache bash git openssh-client RUN adduser -D gitleaks && \
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/
USER gitleaks
RUN git config --global --add safe.directory '*' RUN git config --global --add safe.directory '*'
+2
View File
@@ -13,9 +13,11 @@ format:
go fmt ./... go fmt ./...
test: format test: format
go vet ./...
go test -v ./... --race $(PKG) go test -v ./... --race $(PKG)
build: format build: format
go vet ./...
go mod tidy go mod tidy
go build $(LDFLAGS) go build $(LDFLAGS)
+19 -27
View File
@@ -16,6 +16,9 @@
<a href="https://hub.docker.com/r/zricethezav/gitleaks"> <a href="https://hub.docker.com/r/zricethezav/gitleaks">
<img src="https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg" /> <img src="https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg" />
</a> </a>
<a href="https://www.jit.io/jit-open-source-gitleaks?utm_source=github&utm_medium=badge&utm_campaign=GitleaksReadme&utm_id=oss&items=item-secret-detection">
<img src="https://img.shields.io/badge/Secured%20by-Jit-B8287F?style=?style=plastic" />
</a>
<a href="https://github.com/zricethezav/gitleaks-action"> <a href="https://github.com/zricethezav/gitleaks-action">
<img alt="gitleaks badge" src="https://img.shields.io/badge/protected%20by-gitleaks-blue"> <img alt="gitleaks badge" src="https://img.shields.io/badge/protected%20by-gitleaks-blue">
</a> </a>
@@ -25,8 +28,6 @@
</p> </p>
</p> </p>
### Join our Discord! [![Discord](https://img.shields.io/discord/1102689410522284044.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/8Hzbrnkr7E)
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. 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.
``` ```
@@ -67,16 +68,16 @@ docker pull zricethezav/gitleaks:latest
docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] --source="/path" [OPTIONS] docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] --source="/path" [OPTIONS]
# Docker (ghcr.io) # Docker (ghcr.io)
docker pull ghcr.io/gitleaks/gitleaks:latest docker pull ghcr.io/zricethezav/gitleaks:latest
docker run -v ${path_to_host_folder_to_scan}:/path ghcr.io/gitleaks/gitleaks:latest [COMMAND] --source="/path" [OPTIONS] docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] --source="/path" [OPTIONS]
# From Source # From Source
git clone https://github.com/gitleaks/gitleaks.git git clone https://github.com/zricethezav/gitleaks.git
cd gitleaks cd gitleaks
make build make build
``` ```
### GitHub Action ### Github Action
Check out the official [Gitleaks GitHub Action](https://github.com/gitleaks/gitleaks-action) Check out the official [Gitleaks GitHub Action](https://github.com/gitleaks/gitleaks-action)
@@ -104,8 +105,8 @@ jobs:
``` ```
repos: repos:
- repo: https://github.com/gitleaks/gitleaks - repo: https://github.com/zricethezav/gitleaks
rev: v8.16.1 rev: v8.12.0
hooks: hooks:
- id: gitleaks - id: gitleaks
``` ```
@@ -154,12 +155,11 @@ Flags:
-h, --help help for gitleaks -h, --help help for gitleaks
-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-target-megabytes int files larger than this will be skipped --max-target-megabytes int files larger than this will be skipped
--no-color turn off color for verbose output
--no-banner suppress banner --no-banner suppress banner
--redact redact secrets from logs and stdout --redact redact secrets from logs and stdout
-f, --report-format string output format (json, csv, junit, sarif) (default "json") -f, --report-format string output format (json, csv, sarif) (default "json")
-r, --report-path string report file -r, --report-path string report file
-s, --source string path to source (default ".") -s, --source string path to source (default: $PWD) (default ".")
-v, --verbose show verbose output from scan -v, --verbose show verbose output from scan
Use "gitleaks [command] --help" for more information about a command. Use "gitleaks [command] --help" for more information about a command.
@@ -182,11 +182,9 @@ See the `git log` [documentation](https://git-scm.com/docs/git-log) for more inf
You can scan files and directories by using the `--no-git` option. You can scan files and directories by using the `--no-git` option.
If you want to run only specific rules you can do so by using the `--enable-rule` option (with a rule ID as a parameter), this flag can be used multiple times. For example: `--enable-rule=atlassian-api-token` will only apply that rule. You can find a list of rules [here](config/gitleaks.toml).
#### Protect #### Protect
The `protect` command is used to scan uncommitted changes in a git repo. This command should be used on developer machines in accordance with The `protect` command is used to uncommitted changes in a git repo. This command should be used on developer machines in accordance with
[shifting left on security](https://cloud.google.com/architecture/devops/devops-tech-shifting-left-on-security). [shifting left on security](https://cloud.google.com/architecture/devops/devops-tech-shifting-left-on-security).
When running `protect` on a git repository, gitleaks will parse the output of a `git diff` command (you can see how this executed When running `protect` on a git repository, gitleaks will parse the output of a `git diff` command (you can see how this executed
[here](https://github.com/zricethezav/gitleaks/blob/7240e16769b92d2a1b137c17d6bf9d55a8562899/git/git.go#L48-L49)). You can set the [here](https://github.com/zricethezav/gitleaks/blob/7240e16769b92d2a1b137c17d6bf9d55a8562899/git/git.go#L48-L49)). You can set the
@@ -274,7 +272,7 @@ Gitleaks offers a configuration format you can follow to write your own secret d
title = "Gitleaks title" title = "Gitleaks title"
# Extend the base (this) configuration. When you extend a configuration # Extend the base (this) configuration. When you extend a configuration
# the base rules take precedence over the extended rules. I.e., if there are # the base rules take precendence over the extended rules. I.e, if there are
# duplicate rules in both the base configuration and the extended configuration # duplicate rules in both the base configuration and the extended configuration
# the base rules will override the extended rules. # the base rules will override the extended rules.
# Another thing to know with extending configurations is you can chain together # Another thing to know with extending configurations is you can chain together
@@ -337,10 +335,6 @@ paths = [
'''go\.mod''', '''go\.mod''',
'''go\.sum''' '''go\.sum'''
] ]
# note: (rule) 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"
regexTarget = "match"
regexes = [ regexes = [
'''process''', '''process''',
'''getenv''', '''getenv''',
@@ -363,12 +357,6 @@ paths = [
'''gitleaks\.toml''', '''gitleaks\.toml''',
'''(.*?)(jpg|gif|doc)''' '''(.*?)(jpg|gif|doc)'''
] ]
# 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"
regexTarget = "match"
regexes = [ regexes = [
'''219-09-9999''', '''219-09-9999''',
'''078-05-1120''', '''078-05-1120''',
@@ -382,7 +370,7 @@ stopwords = [
] ]
``` ```
Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/zricethezav/gitleaks/blob/master/README.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/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/zricethezav/gitleaks/blob/master/README.md).
### Additional Configuration ### Additional Configuration
@@ -399,7 +387,11 @@ class CustomClass:
#### .gitleaksignore #### .gitleaksignore
You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. Note: this feature is experimental and is subject to change in the future. You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. Note: this feature is expirmental and is subject to change in the future.
## Secured by Jit
We use [Jit](https://www.jit.io/jit-open-source-gitleaks?utm_source=github&utm_medium=readme&utm_campaign=GitleaksReadme&utm_id=oss&items=item-secret-detection) to secure our codebase, to achieve fully automated, full-stack continuous security using the world's best OSS security tools.
## Sponsorships ## Sponsorships
+118 -16
View File
@@ -2,19 +2,25 @@ package cmd
import ( import (
"os" "os"
"path/filepath"
"time" "time"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/detect"
"github.com/zricethezav/gitleaks/v8/report" "github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/sources"
) )
func init() { func init() {
rootCmd.AddCommand(detectCmd) rootCmd.AddCommand(detectCmd)
detectCmd.Flags().String("log-opts", "", "git log options")
detectCmd.Flags().Bool("no-git", false, "treat git repo as a regular directory and scan those files, --log-opts has no effect on the scan when --no-git is set") detectCmd.Flags().Bool("no-git", false, "treat git repo as a regular directory and scan those files, --log-opts has no effect on the scan when --no-git is set")
detectCmd.Flags().Bool("pipe", false, "scan input from stdin, ex: `cat some_file | gitleaks detect --pipe`") detectCmd.Flags().Bool("pipe", false, "scan input from stdin, ex: `cat some_file | gitleaks detect --pipe`")
detectCmd.Flags().Bool("follow-symlinks", false, "scan files that are symlinks to other files")
} }
var detectCmd = &cobra.Command{ var detectCmd = &cobra.Command{
@@ -26,22 +32,70 @@ var detectCmd = &cobra.Command{
func runDetect(cmd *cobra.Command, args []string) { func runDetect(cmd *cobra.Command, args []string) {
initConfig() initConfig()
var ( var (
vc config.ViperConfig
findings []report.Finding findings []report.Finding
err error err error
) )
// setup config (aka, the thing that defines rules) // Load config
cfg := Config(cmd) if err = viper.Unmarshal(&vc); err != nil {
log.Fatal().Err(err).Msg("Failed to load config")
}
cfg, err := vc.Translate()
if err != nil {
log.Fatal().Err(err).Msg("Failed to load config")
}
cfg.Path, _ = cmd.Flags().GetString("config")
// start timer // start timer
start := time.Now() start := time.Now()
// grab source // Setup detector
detector := detect.NewDetector(cfg)
detector.Config.Path, err = cmd.Flags().GetString("config")
if err != nil {
log.Fatal().Err(err).Msg("")
}
source, err := cmd.Flags().GetString("source") source, err := cmd.Flags().GetString("source")
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("") log.Fatal().Err(err).Msg("")
} }
detector := Detector(cmd, cfg, source) // if config path is not set, then use the {source}/.gitleaks.toml path.
// note that there may not be a `{source}/.gitleaks.toml` file, this is ok.
if detector.Config.Path == "" {
detector.Config.Path = filepath.Join(source, ".gitleaks.toml")
}
// set verbose flag
if detector.Verbose, err = cmd.Flags().GetBool("verbose"); err != nil {
log.Fatal().Err(err).Msg("")
}
// set redact flag
if detector.Redact, err = cmd.Flags().GetBool("redact"); err != nil {
log.Fatal().Err(err).Msg("")
}
if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil {
log.Fatal().Err(err).Msg("")
}
if fileExists(filepath.Join(source, ".gitleaksignore")) {
if err = detector.AddGitleaksIgnore(filepath.Join(source, ".gitleaksignore")); err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
}
}
// ignore findings from the baseline (an existing report in json format generated earlier)
baselinePath, _ := cmd.Flags().GetString("baseline-path")
if baselinePath != "" {
err = detector.AddBaseline(baselinePath)
if err != nil {
log.Error().Msgf("Could not load baseline. The path must point of a gitleaks report generated using the default format: %s", err)
}
}
// set follow symlinks flag
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
log.Fatal().Err(err).Msg("")
}
// set exit code // set exit code
exitCode, err := cmd.Flags().GetInt("exit-code") exitCode, err := cmd.Flags().GetInt("exit-code")
@@ -63,11 +117,7 @@ func runDetect(cmd *cobra.Command, args []string) {
// start the detector scan // start the detector scan
if noGit { if noGit {
paths, err := sources.DirectoryTargets(source, detector.Sema, detector.FollowSymlinks) findings, err = detector.DetectFiles(source)
if err != nil {
log.Fatal().Err(err)
}
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("") log.Error().Err(err).Msg("")
@@ -85,16 +135,68 @@ func runDetect(cmd *cobra.Command, args []string) {
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("") log.Fatal().Err(err).Msg("")
} }
gitCmd, err := sources.NewGitLogCmd(source, logOpts) findings, err = detector.DetectGit(source, logOpts, detect.DetectType)
if err != nil {
log.Fatal().Err(err).Msg("")
}
findings, err = detector.DetectGit(gitCmd)
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("") log.Error().Err(err).Msg("")
} }
} }
findingSummaryAndExit(findings, cmd, cfg, exitCode, start, err) // log info about the scan
if err == nil {
log.Info().Msgf("scan completed in %s", FormatDuration(time.Since(start)))
if len(findings) != 0 {
log.Warn().Msgf("leaks found: %d", len(findings))
} else {
log.Info().Msg("no leaks found")
}
} else {
log.Warn().Msgf("partial scan completed in %s", FormatDuration(time.Since(start)))
if len(findings) != 0 {
log.Warn().Msgf("%d leaks found in partial scan", len(findings))
} else {
log.Warn().Msg("no leaks found in partial scan")
}
}
// write report if desired
reportPath, _ := cmd.Flags().GetString("report-path")
ext, _ := cmd.Flags().GetString("report-format")
if reportPath != "" {
if err := report.Write(findings, cfg, ext, reportPath); err != nil {
log.Fatal().Err(err).Msg("could not write")
}
}
if err != nil {
os.Exit(1)
}
if len(findings) != 0 {
os.Exit(exitCode)
}
}
func fileExists(fileName string) bool {
// check for a .gitleaksignore file
info, err := os.Stat(fileName)
if err != nil && !os.IsNotExist(err) {
return false
}
if info != nil && err == nil {
if !info.IsDir() {
return true
}
}
return false
}
func FormatDuration(d time.Duration) string {
scale := 100 * time.Second
// look for the max scale that is smaller than d
for scale > d {
scale = scale / 10
}
return d.Round(scale / 100).String()
} }
+150 -180
View File
@@ -14,188 +14,158 @@ const (
templatePath = "rules/config.tmpl" templatePath = "rules/config.tmpl"
) )
//go:generate go run $GOFILE ../../../config/gitleaks.toml
func main() { func main() {
if len(os.Args) < 2 { var configRules []*config.Rule
os.Stderr.WriteString("Specify path to the gitleaks.toml config\n") configRules = append(configRules, rules.AdafruitAPIKey())
os.Exit(2) configRules = append(configRules, rules.AdobeClientID())
} configRules = append(configRules, rules.AdobeClientSecret())
gitleaksConfigPath := os.Args[1] configRules = append(configRules, rules.AgeSecretKey())
configRules = append(configRules, rules.Airtable())
configRules := []*config.Rule{ configRules = append(configRules, rules.AlgoliaApiKey())
rules.AdafruitAPIKey(), configRules = append(configRules, rules.AlibabaAccessKey())
rules.AdobeClientID(), configRules = append(configRules, rules.AlibabaSecretKey())
rules.AdobeClientSecret(), configRules = append(configRules, rules.AsanaClientID())
rules.AgeSecretKey(), configRules = append(configRules, rules.AsanaClientSecret())
rules.Airtable(), configRules = append(configRules, rules.Atlassian())
rules.AlgoliaApiKey(), configRules = append(configRules, rules.AWS())
rules.AlibabaAccessKey(), configRules = append(configRules, rules.BitBucketClientID())
rules.AlibabaSecretKey(), configRules = append(configRules, rules.BitBucketClientSecret())
rules.AsanaClientID(), configRules = append(configRules, rules.BittrexAccessKey())
rules.AsanaClientSecret(), configRules = append(configRules, rules.BittrexSecretKey())
rules.Atlassian(), configRules = append(configRules, rules.Beamer())
rules.Authress(), configRules = append(configRules, rules.CodecovAccessToken())
rules.AWS(), configRules = append(configRules, rules.CoinbaseAccessToken())
rules.BitBucketClientID(), configRules = append(configRules, rules.Clojars())
rules.BitBucketClientSecret(), configRules = append(configRules, rules.ConfluentAccessToken())
rules.BittrexAccessKey(), configRules = append(configRules, rules.ConfluentSecretKey())
rules.BittrexSecretKey(), configRules = append(configRules, rules.Contentful())
rules.Beamer(), configRules = append(configRules, rules.Databricks())
rules.CodecovAccessToken(), configRules = append(configRules, rules.DatadogtokenAccessToken())
rules.CoinbaseAccessToken(), configRules = append(configRules, rules.DigitalOceanPAT())
rules.Clojars(), configRules = append(configRules, rules.DigitalOceanOAuthToken())
rules.ConfluentAccessToken(), configRules = append(configRules, rules.DigitalOceanRefreshToken())
rules.ConfluentSecretKey(), configRules = append(configRules, rules.DiscordAPIToken())
rules.Contentful(), configRules = append(configRules, rules.DiscordClientID())
rules.Databricks(), configRules = append(configRules, rules.DiscordClientSecret())
rules.DatadogtokenAccessToken(), configRules = append(configRules, rules.Doppler())
rules.DefinedNetworkingAPIToken(), configRules = append(configRules, rules.DropBoxAPISecret())
rules.DigitalOceanPAT(), configRules = append(configRules, rules.DropBoxLongLivedAPIToken())
rules.DigitalOceanOAuthToken(), configRules = append(configRules, rules.DropBoxShortLivedAPIToken())
rules.DigitalOceanRefreshToken(), configRules = append(configRules, rules.DroneciAccessToken())
rules.DiscordAPIToken(), configRules = append(configRules, rules.Duffel())
rules.DiscordClientID(), configRules = append(configRules, rules.Dynatrace())
rules.DiscordClientSecret(), configRules = append(configRules, rules.EasyPost())
rules.Doppler(), configRules = append(configRules, rules.EasyPostTestAPI())
rules.DropBoxAPISecret(), configRules = append(configRules, rules.EtsyAccessToken())
rules.DropBoxLongLivedAPIToken(), configRules = append(configRules, rules.Facebook())
rules.DropBoxShortLivedAPIToken(), configRules = append(configRules, rules.FastlyAPIToken())
rules.DroneciAccessToken(), configRules = append(configRules, rules.FinicityClientSecret())
rules.Duffel(), configRules = append(configRules, rules.FinicityAPIToken())
rules.Dynatrace(), configRules = append(configRules, rules.FlickrAccessToken())
rules.EasyPost(), configRules = append(configRules, rules.FinnhubAccessToken())
rules.EasyPostTestAPI(), configRules = append(configRules, rules.FlutterwavePublicKey())
rules.EtsyAccessToken(), configRules = append(configRules, rules.FlutterwaveSecretKey())
rules.Facebook(), configRules = append(configRules, rules.FlutterwaveEncKey())
rules.FastlyAPIToken(), configRules = append(configRules, rules.FrameIO())
rules.FinicityClientSecret(), configRules = append(configRules, rules.FreshbooksAccessToken())
rules.FinicityAPIToken(), configRules = append(configRules, rules.GoCardless())
rules.FlickrAccessToken(), // TODO figure out what makes sense for GCP
rules.FinnhubAccessToken(), // configRules = append(configRules, rules.GCPServiceAccount())
rules.FlutterwavePublicKey(), configRules = append(configRules, rules.GCPAPIKey())
rules.FlutterwaveSecretKey(), configRules = append(configRules, rules.GitHubPat())
rules.FlutterwaveEncKey(), configRules = append(configRules, rules.GitHubFineGrainedPat())
rules.FrameIO(), configRules = append(configRules, rules.GitHubOauth())
rules.FreshbooksAccessToken(), configRules = append(configRules, rules.GitHubApp())
rules.GoCardless(), configRules = append(configRules, rules.GitHubRefresh())
// TODO figure out what makes sense for GCP configRules = append(configRules, rules.Gitlab())
// rules.GCPServiceAccount(), configRules = append(configRules, rules.GitterAccessToken())
rules.GCPAPIKey(), configRules = append(configRules, rules.GrafanaApiKey())
rules.GitHubPat(), configRules = append(configRules, rules.GrafanaCloudApiToken())
rules.GitHubFineGrainedPat(), configRules = append(configRules, rules.GrafanaServiceAccountToken())
rules.GitHubOauth(), configRules = append(configRules, rules.Hashicorp())
rules.GitHubApp(), configRules = append(configRules, rules.Heroku())
rules.GitHubRefresh(), configRules = append(configRules, rules.HubSpot())
rules.GitlabPat(), configRules = append(configRules, rules.Intercom())
rules.GitlabPipelineTriggerToken(), configRules = append(configRules, rules.JWT())
rules.GitlabRunnerRegistrationToken(), configRules = append(configRules, rules.KrakenAccessToken())
rules.GitterAccessToken(), configRules = append(configRules, rules.KucoinAccessToken())
rules.GrafanaApiKey(), configRules = append(configRules, rules.KucoinSecretKey())
rules.GrafanaCloudApiToken(), configRules = append(configRules, rules.LaunchDarklyAccessToken())
rules.GrafanaServiceAccountToken(), configRules = append(configRules, rules.LinearAPIToken())
rules.Hashicorp(), configRules = append(configRules, rules.LinearClientSecret())
rules.HashicorpField(), configRules = append(configRules, rules.LinkedinClientID())
rules.Heroku(), configRules = append(configRules, rules.LinkedinClientSecret())
rules.HubSpot(), configRules = append(configRules, rules.LobAPIToken())
rules.HuggingFaceAccessToken(), configRules = append(configRules, rules.LobPubAPIToken())
rules.HuggingFaceOrganizationApiToken(), configRules = append(configRules, rules.MailChimp())
rules.Intercom(), configRules = append(configRules, rules.MailGunPubAPIToken())
rules.JFrogAPIKey(), configRules = append(configRules, rules.MailGunPrivateAPIToken())
rules.JFrogIdentityToken(), configRules = append(configRules, rules.MailGunSigningKey())
rules.JWT(), configRules = append(configRules, rules.MapBox())
rules.JWTBase64(), configRules = append(configRules, rules.MattermostAccessToken())
rules.KrakenAccessToken(), configRules = append(configRules, rules.MessageBirdAPIToken())
rules.KucoinAccessToken(), configRules = append(configRules, rules.MessageBirdClientID())
rules.KucoinSecretKey(), configRules = append(configRules, rules.NetlifyAccessToken())
rules.LaunchDarklyAccessToken(), configRules = append(configRules, rules.NewRelicUserID())
rules.LinearAPIToken(), configRules = append(configRules, rules.NewRelicUserKey())
rules.LinearClientSecret(), configRules = append(configRules, rules.NewRelicBrowserAPIKey())
rules.LinkedinClientID(), configRules = append(configRules, rules.NPM())
rules.LinkedinClientSecret(), configRules = append(configRules, rules.NytimesAccessToken())
rules.LobAPIToken(), configRules = append(configRules, rules.OktaAccessToken())
rules.LobPubAPIToken(), configRules = append(configRules, rules.PlaidAccessID())
rules.MailChimp(), configRules = append(configRules, rules.PlaidSecretKey())
rules.MailGunPubAPIToken(), configRules = append(configRules, rules.PlaidAccessToken())
rules.MailGunPrivateAPIToken(), configRules = append(configRules, rules.PlanetScalePassword())
rules.MailGunSigningKey(), configRules = append(configRules, rules.PlanetScaleAPIToken())
rules.MapBox(), configRules = append(configRules, rules.PlanetScaleOAuthToken())
rules.MattermostAccessToken(), configRules = append(configRules, rules.PostManAPI())
rules.MessageBirdAPIToken(), configRules = append(configRules, rules.Prefect())
rules.MessageBirdClientID(), configRules = append(configRules, rules.PrivateKey())
rules.NetlifyAccessToken(), configRules = append(configRules, rules.PulumiAPIToken())
rules.NewRelicUserID(), configRules = append(configRules, rules.PyPiUploadToken())
rules.NewRelicUserKey(), configRules = append(configRules, rules.RapidAPIAccessToken())
rules.NewRelicBrowserAPIKey(), configRules = append(configRules, rules.ReadMe())
rules.NPM(), configRules = append(configRules, rules.RubyGemsAPIToken())
rules.NytimesAccessToken(), configRules = append(configRules, rules.SendbirdAccessID())
rules.OktaAccessToken(), configRules = append(configRules, rules.SendbirdAccessToken())
rules.OpenAI(), configRules = append(configRules, rules.SendGridAPIToken())
rules.PlaidAccessID(), configRules = append(configRules, rules.SendInBlueAPIToken())
rules.PlaidSecretKey(), configRules = append(configRules, rules.SentryAccessToken())
rules.PlaidAccessToken(), configRules = append(configRules, rules.ShippoAPIToken())
rules.PlanetScalePassword(), configRules = append(configRules, rules.ShopifyAccessToken())
rules.PlanetScaleAPIToken(), configRules = append(configRules, rules.ShopifyCustomAccessToken())
rules.PlanetScaleOAuthToken(), configRules = append(configRules, rules.ShopifyPrivateAppAccessToken())
rules.PostManAPI(), configRules = append(configRules, rules.ShopifySharedSecret())
rules.Prefect(), configRules = append(configRules, rules.SidekiqSecret())
rules.PrivateKey(), configRules = append(configRules, rules.SidekiqSensitiveUrl())
rules.PulumiAPIToken(), configRules = append(configRules, rules.SlackAccessToken())
rules.PyPiUploadToken(), configRules = append(configRules, rules.SlackWebHook())
rules.RapidAPIAccessToken(), configRules = append(configRules, rules.StripeAccessToken())
rules.ReadMe(), configRules = append(configRules, rules.SquareAccessToken())
rules.RubyGemsAPIToken(), configRules = append(configRules, rules.SquareSpaceAccessToken())
rules.ScalingoAPIToken(), configRules = append(configRules, rules.SumoLogicAccessID())
rules.SendbirdAccessID(), configRules = append(configRules, rules.SumoLogicAccessToken())
rules.SendbirdAccessToken(), configRules = append(configRules, rules.TeamsWebhook())
rules.SendGridAPIToken(), configRules = append(configRules, rules.TelegramBotToken())
rules.SendInBlueAPIToken(), configRules = append(configRules, rules.TravisCIAccessToken())
rules.SentryAccessToken(), configRules = append(configRules, rules.Twilio())
rules.ShippoAPIToken(), configRules = append(configRules, rules.TwitchAPIToken())
rules.ShopifyAccessToken(), configRules = append(configRules, rules.TwitterAPIKey())
rules.ShopifyCustomAccessToken(), configRules = append(configRules, rules.TwitterAPISecret())
rules.ShopifyPrivateAppAccessToken(), configRules = append(configRules, rules.TwitterAccessToken())
rules.ShopifySharedSecret(), configRules = append(configRules, rules.TwitterAccessSecret())
rules.SidekiqSecret(), configRules = append(configRules, rules.TwitterBearerToken())
rules.SidekiqSensitiveUrl(), configRules = append(configRules, rules.Typeform())
rules.SlackBotToken(), configRules = append(configRules, rules.VaultBatchToken())
rules.SlackUserToken(), configRules = append(configRules, rules.VaultServiceToken())
rules.SlackAppLevelToken(), configRules = append(configRules, rules.YandexAPIKey())
rules.SlackConfigurationToken(), configRules = append(configRules, rules.YandexAWSAccessToken())
rules.SlackConfigurationRefreshToken(), configRules = append(configRules, rules.YandexAccessToken())
rules.SlackLegacyBotToken(), configRules = append(configRules, rules.ZendeskSecretKey())
rules.SlackLegacyWorkspaceToken(), configRules = append(configRules, rules.GenericCredential())
rules.SlackLegacyToken(),
rules.SlackWebHookUrl(),
rules.Snyk(),
rules.StripeAccessToken(),
rules.SquareAccessToken(),
rules.SquareSpaceAccessToken(),
rules.SumoLogicAccessID(),
rules.SumoLogicAccessToken(),
rules.TeamsWebhook(),
rules.TelegramBotToken(),
rules.TravisCIAccessToken(),
rules.Twilio(),
rules.TwitchAPIToken(),
rules.TwitterAPIKey(),
rules.TwitterAPISecret(),
rules.TwitterAccessToken(),
rules.TwitterAccessSecret(),
rules.TwitterBearerToken(),
rules.Typeform(),
rules.VaultBatchToken(),
rules.VaultServiceToken(),
rules.YandexAPIKey(),
rules.YandexAWSAccessToken(),
rules.YandexAccessToken(),
rules.ZendeskSecretKey(),
rules.GenericCredential(),
rules.InfracostAPIToken(),
}
// ensure rules have unique ids // ensure rules have unique ids
ruleLookUp := make(map[string]config.Rule, len(configRules)) ruleLookUp := make(map[string]config.Rule)
for _, rule := range configRules { for _, rule := range configRules {
// check if rule is in ruleLookUp // check if rule is in ruleLookUp
if _, ok := ruleLookUp[rule.RuleID]; ok { if _, ok := ruleLookUp[rule.RuleID]; ok {
@@ -211,7 +181,7 @@ func main() {
log.Fatal().Err(err).Msg("Failed to parse template") log.Fatal().Err(err).Msg("Failed to parse template")
} }
f, err := os.Create(gitleaksConfigPath) f, err := os.Create("../../../config/gitleaks.toml")
if err != nil { if err != nil {
log.Fatal().Err(err).Msg("Failed to create rules.toml") log.Fatal().Err(err).Msg("Failed to create rules.toml")
} }
+3 -2
View File
@@ -8,9 +8,10 @@ import (
func AdafruitAPIKey() *config.Rule { func AdafruitAPIKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a potential Adafruit API Key, which could lead to unauthorized access to Adafruit services and sensitive data exposure.", Description: "Adafruit API Key",
RuleID: "adafruit-api-key", RuleID: "adafruit-api-key",
Regex: generateSemiGenericRegex([]string{"adafruit"}, alphaNumericExtendedShort("32"), true), Regex: generateSemiGenericRegex([]string{"adafruit"}, alphaNumericExtendedShort("32")),
SecretGroup: 1,
Keywords: []string{"adafruit"}, Keywords: []string{"adafruit"},
} }
+5 -4
View File
@@ -8,9 +8,10 @@ import (
func AdobeClientID() *config.Rule { func AdobeClientID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a pattern that resembles an Adobe OAuth Web Client ID, posing a risk of compromised Adobe integrations and data breaches.", Description: "Adobe Client ID (OAuth Web)",
RuleID: "adobe-client-id", RuleID: "adobe-client-id",
Regex: generateSemiGenericRegex([]string{"adobe"}, hex("32"), true), Regex: generateSemiGenericRegex([]string{"adobe"}, hex("32")),
SecretGroup: 1,
Keywords: []string{"adobe"}, Keywords: []string{"adobe"},
} }
@@ -24,9 +25,9 @@ func AdobeClientID() *config.Rule {
func AdobeClientSecret() *config.Rule { func AdobeClientSecret() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a potential Adobe Client Secret, which, if exposed, could allow unauthorized Adobe service access and data manipulation.", Description: "Adobe Client Secret",
RuleID: "adobe-client-secret", RuleID: "adobe-client-secret",
Regex: generateUniqueTokenRegex(`(p8e-)(?i)[a-z0-9]{32}`, true), Regex: generateUniqueTokenRegex(`(p8e-)(?i)[a-z0-9]{32}`),
Keywords: []string{"p8e-"}, Keywords: []string{"p8e-"},
} }
+1 -1
View File
@@ -9,7 +9,7 @@ import (
func AgeSecretKey() *config.Rule { func AgeSecretKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a potential Age encryption tool secret key, risking data decryption and unauthorized access to sensitive information.", Description: "Age secret key",
RuleID: "age secret key", RuleID: "age secret key",
Regex: regexp.MustCompile(`AGE-SECRET-KEY-1[QPZRY9X8GF2TVDW0S3JN54KHCE6MUA7L]{58}`), Regex: regexp.MustCompile(`AGE-SECRET-KEY-1[QPZRY9X8GF2TVDW0S3JN54KHCE6MUA7L]{58}`),
Keywords: []string{"AGE-SECRET-KEY-1"}, Keywords: []string{"AGE-SECRET-KEY-1"},
+3 -2
View File
@@ -8,9 +8,10 @@ import (
func Airtable() *config.Rule { func Airtable() *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: "Airtable API Key",
RuleID: "airtable-api-key", RuleID: "airtable-api-key",
Regex: generateSemiGenericRegex([]string{"airtable"}, alphaNumeric("17"), true), Regex: generateSemiGenericRegex([]string{"airtable"}, alphaNumeric("17")),
SecretGroup: 1,
Keywords: []string{"airtable"}, Keywords: []string{"airtable"},
} }
+2 -2
View File
@@ -8,9 +8,9 @@ import (
func AlgoliaApiKey() *config.Rule { func AlgoliaApiKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified an Algolia API Key, which could result in unauthorized search operations and data exposure on Algolia-managed platforms.", Description: "Algolia API Key",
RuleID: "algolia-api-key", RuleID: "algolia-api-key",
Regex: generateSemiGenericRegex([]string{"algolia"}, `[a-z0-9]{32}`, true), Regex: generateSemiGenericRegex([]string{"algolia"}, `[a-z0-9]{32}`),
Keywords: []string{"algolia"}, Keywords: []string{"algolia"},
} }
+6 -6
View File
@@ -8,9 +8,9 @@ import (
func AlibabaAccessKey() *config.Rule { func AlibabaAccessKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected an Alibaba Cloud AccessKey ID, posing a risk of unauthorized cloud resource access and potential data compromise.", Description: "Alibaba AccessKey ID",
RuleID: "alibaba-access-key-id", RuleID: "alibaba-access-key-id",
Regex: generateUniqueTokenRegex(`(LTAI)(?i)[a-z0-9]{20}`, true), Regex: generateUniqueTokenRegex(`(LTAI)(?i)[a-z0-9]{20}`),
Keywords: []string{"LTAI"}, Keywords: []string{"LTAI"},
} }
@@ -25,12 +25,12 @@ func AlibabaAccessKey() *config.Rule {
func AlibabaSecretKey() *config.Rule { func AlibabaSecretKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a potential Alibaba Cloud Secret Key, potentially allowing unauthorized operations and data access within Alibaba Cloud.", Description: "Alibaba Secret Key",
RuleID: "alibaba-secret-key", RuleID: "alibaba-secret-key",
Regex: generateSemiGenericRegex([]string{"alibaba"}, Regex: generateSemiGenericRegex([]string{"alibaba"},
alphaNumeric("30"), true), alphaNumeric("30")),
SecretGroup: 1,
Keywords: []string{"alibaba"}, Keywords: []string{"alibaba"},
} }
// validate // validate
+7 -6
View File
@@ -8,9 +8,10 @@ import (
func AsanaClientID() *config.Rule { func AsanaClientID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a potential Asana Client ID, risking unauthorized access to Asana projects and sensitive task information.", Description: "Asana Client ID",
RuleID: "asana-client-id", RuleID: "asana-client-id",
Regex: generateSemiGenericRegex([]string{"asana"}, numeric("16"), true), Regex: generateSemiGenericRegex([]string{"asana"}, numeric("16")),
SecretGroup: 1,
Keywords: []string{"asana"}, Keywords: []string{"asana"},
} }
@@ -24,11 +25,11 @@ func AsanaClientID() *config.Rule {
func AsanaClientSecret() *config.Rule { func AsanaClientSecret() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified an Asana Client Secret, which could lead to compromised project management integrity and unauthorized access.", Description: "Asana Client Secret",
RuleID: "asana-client-secret", RuleID: "asana-client-secret",
Regex: generateSemiGenericRegex([]string{"asana"}, alphaNumeric("32"), true), Regex: generateSemiGenericRegex([]string{"asana"}, alphaNumeric("32")),
SecretGroup: 1,
Keywords: []string{"asana"}, Keywords: []string{"asana"},
} }
// validate // validate
+4 -3
View File
@@ -8,11 +8,12 @@ import (
func Atlassian() *config.Rule { func Atlassian() *config.Rule {
// define rule // define 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: "Atlassian API token",
RuleID: "atlassian-api-token", RuleID: "atlassian-api-token",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"atlassian", "confluence", "jira"}, alphaNumeric("24"), true), "atlassian", "confluence", "jira"}, alphaNumeric("24")),
Keywords: []string{"atlassian", "confluence", "jira"}, SecretGroup: 1,
Keywords: []string{"atlassian", "confluence", "jira"},
} }
// validate // validate
-31
View File
@@ -1,31 +0,0 @@
package rules
import (
"fmt"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
func Authress() *config.Rule {
// Rule Definition
// (Note: When changes are made to this, rerun `go generate ./...` and commit the config/gitleaks.toml file
r := config.Rule{
Description: "Uncovered a possible Authress Service Client Access Key, which may compromise access control services and sensitive data.",
RuleID: "authress-service-client-access-key",
Regex: generateUniqueTokenRegex(`(?:sc|ext|scauth|authress)_[a-z0-9]{5,30}\.[a-z0-9]{4,6}\.acc[_-][a-z0-9-]{10,32}\.[a-z0-9+/_=-]{30,120}`, true),
Keywords: []string{"sc_", "ext_", "scauth_", "authress_"},
}
// validate
// https://authress.io/knowledge-base/docs/authorization/service-clients/secrets-scanning/#1-detection
service_client_id := "sc_" + alphaNumeric("10")
access_key_id := alphaNumeric("4")
account_id := "acc_" + alphaNumeric("10")
signature_key := alphaNumericExtendedShort("40")
tps := []string{
generateSampleSecret("authress", secrets.NewSecret(fmt.Sprintf(`%s\.%s\.%s\.%s`, service_client_id, access_key_id, account_id, signature_key))),
}
return validate(r, tps, nil)
}
+8 -4
View File
@@ -9,15 +9,19 @@ import (
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.", Description: "AWS",
RuleID: "aws-access-token", RuleID: "aws-access-token",
Regex: regexp.MustCompile( Regex: regexp.MustCompile(
"(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA)[A-Z0-9]{16}"), "(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"),
Keywords: []string{ Keywords: []string{
"AKIA", "AKIA",
"AGPA",
"AIDA",
"AROA",
"AIPA",
"ANPA",
"ANVA",
"ASIA", "ASIA",
"ABIA",
"ACCA",
}, },
} }
+3 -2
View File
@@ -8,10 +8,11 @@ import (
func Beamer() *config.Rule { func Beamer() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Beamer API token, potentially compromising content management and exposing sensitive notifications and updates.", Description: "Beamer API token",
RuleID: "beamer-api-token", RuleID: "beamer-api-token",
SecretGroup: 1,
Regex: generateSemiGenericRegex([]string{"beamer"}, Regex: generateSemiGenericRegex([]string{"beamer"},
`b_[a-z0-9=_\-]{44}`, true), `b_[a-z0-9=_\-]{44}`),
Keywords: []string{"beamer"}, Keywords: []string{"beamer"},
} }
+7 -6
View File
@@ -8,9 +8,10 @@ import (
func BitBucketClientID() *config.Rule { func BitBucketClientID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a potential Bitbucket Client ID, risking unauthorized repository access and potential codebase exposure.", Description: "Bitbucket Client ID",
RuleID: "bitbucket-client-id", RuleID: "bitbucket-client-id",
Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumeric("32"), true), Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumeric("32")),
SecretGroup: 1,
Keywords: []string{"bitbucket"}, Keywords: []string{"bitbucket"},
} }
@@ -24,11 +25,11 @@ func BitBucketClientID() *config.Rule {
func BitBucketClientSecret() *config.Rule { func BitBucketClientSecret() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a potential Bitbucket Client Secret, posing a risk of compromised code repositories and unauthorized access.", Description: "Bitbucket Client Secret",
RuleID: "bitbucket-client-secret", RuleID: "bitbucket-client-secret",
Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumericExtended("64"), true), Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumericExtended("64")),
SecretGroup: 1,
Keywords: []string{"bitbucket"}, Keywords: []string{"bitbucket"},
} }
// validate // validate
+7 -6
View File
@@ -8,9 +8,10 @@ import (
func BittrexAccessKey() *config.Rule { func BittrexAccessKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a Bittrex Access Key, which could lead to unauthorized access to cryptocurrency trading accounts and financial loss.", Description: "Bittrex Access Key",
RuleID: "bittrex-access-key", RuleID: "bittrex-access-key",
Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32"), true), Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32")),
SecretGroup: 1,
Keywords: []string{"bittrex"}, Keywords: []string{"bittrex"},
} }
@@ -24,11 +25,11 @@ func BittrexAccessKey() *config.Rule {
func BittrexSecretKey() *config.Rule { func BittrexSecretKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Bittrex Secret Key, potentially compromising cryptocurrency transactions and financial security.", Description: "Bittrex Secret Key",
RuleID: "bittrex-secret-key", RuleID: "bittrex-secret-key",
Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32"), true), Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32")),
SecretGroup: 1,
Keywords: []string{"bittrex"}, Keywords: []string{"bittrex"},
} }
// validate // validate
+1 -1
View File
@@ -10,7 +10,7 @@ import (
func Clojars() *config.Rule { func Clojars() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Uncovered a possible Clojars API token, risking unauthorized access to Clojure libraries and potential code manipulation.", Description: "Clojars API token",
RuleID: "clojars-api-token", RuleID: "clojars-api-token",
Regex: regexp.MustCompile(`(?i)(CLOJARS_)[a-z0-9]{60}`), Regex: regexp.MustCompile(`(?i)(CLOJARS_)[a-z0-9]{60}`),
Keywords: []string{"clojars"}, Keywords: []string{"clojars"},
+3 -2
View File
@@ -9,8 +9,9 @@ func CodecovAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "codecov-access-token", RuleID: "codecov-access-token",
Description: "Found a pattern resembling a Codecov Access Token, posing a risk of unauthorized access to code coverage reports and sensitive data.", Description: "Codecov Access Token",
Regex: generateSemiGenericRegex([]string{"codecov"}, alphaNumeric("32"), true), Regex: generateSemiGenericRegex([]string{"codecov"}, alphaNumeric("32")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"codecov", "codecov",
}, },
+3 -2
View File
@@ -9,9 +9,10 @@ func CoinbaseAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "coinbase-access-token", RuleID: "coinbase-access-token",
Description: "Detected a Coinbase Access Token, posing a risk of unauthorized access to cryptocurrency accounts and financial transactions.", Description: "Coinbase Access Token",
Regex: generateSemiGenericRegex([]string{"coinbase"}, Regex: generateSemiGenericRegex([]string{"coinbase"},
alphaNumericExtendedShort("64"), true), alphaNumericExtendedShort("64")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"coinbase", "coinbase",
}, },
+34 -38
View File
@@ -14,51 +14,47 @@ title = "gitleaks config"
description = "global allow lists" description = "global allow lists"
paths = [ paths = [
'''gitleaks.toml''', '''gitleaks.toml''',
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe)$''', '''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket)$''',
'''(go.mod|go.sum)$''', '''(go.mod|go.sum)$''',
'''gradle.lockfile''',
'''node_modules''', '''node_modules''',
'''package-lock.json''',
'''yarn.lock''',
'''pnpm-lock.yaml''',
'''Database.refactorlog''',
'''vendor''', '''vendor''',
] ]
{{ range $i, $rule := .Rules }}[[rules]] {{ range $i, $rule := .Rules }}[[rules]]
{{ if and $rule.SecretGroup $rule.Entropy $rule.Allowlist.StopWords }}description = "{{$rule.Description}}"
id = "{{$rule.RuleID}}" id = "{{$rule.RuleID}}"
description = "{{$rule.Description}}"
regex = '''{{$rule.Regex}}''' regex = '''{{$rule.Regex}}'''
{{- with $rule.Path }} secretGroup = {{ $rule.SecretGroup }}
path = '''{{ . }}'''{{ end -}} entropy = {{ $rule.Entropy}}
{{- with $rule.SecretGroup }}
secretGroup = {{ . }}{{ end -}}
{{- with $rule.Entropy }}
entropy = {{ . }}{{ end -}}
{{- with $rule.Keywords }}
keywords = [ keywords = [
{{ range $j, $keyword := . }}"{{ $keyword }}",{{ end }} {{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
]{{ end }} ]
{{- with $rule.Tags }}
tags = [
{{ range $j, $tag := . }}"{{ $tag }}",{{ end }}
]{{ end }}
{{ if or $rule.Allowlist.Regexes $rule.Allowlist.Paths $rule.Allowlist.Commits $rule.Allowlist.StopWords }}
[rules.allowlist] [rules.allowlist]
{{ with $rule.Allowlist.RegexTarget }} stopwords= [{{ range $j, $stopword := $rule.Allowlist.StopWords }}
regexTarget = "{{ . }}"{{ end -}} "{{$stopword}}",{{end}}
{{- with $rule.Allowlist.Regexes }} ]
regexes = [ {{ else if and $rule.SecretGroup $rule.Entropy }}description = "{{$rule.Description}}"
{{ range $j, $regex := . }}"{{ $regex }}",{{ end }} id = "{{$rule.RuleID}}"
]{{ end }} regex = '''{{$rule.Regex}}'''
{{- with $rule.Allowlist.Paths }}paths = [ secretGroup = {{ $rule.SecretGroup }}
{{ range $j, $path := . }}"{{ $path }}",{{ end }} entropy = {{ $rule.Entropy}}
]{{ end }} keywords = [
{{- with $rule.Allowlist.Commits }}commits = [ {{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
{{ range $j, $commit := . }}"{{ $commit }}",{{ end }} ]
]{{ end }}
{{- with $rule.Allowlist.StopWords }}stopwords = [{{ range $j, $stopword := . }} {{ else if $rule.SecretGroup }}description = "{{$rule.Description}}"
"{{ $stopword }}",{{ end }} id = "{{$rule.RuleID}}"
]{{ end }} regex = '''{{$rule.Regex}}'''
{{ end }} secretGroup = {{ $rule.SecretGroup }}
{{ end }} keywords = [
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
]
{{ else }}description = "{{$rule.Description}}"
id = "{{$rule.RuleID}}"
regex = '''{{$rule.Regex}}'''
keywords = [
{{ range $j, $keyword := $rule.Keywords }}"{{$keyword}}",{{end}}
]
{{end}}{{end}}
+6 -5
View File
@@ -9,8 +9,9 @@ func ConfluentSecretKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "confluent-secret-key", RuleID: "confluent-secret-key",
Description: "Found a Confluent Secret Key, potentially risking unauthorized operations and data access within Confluent services.", Description: "Confluent Secret Key",
Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("64"), true), Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("64")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"confluent", "confluent",
}, },
@@ -27,9 +28,9 @@ func ConfluentAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "confluent-access-token", RuleID: "confluent-access-token",
Description: "Identified a Confluent Access Token, which could compromise access to streaming data platforms and sensitive data flow.", Description: "Confluent Access Token",
Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("16"), true), Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("16")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"confluent", "confluent",
}, },
+4 -3
View File
@@ -8,11 +8,12 @@ import (
func Contentful() *config.Rule { func Contentful() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a Contentful delivery API token, posing a risk to content management systems and data integrity.", Description: "Contentful delivery API token",
RuleID: "contentful-delivery-api-token", RuleID: "contentful-delivery-api-token",
Regex: generateSemiGenericRegex([]string{"contentful"}, Regex: generateSemiGenericRegex([]string{"contentful"},
alphaNumericExtended("43"), true), alphaNumericExtended("43")),
Keywords: []string{"contentful"}, SecretGroup: 1,
Keywords: []string{"contentful"},
} }
// validate // validate
+2 -2
View File
@@ -8,9 +8,9 @@ import (
func Databricks() *config.Rule { func Databricks() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Uncovered a Databricks API token, which may compromise big data analytics platforms and sensitive data processing.", Description: "Databricks API token",
RuleID: "databricks-api-token", RuleID: "databricks-api-token",
Regex: generateUniqueTokenRegex(`dapi[a-h0-9]{32}`, true), Regex: generateUniqueTokenRegex(`dapi[a-h0-9]{32}`),
Keywords: []string{"dapi"}, Keywords: []string{"dapi"},
} }
+3 -2
View File
@@ -9,9 +9,10 @@ func DatadogtokenAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "datadog-access-token", RuleID: "datadog-access-token",
Description: "Detected a Datadog Access Token, potentially risking monitoring and analytics data exposure and manipulation.", Description: "Datadog Access Token",
Regex: generateSemiGenericRegex([]string{"datadog"}, Regex: generateSemiGenericRegex([]string{"datadog"},
alphaNumeric("40"), true), alphaNumeric("40")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"datadog", "datadog",
}, },
@@ -1,29 +0,0 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
func DefinedNetworkingAPIToken() *config.Rule {
// Define Rule
r := config.Rule{
// Human redable description of the rule
Description: "Identified a Defined Networking API token, which could lead to unauthorized network operations and data breaches.",
// Unique ID for the rule
RuleID: "defined-networking-api-token",
// Regex used for detecting secrets. See regex section below for more details
Regex: generateSemiGenericRegex([]string{"dnkey"}, `dnkey-[a-z0-9=_\-]{26}-[a-z0-9=_\-]{52}`, true),
// Keywords used for string matching on fragments (think of this as a prefilter)
Keywords: []string{"dnkey"},
}
// validate
tps := []string{
generateSampleSecret("dnkey", "dnkey-"+secrets.NewSecret(alphaNumericExtended("26"))+"-"+secrets.NewSecret(alphaNumericExtended("52"))),
}
return validate(r, tps, nil)
}
+11 -10
View File
@@ -7,9 +7,10 @@ import (
func DigitalOceanPAT() *config.Rule { func DigitalOceanPAT() *config.Rule {
r := config.Rule{ r := config.Rule{
Description: "Discovered a DigitalOcean Personal Access Token, posing a threat to cloud infrastructure security and data privacy.", Description: "DigitalOcean Personal Access Token",
RuleID: "digitalocean-pat", RuleID: "digitalocean-pat",
Regex: generateUniqueTokenRegex(`dop_v1_[a-f0-9]{64}`, true), SecretGroup: 1,
Regex: generateUniqueTokenRegex(`dop_v1_[a-f0-9]{64}`),
Keywords: []string{"dop_v1_"}, Keywords: []string{"dop_v1_"},
} }
@@ -21,11 +22,11 @@ func DigitalOceanPAT() *config.Rule {
func DigitalOceanOAuthToken() *config.Rule { func DigitalOceanOAuthToken() *config.Rule {
r := config.Rule{ r := config.Rule{
Description: "Found a DigitalOcean OAuth Access Token, risking unauthorized cloud resource access and data compromise.", Description: "DigitalOcean OAuth Access Token",
RuleID: "digitalocean-access-token", RuleID: "digitalocean-access-token",
SecretGroup: 1,
Regex: generateUniqueTokenRegex(`doo_v1_[a-f0-9]{64}`, true), Regex: generateUniqueTokenRegex(`doo_v1_[a-f0-9]{64}`),
Keywords: []string{"doo_v1_"}, Keywords: []string{"doo_v1_"},
} }
tps := []string{ tps := []string{
@@ -36,11 +37,11 @@ func DigitalOceanOAuthToken() *config.Rule {
func DigitalOceanRefreshToken() *config.Rule { func DigitalOceanRefreshToken() *config.Rule {
r := config.Rule{ r := config.Rule{
Description: "Uncovered a DigitalOcean OAuth Refresh Token, which could allow prolonged unauthorized access and resource manipulation.", Description: "DigitalOcean OAuth Refresh Token",
RuleID: "digitalocean-refresh-token", RuleID: "digitalocean-refresh-token",
SecretGroup: 1,
Regex: generateUniqueTokenRegex(`dor_v1_[a-f0-9]{64}`, true), Regex: generateUniqueTokenRegex(`dor_v1_[a-f0-9]{64}`),
Keywords: []string{"dor_v1_"}, Keywords: []string{"dor_v1_"},
} }
tps := []string{ tps := []string{
+9 -6
View File
@@ -8,9 +8,10 @@ import (
func DiscordAPIToken() *config.Rule { func DiscordAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Discord API key, potentially compromising communication channels and user data privacy on Discord.", Description: "Discord API key",
RuleID: "discord-api-token", RuleID: "discord-api-token",
Regex: generateSemiGenericRegex([]string{"discord"}, hex("64"), true), Regex: generateSemiGenericRegex([]string{"discord"}, hex("64")),
SecretGroup: 1,
Keywords: []string{"discord"}, Keywords: []string{"discord"},
} }
@@ -24,9 +25,10 @@ func DiscordAPIToken() *config.Rule {
func DiscordClientID() *config.Rule { func DiscordClientID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a Discord client ID, which may lead to unauthorized integrations and data exposure in Discord applications.", Description: "Discord client ID",
RuleID: "discord-client-id", RuleID: "discord-client-id",
Regex: generateSemiGenericRegex([]string{"discord"}, numeric("18"), true), Regex: generateSemiGenericRegex([]string{"discord"}, numeric("18")),
SecretGroup: 1,
Keywords: []string{"discord"}, Keywords: []string{"discord"},
} }
@@ -40,9 +42,10 @@ func DiscordClientID() *config.Rule {
func DiscordClientSecret() *config.Rule { func DiscordClientSecret() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a potential Discord client secret, risking compromised Discord bot integrations and data leaks.", Description: "Discord client secret",
RuleID: "discord-client-secret", RuleID: "discord-client-secret",
Regex: generateSemiGenericRegex([]string{"discord"}, alphaNumericExtended("32"), true), Regex: generateSemiGenericRegex([]string{"discord"}, alphaNumericExtended("32")),
SecretGroup: 1,
Keywords: []string{"discord"}, Keywords: []string{"discord"},
} }
+1 -1
View File
@@ -10,7 +10,7 @@ import (
func Doppler() *config.Rule { func Doppler() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a Doppler API token, posing a risk to environment and secrets management security.", Description: "Doppler API token",
RuleID: "doppler-api-token", RuleID: "doppler-api-token",
Regex: regexp.MustCompile(`(dp\.pt\.)(?i)[a-z0-9]{43}`), Regex: regexp.MustCompile(`(dp\.pt\.)(?i)[a-z0-9]{43}`),
Keywords: []string{"doppler"}, Keywords: []string{"doppler"},
+3 -3
View File
@@ -9,9 +9,9 @@ func DroneciAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "droneci-access-token", RuleID: "droneci-access-token",
Description: "Detected a Droneci Access Token, potentially compromising continuous integration and deployment workflows.", Description: "Droneci Access Token",
Regex: generateSemiGenericRegex([]string{"droneci"}, alphaNumeric("32"), true), Regex: generateSemiGenericRegex([]string{"droneci"}, alphaNumeric("32")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"droneci", "droneci",
}, },
+8 -8
View File
@@ -8,11 +8,11 @@ import (
func DropBoxAPISecret() *config.Rule { func DropBoxAPISecret() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a Dropbox API secret, which could lead to unauthorized file access and data breaches in Dropbox storage.", Description: "Dropbox API secret",
RuleID: "dropbox-api-token", RuleID: "dropbox-api-token",
Regex: generateSemiGenericRegex([]string{"dropbox"}, alphaNumeric("15"), true), Regex: generateSemiGenericRegex([]string{"dropbox"}, alphaNumeric("15")),
SecretGroup: 1,
Keywords: []string{"dropbox"}, Keywords: []string{"dropbox"},
} }
// validate // validate
@@ -26,8 +26,8 @@ func DropBoxShortLivedAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "dropbox-short-lived-api-token", RuleID: "dropbox-short-lived-api-token",
Description: "Discovered a Dropbox short-lived API token, posing a risk of temporary but potentially harmful data access and manipulation.", Description: "Dropbox short lived API token",
Regex: generateSemiGenericRegex([]string{"dropbox"}, `sl\.[a-z0-9\-=_]{135}`, true), Regex: generateSemiGenericRegex([]string{"dropbox"}, `sl\.[a-z0-9\-=_]{135}`),
Keywords: []string{"dropbox"}, Keywords: []string{"dropbox"},
} }
@@ -39,8 +39,8 @@ func DropBoxLongLivedAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "dropbox-long-lived-api-token", RuleID: "dropbox-long-lived-api-token",
Description: "Found a Dropbox long-lived API token, risking prolonged unauthorized access to cloud storage and sensitive data.", Description: "Dropbox long lived API token",
Regex: generateSemiGenericRegex([]string{"dropbox"}, `[a-z0-9]{11}(AAAAAAAAAA)[a-z0-9\-_=]{43}`, true), Regex: generateSemiGenericRegex([]string{"dropbox"}, `[a-z0-9]{11}(AAAAAAAAAA)[a-z0-9\-_=]{43}`),
Keywords: []string{"dropbox"}, Keywords: []string{"dropbox"},
} }
+1 -1
View File
@@ -11,7 +11,7 @@ func Duffel() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "duffel-api-token", RuleID: "duffel-api-token",
Description: "Uncovered a Duffel API token, which may compromise travel platform integrations and sensitive customer data.", Description: "Duffel API token",
Regex: regexp.MustCompile(`duffel_(test|live)_(?i)[a-z0-9_\-=]{43}`), Regex: regexp.MustCompile(`duffel_(test|live)_(?i)[a-z0-9_\-=]{43}`),
Keywords: []string{"duffel"}, Keywords: []string{"duffel"},
} }
+1 -1
View File
@@ -10,7 +10,7 @@ import (
func Dynatrace() *config.Rule { func Dynatrace() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Dynatrace API token, potentially risking application performance monitoring and data exposure.", Description: "Dynatrace API token",
RuleID: "dynatrace-api-token", RuleID: "dynatrace-api-token",
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}`),
Keywords: []string{"dynatrace"}, Keywords: []string{"dynatrace"},
+4 -4
View File
@@ -10,9 +10,9 @@ import (
func EasyPost() *config.Rule { func EasyPost() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified an EasyPost API token, which could lead to unauthorized postal and shipment service access and data exposure.", Description: "EasyPost API token",
RuleID: "easypost-api-token", RuleID: "easypost-api-token",
Regex: regexp.MustCompile(`\bEZAK(?i)[a-z0-9]{54}`), Regex: regexp.MustCompile(`EZAK(?i)[a-z0-9]{54}`),
Keywords: []string{"EZAK"}, Keywords: []string{"EZAK"},
} }
@@ -26,9 +26,9 @@ func EasyPost() *config.Rule {
func EasyPostTestAPI() *config.Rule { func EasyPostTestAPI() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected an EasyPost test API token, risking exposure of test environments and potentially sensitive shipment data.", Description: "EasyPost test API token",
RuleID: "easypost-test-api-token", RuleID: "easypost-test-api-token",
Regex: regexp.MustCompile(`\bEZTK(?i)[a-z0-9]{54}`), Regex: regexp.MustCompile(`EZTK(?i)[a-z0-9]{54}`),
Keywords: []string{"EZTK"}, Keywords: []string{"EZTK"},
} }
+3 -3
View File
@@ -9,9 +9,9 @@ func EtsyAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "etsy-access-token", RuleID: "etsy-access-token",
Description: "Found an Etsy Access Token, potentially compromising Etsy shop management and customer data.", Description: "Etsy Access Token",
Regex: generateSemiGenericRegex([]string{"etsy"}, alphaNumeric("24"), true), Regex: generateSemiGenericRegex([]string{"etsy"}, alphaNumeric("24")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"etsy", "etsy",
}, },
+4 -4
View File
@@ -8,11 +8,11 @@ import (
func Facebook() *config.Rule { func Facebook() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a Facebook Access Token, posing a risk of unauthorized access to Facebook accounts and personal data exposure.", Description: "Facebook",
RuleID: "facebook", RuleID: "facebook",
Regex: generateSemiGenericRegex([]string{"facebook"}, hex("32"), true), Regex: generateSemiGenericRegex([]string{"facebook"}, hex("32")),
SecretGroup: 1,
Keywords: []string{"facebook"}, Keywords: []string{"facebook"},
} }
// validate // validate
+4 -4
View File
@@ -8,11 +8,11 @@ import (
func FastlyAPIToken() *config.Rule { func FastlyAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Uncovered a Fastly API key, which may compromise CDN and edge cloud services, leading to content delivery and security issues.", Description: "Fastly API key",
RuleID: "fastly-api-token", RuleID: "fastly-api-token",
Regex: generateSemiGenericRegex([]string{"fastly"}, alphaNumericExtended("32"), true), Regex: generateSemiGenericRegex([]string{"fastly"}, alphaNumericExtended("32")),
SecretGroup: 1,
Keywords: []string{"fastly"}, Keywords: []string{"fastly"},
} }
// validate // validate
+8 -8
View File
@@ -8,11 +8,11 @@ import (
func FinicityClientSecret() *config.Rule { func FinicityClientSecret() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a Finicity Client Secret, which could lead to compromised financial service integrations and data breaches.", Description: "Finicity Client Secret",
RuleID: "finicity-client-secret", RuleID: "finicity-client-secret",
Regex: generateSemiGenericRegex([]string{"finicity"}, alphaNumeric("20"), true), Regex: generateSemiGenericRegex([]string{"finicity"}, alphaNumeric("20")),
SecretGroup: 1,
Keywords: []string{"finicity"}, Keywords: []string{"finicity"},
} }
// validate // validate
@@ -25,11 +25,11 @@ func FinicityClientSecret() *config.Rule {
func FinicityAPIToken() *config.Rule { func FinicityAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Finicity API token, potentially risking financial data access and unauthorized financial operations.", Description: "Finicity API token",
RuleID: "finicity-api-token", RuleID: "finicity-api-token",
Regex: generateSemiGenericRegex([]string{"finicity"}, hex("32"), true), Regex: generateSemiGenericRegex([]string{"finicity"}, hex("32")),
SecretGroup: 1,
Keywords: []string{"finicity"}, Keywords: []string{"finicity"},
} }
// validate // validate
+3 -3
View File
@@ -9,9 +9,9 @@ func FinnhubAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "finnhub-access-token", RuleID: "finnhub-access-token",
Description: "Found a Finnhub Access Token, risking unauthorized access to financial market data and analytics.", Description: "Finnhub Access Token",
Regex: generateSemiGenericRegex([]string{"finnhub"}, alphaNumeric("20"), true), Regex: generateSemiGenericRegex([]string{"finnhub"}, alphaNumeric("20")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"finnhub", "finnhub",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func FlickrAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "flickr-access-token", RuleID: "flickr-access-token",
Description: "Discovered a Flickr Access Token, posing a risk of unauthorized photo management and potential data leakage.", Description: "Flickr Access Token",
Regex: generateSemiGenericRegex([]string{"flickr"}, alphaNumeric("32"), true), Regex: generateSemiGenericRegex([]string{"flickr"}, alphaNumeric("32")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"flickr", "flickr",
}, },
+3 -3
View File
@@ -10,7 +10,7 @@ import (
func FlutterwavePublicKey() *config.Rule { func FlutterwavePublicKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Finicity Public Key, potentially exposing public cryptographic operations and integrations.", Description: "Finicity Public Key",
RuleID: "flutterwave-public-key", RuleID: "flutterwave-public-key",
Regex: regexp.MustCompile(`FLWPUBK_TEST-(?i)[a-h0-9]{32}-X`), Regex: regexp.MustCompile(`FLWPUBK_TEST-(?i)[a-h0-9]{32}-X`),
Keywords: []string{"FLWPUBK_TEST"}, Keywords: []string{"FLWPUBK_TEST"},
@@ -26,7 +26,7 @@ func FlutterwavePublicKey() *config.Rule {
func FlutterwaveSecretKey() *config.Rule { func FlutterwaveSecretKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a Flutterwave Secret Key, risking unauthorized financial transactions and data breaches.", Description: "Flutterwave Secret Key",
RuleID: "flutterwave-secret-key", RuleID: "flutterwave-secret-key",
Regex: regexp.MustCompile(`FLWSECK_TEST-(?i)[a-h0-9]{32}-X`), Regex: regexp.MustCompile(`FLWSECK_TEST-(?i)[a-h0-9]{32}-X`),
Keywords: []string{"FLWSECK_TEST"}, Keywords: []string{"FLWSECK_TEST"},
@@ -42,7 +42,7 @@ func FlutterwaveSecretKey() *config.Rule {
func FlutterwaveEncKey() *config.Rule { func FlutterwaveEncKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Uncovered a Flutterwave Encryption Key, which may compromise payment processing and sensitive financial information.", Description: "Flutterwave Encryption Key",
RuleID: "flutterwave-encryption-key", RuleID: "flutterwave-encryption-key",
Regex: regexp.MustCompile(`FLWSECK_TEST-(?i)[a-h0-9]{12}`), Regex: regexp.MustCompile(`FLWSECK_TEST-(?i)[a-h0-9]{12}`),
Keywords: []string{"FLWSECK_TEST"}, Keywords: []string{"FLWSECK_TEST"},
+1 -1
View File
@@ -10,7 +10,7 @@ import (
func FrameIO() *config.Rule { func FrameIO() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Found a Frame.io API token, potentially compromising video collaboration and project management.", Description: "Frame.io API token",
RuleID: "frameio-api-token", RuleID: "frameio-api-token",
Regex: regexp.MustCompile(`fio-u-(?i)[a-z0-9\-_=]{64}`), Regex: regexp.MustCompile(`fio-u-(?i)[a-z0-9\-_=]{64}`),
Keywords: []string{"fio-u-"}, Keywords: []string{"fio-u-"},
+3 -3
View File
@@ -9,9 +9,9 @@ func FreshbooksAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "freshbooks-access-token", RuleID: "freshbooks-access-token",
Description: "Discovered a Freshbooks Access Token, posing a risk to accounting software access and sensitive financial data exposure.", Description: "Freshbooks Access Token",
Regex: generateSemiGenericRegex([]string{"freshbooks"}, alphaNumeric("64"), true), Regex: generateSemiGenericRegex([]string{"freshbooks"}, alphaNumeric("64")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"freshbooks", "freshbooks",
}, },
+3 -3
View File
@@ -28,9 +28,9 @@ func GCPAPIKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := 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: "GCP API key",
Regex: generateUniqueTokenRegex(`AIza[0-9A-Za-z\\-_]{35}`, true), Regex: generateUniqueTokenRegex(`AIza[0-9A-Za-z\\-_]{35}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"AIza", "AIza",
}, },
+3 -2
View File
@@ -8,7 +8,7 @@ func GenericCredential() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "generic-api-key", RuleID: "generic-api-key",
Description: "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.", Description: "Generic API Key",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"key", "key",
"api", "api",
@@ -19,7 +19,8 @@ func GenericCredential() *config.Rule {
"password", "password",
"auth", "auth",
"access", "access",
}, `[0-9a-z\-_.=]{10,150}`, true), }, `[0-9a-z\-_.=]{10,150}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"key", "key",
"api", "api",
+5 -5
View File
@@ -10,7 +10,7 @@ import (
func GitHubPat() *config.Rule { func GitHubPat() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Uncovered a GitHub Personal Access Token, potentially leading to unauthorized repository access and sensitive content exposure.", Description: "GitHub Personal Access Token",
RuleID: "github-pat", RuleID: "github-pat",
Regex: regexp.MustCompile(`ghp_[0-9a-zA-Z]{36}`), Regex: regexp.MustCompile(`ghp_[0-9a-zA-Z]{36}`),
Keywords: []string{"ghp_"}, Keywords: []string{"ghp_"},
@@ -26,7 +26,7 @@ func GitHubPat() *config.Rule {
func GitHubFineGrainedPat() *config.Rule { func GitHubFineGrainedPat() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Found a GitHub Fine-Grained Personal Access Token, risking unauthorized repository access and code manipulation.", Description: "GitHub Fine-Grained Personal Access Token",
RuleID: "github-fine-grained-pat", RuleID: "github-fine-grained-pat",
Regex: regexp.MustCompile(`github_pat_[0-9a-zA-Z_]{82}`), Regex: regexp.MustCompile(`github_pat_[0-9a-zA-Z_]{82}`),
Keywords: []string{"github_pat_"}, Keywords: []string{"github_pat_"},
@@ -42,7 +42,7 @@ func GitHubFineGrainedPat() *config.Rule {
func GitHubOauth() *config.Rule { func GitHubOauth() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a GitHub OAuth Access Token, posing a risk of compromised GitHub account integrations and data leaks.", Description: "GitHub OAuth Access Token",
RuleID: "github-oauth", RuleID: "github-oauth",
Regex: regexp.MustCompile(`gho_[0-9a-zA-Z]{36}`), Regex: regexp.MustCompile(`gho_[0-9a-zA-Z]{36}`),
Keywords: []string{"gho_"}, Keywords: []string{"gho_"},
@@ -58,7 +58,7 @@ func GitHubOauth() *config.Rule {
func GitHubApp() *config.Rule { func GitHubApp() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a GitHub App Token, which may compromise GitHub application integrations and source code security.", Description: "GitHub App Token",
RuleID: "github-app-token", RuleID: "github-app-token",
Regex: regexp.MustCompile(`(ghu|ghs)_[0-9a-zA-Z]{36}`), Regex: regexp.MustCompile(`(ghu|ghs)_[0-9a-zA-Z]{36}`),
Keywords: []string{"ghu_", "ghs_"}, Keywords: []string{"ghu_", "ghs_"},
@@ -75,7 +75,7 @@ func GitHubApp() *config.Rule {
func GitHubRefresh() *config.Rule { func GitHubRefresh() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a GitHub Refresh Token, which could allow prolonged unauthorized access to GitHub services.", Description: "GitHub Refresh Token",
RuleID: "github-refresh-token", RuleID: "github-refresh-token",
Regex: regexp.MustCompile(`ghr_[0-9a-zA-Z]{36}`), Regex: regexp.MustCompile(`ghr_[0-9a-zA-Z]{36}`),
Keywords: []string{"ghr_"}, Keywords: []string{"ghr_"},
+2 -34
View File
@@ -7,10 +7,10 @@ import (
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
) )
func GitlabPat() *config.Rule { func Gitlab() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a GitLab Personal Access Token, risking unauthorized access to GitLab repositories and codebase exposure.", Description: "GitLab Personal Access Token",
RuleID: "gitlab-pat", RuleID: "gitlab-pat",
Regex: regexp.MustCompile(`glpat-[0-9a-zA-Z\-\_]{20}`), Regex: regexp.MustCompile(`glpat-[0-9a-zA-Z\-\_]{20}`),
Keywords: []string{"glpat-"}, Keywords: []string{"glpat-"},
@@ -22,35 +22,3 @@ func GitlabPat() *config.Rule {
} }
return validate(r, tps, nil) return validate(r, tps, nil)
} }
func GitlabPipelineTriggerToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Found a GitLab Pipeline Trigger Token, potentially compromising continuous integration workflows and project security.",
RuleID: "gitlab-ptt",
Regex: regexp.MustCompile(`glptt-[0-9a-f]{40}`),
Keywords: []string{"glptt-"},
}
// validate
tps := []string{
generateSampleSecret("gitlab", "glptt-"+secrets.NewSecret(hex("40"))),
}
return validate(r, tps, nil)
}
func GitlabRunnerRegistrationToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Discovered a GitLab Runner Registration Token, posing a risk to CI/CD pipeline integrity and unauthorized access.",
RuleID: "gitlab-rrt",
Regex: regexp.MustCompile(`GR1348941[0-9a-zA-Z\-\_]{20}`),
Keywords: []string{"GR1348941"},
}
// validate
tps := []string{
generateSampleSecret("gitlab", "GR1348941"+secrets.NewSecret(alphaNumeric("20"))),
}
return validate(r, tps, nil)
}
+3 -3
View File
@@ -9,10 +9,10 @@ func GitterAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "gitter-access-token", RuleID: "gitter-access-token",
Description: "Uncovered a Gitter Access Token, which may lead to unauthorized access to chat and communication services.", Description: "Gitter Access Token",
Regex: generateSemiGenericRegex([]string{"gitter"}, Regex: generateSemiGenericRegex([]string{"gitter"},
alphaNumericExtendedShort("40"), true), alphaNumericExtendedShort("40")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"gitter", "gitter",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func GoCardless() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "gocardless-api-token", RuleID: "gocardless-api-token",
Description: "Detected a GoCardless API token, potentially risking unauthorized direct debit payment operations and financial data exposure.", Description: "GoCardless API token",
Regex: generateSemiGenericRegex([]string{"gocardless"}, `live_(?i)[a-z0-9\-_=]{40}`, true), Regex: generateSemiGenericRegex([]string{"gocardless"}, `live_(?i)[a-z0-9\-_=]{40}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"live_", "live_",
"gocardless", "gocardless",
+12 -12
View File
@@ -8,11 +8,11 @@ import (
func GrafanaApiKey() *config.Rule { func GrafanaApiKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a Grafana API key, which could compromise monitoring dashboards and sensitive data analytics.", Description: "Grafana api key (or Grafana cloud api key)",
RuleID: "grafana-api-key", RuleID: "grafana-api-key",
SecretGroup: 1,
Regex: generateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`, true), Regex: generateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`),
Keywords: []string{"eyJrIjoi"}, Keywords: []string{"eyJrIjoi"},
} }
// validate // validate
@@ -27,11 +27,11 @@ func GrafanaApiKey() *config.Rule {
func GrafanaCloudApiToken() *config.Rule { func GrafanaCloudApiToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Found a Grafana cloud API token, risking unauthorized access to cloud-based monitoring services and data exposure.", Description: "Grafana cloud api token",
RuleID: "grafana-cloud-api-token", RuleID: "grafana-cloud-api-token",
SecretGroup: 1,
Regex: generateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`, true), Regex: generateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`),
Keywords: []string{"glc_"}, Keywords: []string{"glc_"},
} }
// validate // validate
@@ -46,11 +46,11 @@ func GrafanaCloudApiToken() *config.Rule {
func GrafanaServiceAccountToken() *config.Rule { func GrafanaServiceAccountToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a Grafana service account token, posing a risk of compromised monitoring services and data integrity.", Description: "Grafana service account token",
RuleID: "grafana-service-account-token", RuleID: "grafana-service-account-token",
SecretGroup: 1,
Regex: generateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`, true), Regex: generateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`),
Keywords: []string{"glsa_"}, Keywords: []string{"glsa_"},
} }
// validate // validate
+1 -25
View File
@@ -1,7 +1,6 @@
package rules package rules
import ( import (
"fmt"
"regexp" "regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
@@ -11,7 +10,7 @@ import (
func Hashicorp() *config.Rule { func Hashicorp() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Uncovered a HashiCorp Terraform user/org API token, which may lead to unauthorized infrastructure management and security breaches.", Description: "HashiCorp Terraform user/org API token",
RuleID: "hashicorp-tf-api-token", RuleID: "hashicorp-tf-api-token",
Regex: regexp.MustCompile(`(?i)[a-z0-9]{14}\.atlasv1\.[a-z0-9\-_=]{60,70}`), Regex: regexp.MustCompile(`(?i)[a-z0-9]{14}\.atlasv1\.[a-z0-9\-_=]{60,70}`),
Keywords: []string{"atlasv1"}, Keywords: []string{"atlasv1"},
@@ -23,26 +22,3 @@ func Hashicorp() *config.Rule {
} }
return validate(r, tps, nil) return validate(r, tps, nil)
} }
func HashicorpField() *config.Rule {
keywords := []string{"administrator_login_password", "password"}
// define rule
r := config.Rule{
Description: "Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.",
RuleID: "hashicorp-tf-password",
Regex: generateSemiGenericRegex(keywords, fmt.Sprintf(`"%s"`, alphaNumericExtended("8,20")), true),
Keywords: keywords,
}
tps := []string{
// Example from: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_server.html
"administrator_login_password = " + `"thisIsDog11"`,
// https://registry.terraform.io/providers/petoju/mysql/latest/docs
"password = " + `"rootpasswd"`,
}
fps := []string{
"administrator_login_password = var.db_password",
`password = "${aws_db_instance.default.password}"`,
}
return validate(r, tps, fps)
}
+4 -4
View File
@@ -7,11 +7,11 @@ import (
func Heroku() *config.Rule { func Heroku() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Heroku API Key, potentially compromising cloud application deployments and operational security.", Description: "Heroku API Key",
RuleID: "heroku-api-key", RuleID: "heroku-api-key",
Regex: generateSemiGenericRegex([]string{"heroku"}, hex8_4_4_4_12(), true), Regex: generateSemiGenericRegex([]string{"heroku"}, hex8_4_4_4_12()),
SecretGroup: 1,
Keywords: []string{"heroku"}, Keywords: []string{"heroku"},
} }
// validate // validate
+4 -4
View File
@@ -7,12 +7,12 @@ import (
func HubSpot() *config.Rule { func HubSpot() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Found a HubSpot API Token, posing a risk to CRM data integrity and unauthorized marketing operations.", Description: "HubSpot API Token",
RuleID: "hubspot-api-key", RuleID: "hubspot-api-key",
Regex: generateSemiGenericRegex([]string{"hubspot"}, Regex: generateSemiGenericRegex([]string{"hubspot"},
`[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}`, true), `[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}`),
SecretGroup: 1,
Keywords: []string{"hubspot"}, Keywords: []string{"hubspot"},
} }
// validate // validate
-115
View File
@@ -1,115 +0,0 @@
package rules
import (
"fmt"
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
// Reference: https://huggingface.co/docs/hub/security-tokens
//
// Old tokens have the prefix `api_`, however, I am not sure it's worth detecting them as that would be high noise.
// https://huggingface.co/docs/api-inference/quicktour
func HuggingFaceAccessToken() *config.Rule {
// define rule
r := config.Rule{
RuleID: "huggingface-access-token",
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})(?:$|[\\'"` + "`" + ` <])`),
Entropy: 1,
Keywords: []string{
"hf_",
},
}
// validate
tps := []string{
`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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`,
`huggingface-cli login --token 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`,
`huggingface-cli login --token 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`,
`-H "Authorization: Bearer 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"`,
`DEV=1 HF_TOKEN=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 poetry run python app.py`,
`use_auth_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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"'`,
` " hf_token = \"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\"\n",`,
`# Not critical, only usable on the sandboxed CI instance.
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")`,
}
fps := []string{
`- (id)hf_requiredCharacteristicTypesForDisplayMetadata;`,
`amazon.de#@#div[data-cel-widget="desktop-rhf_SponsoredProductsRemoteRHFSearchEXPSubsK2ClickPagination"]`,
` _kHMSymptomhf_generatedByHomeAppForDebuggingPurposesKey,`,
` #define OSCHF_DebugGetExpectedAverageCrystalAmplitude NOROM_OSCHF_DebugGetExpectedAverageCrystalAmplitude`,
` M_UINT (ServingCellPriorityParametersDescription_t, H_PRIO, 2, &hf_servingcellpriorityparametersdescription_h_prio),`,
`+HWI-ST565_0092:4:1101:5508:5860#ACTTGA/1
bb_eeeeegfgffhiiiiiiiiiiihiiiiicgafhf_eefghihhiiiifhifhhdhifhiiiihifdgdhggf\bbceceedbcd
@HWI-ST565_0092:4:1101:7621:5770#ACTTGA/1`,
`y{}x|~|}{~}}~|~}||�~|�{��|{}{|~z{}{{|{||{|}|{}{~|y}vjoePbUBJ7&;"; <; :;?!!;<7%$IACa_ecghbfbaebejhahfbhf_ddbficghbgfbhhcghdghfhigiifhhehhdggcgfchf_fgcei^[[.40&54"5666 6`,
` change_dir(cwd)
subdirs = glob.glob('HF_CAASIMULIAComputeServicesBuildTime.HF*.Linux64')
if len(subdirs) == 1:`,
` os.environ.get("HF_AUTH_TOKEN",
"hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),`,
`# HuggingFace API Token https://huggingface.co/settings/tokens
HUGGINGFACE_API_TOKEN=hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,`,
}
return validate(r, tps, fps)
}
// Will be deprecated Aug 1st, 2023.
func HuggingFaceOrganizationApiToken() *config.Rule {
// define rule
r := config.Rule{
RuleID: "huggingface-organization-api-token",
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})(?:$|[\\'"` + "`" + ` <\),])`),
Entropy: 2,
Keywords: []string{
"api_org_",
},
}
// validate
tps := []string{
`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`,
"`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`",
`\'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'\`,
`\"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\"`,
`,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,`,
`(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)`,
`<foo>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</foo>`,
`def test_private_space(self):
hf_token = "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" # Intentionally revealing this key for testing purposes
io = gr.load(`,
`hf_token = "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" # Intentionally revealing this key for testing purposes`,
`"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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'`,
fmt.Sprintf("api_org_%s", secrets.NewSecret(`[a-zA-Z]{34}`)),
}
fps := []string{
`public static final String API_ORG_EXIST = "APIOrganizationExist";`,
`const api_org_controller = require('../../controllers/api/index').organizations;`,
`API_ORG_CREATE("https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token=ACCESS_TOKEN"),`,
`def test_internal_api_org_inclusion_with_href(api_name, href, expected, monkeypatch, called_with):
monkeypatch.setattr("requests.sessions.Session.request", called_with)`,
` def _api_org_96726c78_4ae3_402f_b08b_7a78c6903d2a(self, method, url, body, headers):
body = self.fixtures.load("api_org_96726c78_4ae3_402f_b08b_7a78c6903d2a.xml")
return httplib.OK, body, headers, httplib.responses[httplib.OK]`,
`<p>You should see a token <code>hf_xxxxx</code> (old tokens are <code>api_XXXXXXXX</code> or <code>api_org_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</code>).</p>`,
` From Hugging Face docs:
You should see a token hf_xxxxx (old tokens are api_XXXXXXXX or api_org_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).
If you do not submit your API token when sending requests to the API, you will not be able to run inference on your private models.`,
}
return validate(r, tps, fps)
}
-31
View File
@@ -1,31 +0,0 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
func InfracostAPIToken() *config.Rule {
// define rule
r := config.Rule{
// Human readable description of the rule
Description: "Detected an Infracost API Token, risking unauthorized access to cloud cost estimation tools and financial data.",
// Unique ID for the rule
RuleID: "infracost-api-token",
// Regex capture group for the actual secret
// Regex used for detecting secrets. See regex section below for more details
Regex: generateUniqueTokenRegex(`ico-[a-zA-Z0-9]{32}`, true),
// Keywords used for string matching on fragments (think of this as a prefilter)
Keywords: []string{"ico-"},
}
// validate
tps := []string{
generateSampleSecret("ico", "ico-"+secrets.NewSecret("[A-Za-z0-9]{32}")),
}
return validate(r, tps, nil)
}
+4 -4
View File
@@ -8,11 +8,11 @@ import (
func Intercom() *config.Rule { func Intercom() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified an Intercom API Token, which could compromise customer communication channels and data privacy.", Description: "Intercom API Token",
RuleID: "intercom-api-key", RuleID: "intercom-api-key",
Regex: generateSemiGenericRegex([]string{"intercom"}, alphaNumericExtended("60"), true), Regex: generateSemiGenericRegex([]string{"intercom"}, alphaNumericExtended("60")),
SecretGroup: 1,
Keywords: []string{"intercom"}, Keywords: []string{"intercom"},
} }
// validate // validate
-64
View File
@@ -1,64 +0,0 @@
package rules
import (
"fmt"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
func JFrogAPIKey() *config.Rule {
keywords := []string{"jfrog", "artifactory", "bintray", "xray"}
// Define Rule
r := config.Rule{
// Human readable description of the rule
Description: "Found a JFrog API Key, posing a risk of unauthorized access to software artifact repositories and build pipelines.",
// Unique ID for the rule
RuleID: "jfrog-api-key",
// Regex capture group for the actual secret
// Regex used for detecting secrets. See regex section below for more details
Regex: generateSemiGenericRegex(keywords, alphaNumeric("73"), true),
// Keywords used for string matching on fragments (think of this as a prefilter)
Keywords: keywords,
}
// validate
tps := []string{
fmt.Sprintf("--set imagePullSecretJfrog.password=%s", secrets.NewSecret(alphaNumeric("73"))),
}
return validate(r, tps, nil)
}
func JFrogIdentityToken() *config.Rule {
keywords := []string{"jfrog", "artifactory", "bintray", "xray"}
// Define Rule
r := config.Rule{
// Human readable description of the rule
Description: "Discovered a JFrog Identity Token, potentially compromising access to JFrog services and sensitive software artifacts.",
// Unique ID for the rule
RuleID: "jfrog-identity-token",
// Regex capture group for the actual secret
// Regex used for detecting secrets. See regex section below for more details
Regex: generateSemiGenericRegex(keywords, alphaNumeric("64"), true),
// Keywords used for string matching on fragments (think of this as a prefilter)
Keywords: keywords,
}
// validate
tps := []string{
generateSampleSecret("jfrog", secrets.NewSecret(alphaNumeric("64"))),
generateSampleSecret("artifactory", secrets.NewSecret(alphaNumeric("64"))),
generateSampleSecret("bintray", secrets.NewSecret(alphaNumeric("64"))),
generateSampleSecret("xray", secrets.NewSecret(alphaNumeric("64"))),
}
return validate(r, tps, nil)
}
+5 -172
View File
@@ -1,188 +1,21 @@
package rules package rules
import ( import (
b64 "encoding/base64"
"fmt"
"regexp"
"github.com/zricethezav/gitleaks/v8/config" "github.com/zricethezav/gitleaks/v8/config"
) )
func JWT() *config.Rule { func JWT() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.", Description: "JSON Web Token",
RuleID: "jwt", RuleID: "jwt",
Regex: generateUniqueTokenRegex(`ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9\/\\_-]{17,}\.(?:[a-zA-Z0-9\/\\_-]{10,}={0,2})?`, false), Regex: generateUniqueTokenRegex(`ey[0-9a-z]{30,34}\.ey[0-9a-z-\/_]{30,500}\.[0-9a-zA-Z-\/_]{10,200}`),
Keywords: []string{"ey"}, Keywords: []string{"ey"},
} }
// validate // validate
tps := []string{`eyJhbGciOieeeiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxM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FrWWpnNExUUmlOek10T1RCaE9TMHpZMlF4TmpZeFpqVTBOallTQld4dlkyRnMifQ.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 `
`"SessionToken": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiI2TjJCQUxYN0VMTzgyN0RYUzNHSyIsImFjciI6IjAiLCJhdWQiOiJhY2NvdW50IiwiYXV0aF90aW1lIjoxNTY5OTEwNTUyLCJhenAiOiJhY2NvdW50IiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJleHAiOjE1Njk5MTQ1NTQsImlhdCI6MTU2OTkxMDk1NCwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgxL2F1dGgvcmVhbG1zL2RlbW8iLCJqdGkiOiJkOTk4YTBlZS01NDk2LTQ4OWYtYWJlMi00ZWE5MjJiZDlhYWYiLCJuYmYiOjAsInBvbGljeSI6InJlYWR3cml0ZSIsInByZWZlcnJlZF91c2VybmFtZSI6Im5ld3VzZXIxIiwic2Vzc2lvbl9zdGF0ZSI6IjJiYTAyYTI2LWE5MTUtNDUxNC04M2M1LWE0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wb0lVcXJZOHQyenBBMnFYZkNtcjVWTzVaRXI0UnpIVV8tZW52dlEiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjM1MzczOTExMDQsImdyb3VwcyI6WyJncm91cDEiLCJncm91cDIiXSwiaWF0IjoxNTM3MzkxMTA0LCJpc3MiOiJ0ZXN0aW5nQHNlY3VyZS5pc3Rpby5pbyIsInNjb3BlIjpbInNjb3BlMSIsInNjb3BlMiJdLCJzdWIiOiJ0ZXN0aW5nQHNlY3VyZS5pc3Rpby5pbyJ9.EdJnEZSH6X8hcyEii7c8H5lnhgjB5dwo07M5oheC8Xz8mOllyg--AHCFWHybM48reunF--oGaG6IXVngCEpVF0_P5DwsUoBgpPmK1JOaKN6_pe9sh0ZwTtdgK_RP01PuI7kUdbOTlkuUi2AO-qUyOm7Art2POzo36DLQlUXv8Ad7NBOqfQaKjE9ndaPWT7aexUsBHxmgiGbz1SyLH879f7uHYPbPKlpHU6P9S-DaKnGLaEchnoKnov7ajhrEhGXAQRukhDPKUHO9L30oPIr5IJllEQfHYtt6IZvlNUGeLUcif3wpry1R5tBXRicx2sXMQ7LyuDremDbcNy_iE76Upg`, // gitleaks:allow
`python examples/cli.py eyJhbGciOiJIUzI1NiJ9.eyJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkJhZFNlY3JldHMiLCJleHAiOjE1OTMxMzM0ODMsImlhdCI6MTQ2NjkwMzA4M30.ovqRikAo_0kKJ0GVrAwQlezymxrLGjcEiW_s3UJMMCo`, // gitleaks:allow
`"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VybmFtZTpib2IifQ.HcfCW67Uda-0gz54ZWTqmtgJnZeNem0Q757eTa9EZuw"`, // gitleaks:allow
`"value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODk1ODU1NjN9.PtfDS1niGoZ7pV6kplI-_q1fVKLnknQ3IwcrL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YmVkMC1jYWRmYjYxNzA1N2YiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZXJuZXRlcy1kYXNoYm9hcmQ6YWRtaW4tdXNlciJ9.LaBPEh6Qantd8tAc0X5DY9dDwUqZpxu38FHnp9TSJw-ghs3TsjrscFulUeEAtp2ng3ElLcU4SbNKPGJflF2dyW9Tmfn-Kt_6Jwq8HQ9GOCwAicEz0JVireHA7EWhATzuT56eO6MTe-2j5bpGnPQRJJtQ8AbtAN3nVK7RPjSzmc8Ppqx1z5i4oCGwiyRlGwqT-FkCtQLbQaQ4XmrASQoN4pJ_OBy5slztUhk32HdGP6pQx5c-nfei-of_4ij_fHrP0xEEfmVVvXqi9WKv1PLkQ3qTiSFDzv8M2sE4T6XmCGBbw7gyHzEGSpOAPZr00bX_YMCUvEF0lyP4YK696xWCBA`, // gitleaks:allow
`$ curl "http://admin:password@127.0.0.1:8080/api/v2/token"
{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiQVBJIl0sImV4cCI6MTYxMzMzNTI2MSwianRpIjoiYzBrb2gxZmNkcnBjaHNzMGZwZmciLCJuYmYiOjE2MTMzMzQ2MzEsInBlcm1pc3Npb25zIjpbIioiXSwic3ViIjoiYUJ0SHUwMHNBUmxzZ29yeEtLQ1pZZWVqSTRKVTlXbThHSGNiVWtWVmc1TT0iLCJ1c2VybmFtZSI6ImFkbWluIn0.WiyqvUF-92zCr--y4Q_sxn-tPnISFzGZd_exsG-K7ME","expires_at":"2021-02-14T20:41:01Z"}`, // gitleaks:allow
`curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiQVBJIl0sImV4cCI6MTYxMzMzNTI2MSwianRpIjoiYzBrb2gxZmNkcnBjaHNzMGZwZmciLCJuYmYiOjE2MTMzMzQ2MzEsInBlcm1pc3Npb25zIjpbIioiXSwic3ViIjoiYUJ0SHUwMHNBUmxzZ29yeEtLQ1pZZWVqSTRKVTlXbThHSGNiVWtWVmc1TT0iLCJ1c2VybmFtZSI6ImFkbWluIn0.WiyqvUF-92zCr--y4Q_sxn-tPnISFzGZd_exsG-K7ME" "http://127.0.0.1:8080/api/v2/dumpdata?output-data=1"`, // gitleaks:allow
`"authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiZ3Vlc3QiLCJzdWIiOiJZV3hwWTJVPSIsIm5iZiI6MTUxNDg1MTEzOSwiZXhwIjoxNjQxMDgxNTM5fQ.K5DnnbbIOspRbpCr2IKXE9cPVatGOCBrBQobQmBmaeU"`, // gitleaks:allow
`{"signatures": [ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmaWxlcyI6W3sibmFtZSI6Ii5tYW5pZmVzdCIsImhhc2giOiJjMjEzMTU0NGM3MTZhMjVhNWUzMWY1MDQzMDBmNTI0MGU4MjM1Y2FkYjlhNTdmMGJkMWI2ZjRiZDc0YjI2NjEyIiwiYWxnb3JpdGhtIjoiU0hBMjU2In0seyJuYW1lIjoicm9sZXMvYmluZGluZ3MvZGF0YS5qc29uIiwiaGFzaCI6IjQyY2ZlNjc2OGI1N2JiNWY3NTAzYzE2NWMyOGRkMDdhYzViODEzNTU0ZWJjODUwZjJjYzM1ODQzZTcxMzdiMWQifV0sImlhdCI6MTU5MjI0ODAyNywiaXNzIjoiSldUU2VydmljZSIsImtleWlkIjoibXlQdWJsaWNLZXkiLCJzY29wZSI6IndyaXRlIn0.ZjtUgXC6USwmhv4XP9gFH6MzZwpZrGpAL_2sTK1P-mg"]}`, // gitleaks:allow
`"id_token": "eyJ4NXQiOiJOVEF4Wm1NeE5ETXlaRGczTVRVMVpHTTBNekV6T0RKaFpXSTRORE5sWkRVMU9HRmtOakZpTVEiLCJraWQiOiJOVEF4Wm1NeE5ETXlaRGczTVRVMVpHTTBNekV6T0RKaFpXSTRORE5sWkRVMU9HRmtOakZpTVEiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJQb0VnWFA2dVZPNDVJc0VOUm5nRFhqNUF1NVlhIiwiYXpwIjoiUG9FZ1hQNnVWTzQ1SXNFTlJuZ0RYajVBdTVZYSIsImlzcyI6Imh0dHBzOlwvXC9sb2NhbGhvc3Q6OTQ0M1wvb2F1dGgyXC90b2tlbiIsImV4cCI6MTUzNDg5MTc3OCwiaWF0IjoxNTM0ODg4MTc4LCJqdGkiOiIxODQ0MzI5Yy1kNjVhLTQ4YTMtODIyOC05ZGY3M2ZlODNkNTYifQ.ELZ8ujk2Xp9xTGgMqnCa5ehuimaAPXWlSCW5QeBbTJIT4M5OB_2XEVIV6p89kftjUdKu50oiYe4SbfrxmLm6NGSGd2qxkjzJK3SRKqsrmVWEn19juj8fz1neKtUdXVHuSZu6ws_bMDy4f_9hN2Jv9dFnkoyeNT54r4jSTJ4A2FzN2rkiURheVVsc8qlm8O7g64Az-5h4UGryyXU4zsnjDCBKYk9jdbEpcUskrFMYhuUlj1RWSASiGhHHHDU5dTRqHkVLIItfG48k_fb-ehU60T7EFWH1JBdNjOxM9oN_yb0hGwOjLUyCUJO_Y7xcd5F4dZzrBg8LffFmvJ09wzHNtQ",`, // gitleaks:allow
` # The following default key is generated by the local Supabase start and doesn't change
- SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0`, // gitleaks:allow
`Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoxLCJiIjoyLCJjIjozfQ.hxhGCCCmGV9nT1slief1WgEsOsfdnlVizNrODxfh1M8`, // gitleaks:allow
`--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJhY3RvclR5cGUiOiJVU0VSIiwiYWN0b3JJZCI6ImRhdGFodWIiLCJ0eXBlIjoiUEVSU09OQUwiLCJ2ZXJzaW9uIjoiMSIsImV4cCI6MTY1MDY2MDY1NSwianRpIjoiM2E4ZDY3ZTItOTM5Yi00NTY3LWE0MjYtZDdlMDA1ZGU3NjJjIiwic3ViIjoiZGF0YWh1YiIsImlzcyI6ImRhdGFodWItbWV0YWRhdGEtc2VydmljZSJ9.pp_vW2u1tiiTT7U0nDF2EQdcayOMB8jatiOA8Je4JJA' \`, // gitleaks:allow
`"Cookie": "auth-token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NDIxMTEsImlzQWRtaW4iOmZhbHNlLCJnaXRodWJJZCI6ImR5ZXhwbG9kZSIsImFwcFJvbGVzIjpbInVzZXIiXSwicm9sZXMiOnsiNDciOiJzdHVkZW50IiwiNTYiOiJzdHVkZW50In0sImNvdXJzZXNSb2xlcyI6eyI0NyI6WyJzdHVkZW50Il0sIjU2IjpbInN0dWRlbnQiXX0sImNvdXJzZXMiOnsiNDciOnsibWVudG9ySWQiOm51bGwsInN0dWRlbnRJZCI6NjY3OTMsInJvbGVzIjpbInN0dWRlbnQiXX0sIjU2Ijp7Im1lbnRvcklkIjpudWxsLCJzdHVkZW50SWQiOjYzMzk4LCJyb2xlcyI6WyJzdHVkZW50Il19fSwiaWF0IjoxNjQ1MjA5NzI2LCJleHAiOjE2NDUzODI1MjZ9.btpYeSioEDUNMI6bAPqgu5zndA8XR5DT8P9U9kotOEA",`, // gitleaks:allow
`<li> <a class="cbtn btn-grad-s btn-shadow btn-width"
target="_blank"
href="https://demo.kuboard.cn/dashboard?k8sToken=eyJhbGciOiJSUzI1NiIsImtpZCI6InZ6SzVqZFNJOXZFMmxQSkhXamNBcFY4RU9FR0RvSUR5bzJIY0NwVG1zODQifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1l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IkEubm9ybWFsX3VzZXJfcHJpY2luZyIsIkEubm9ybWFsX3VzZXJfcHJpdmF0ZSIsIkEubm9ybWFsX3VzZXJfY29tbWVyY2lhbCIsIkEubm9ybWFsX3VzZXJfcGMiXSwibmFtZSI6WyJUZXN0Il0sIm1haWwiOlsiVGVzdEBleGFtcGxlLmNvbSJdLCJvcmdhbml6YXRpb24iOlsiWC1YeHh4eHguMTIzNCJdLCJsb2NhdGlvbiI6WyIxMjMyMSJdLCJ1bml0IjpbIjEwMyJdLCJjb3VudHJ5IjpbIkNOIl0sInVzZXJUeXBlIjoiZW1wbG95ZWUifSwiaWRlbnRpdHktaWQiOiJNb2NrIn0.EK5TbwsIgde3mT3n7NK2W7TCvpgQQLzshvPPANRQeUmKOv2AWbo_7vNEDTSkwUlaHRN3-dknv8F95p5MsGTzH6Uva8aOPJG6JdBIoYX_ud3aBN-hY1i2Xpf8pqjeINfY3_gDNAB9gdMznEej2uqhPwUXmZtcuWPdUCCeNqPJbRUAJeVXxLr_JtQzO2jmuwNY_YYp7KaEIANZwG1spvLuIGZ0HA03u8ye9c2lfqYcjgfIkjMrwgWPamR7joZOZPdQSO2EHrF7bUWMjRNY-FF5V7tOjEijkknE_nDq5THcEvx1seHYFdFNwy9LSSGGPVmZMKTKQ3UUlZZyBMXcOpOA9w`, // gitleaks:allow
// TODO: Detect newlines or escapes (\)?
// https://github.com/mongodb/mongo/blob/1960b792ade4e179ddc6113a3cd400e9492ca11d/src/mongo/crypto/README.JWT.md?plain=1#L115-L117
// TODO: Detect empty claims section?
// `eyJhbGciOiJFQ0RILUVTIiwiZW5jIjoiQTI1NkdDTSIsImVwayI6eyJrdHkiOiJFQyIsImNydiI6IlAtMzg0Iiwia2V5X29wcyI6W10sImV4dCI6dHJ1ZSwieCI6IllUcEY3bGtTc3JvZVVUVFdCb21LNzBTN0FhVTJyc0ptMURpZ1ZzbjRMY2F5eUxFNFBabldkYmFVcE9jQVV5a1ciLCJ5IjoiLU5pS3loUktjSk52Nm02Z0ZJUWc4cy1Xd1VXUW9uT3A5dkQ4cHpoa2tUU3U2RzFlU2FUTVlhZGltQ2Q4V0ExMSJ9LCJhcHUiOiIiLCJhcHYiOiIifQ`,
`String tokenWithNoneAlg = "eyJhbGciOiJub25lIn0.eyJzdWIiOiJ0ZXN0LXVzZXIifQ.";`, // gitleaks:allow
`# Req: Invoke-RestMethod -Uri 'http://localhost:8085/users' -Headers @{ 'X-API-KEY' = 'eyJhbGciOiJub25lIn0.eyJ1c2VybmFtZSI6Im1vcnR5Iiwic3ViIjoiMTIzIn0.' }`, // gitleaks:allow
} }
fps := []string{} return validate(r, tps, nil)
return validate(r, tps, fps)
}
func JWTBase64() *config.Rule {
// define rule
r := config.Rule{
RuleID: "jwt-base64",
Description: "Detected a Base64-encoded JSON Web Token, posing a risk of exposing encoded authentication and data exchange information.",
Regex: regexp.MustCompile(
`\bZXlK(?:(?P<alg>aGJHY2lPaU)|(?P<apu>aGNIVWlPaU)|(?P<apv>aGNIWWlPaU)|(?P<aud>aGRXUWlPaU)|(?P<b64>aU5qUWlP)|(?P<crit>amNtbDBJanBi)|(?P<cty>amRIa2lPaU)|(?P<epk>bGNHc2lPbn)|(?P<enc>bGJtTWlPaU)|(?P<jku>cWEzVWlPaU)|(?P<jwk>cWQyc2lPb)|(?P<iss>cGMzTWlPaU)|(?P<iv>cGRpSTZJ)|(?P<kid>cmFXUWlP)|(?P<key_ops>clpYbGZiM0J6SWpwY)|(?P<kty>cmRIa2lPaUp)|(?P<nonce>dWIyNWpaU0k2)|(?P<p2c>d01tTWlP)|(?P<p2s>d01uTWlPaU)|(?P<ppt>d2NIUWlPaU)|(?P<sub>emRXSWlPaU)|(?P<svt>emRuUWlP)|(?P<tag>MFlXY2lPaU)|(?P<typ>MGVYQWlPaUp)|(?P<url>MWNtd2l)|(?P<use>MWMyVWlPaUp)|(?P<ver>MlpYSWlPaU)|(?P<version>MlpYSnphVzl1SWpv)|(?P<x>NElqb2)|(?P<x5c>NE5XTWlP)|(?P<x5t>NE5YUWlPaU)|(?P<x5ts256>NE5YUWpVekkxTmlJNkl)|(?P<x5u>NE5YVWlPaU)|(?P<zip>NmFYQWlPaU))[a-zA-Z0-9\/\\_+\-\r\n]{40,}={0,2}`),
Keywords: []string{"zxlk"},
}
tps := generateTestValues()
fps := []string{
`-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG/MacGPG2 v2
Comment: GPGTools - https://gpgtools.org
mQENBFOrMNcBCAC+gLI4s3bUkobS5NpOQbWfjWXbqC0Ixpc5bZYDOvsmfstmswna
UWUXkRH9RONabzrAu4TGvW0f5DkC2fuWWHJhZWEccn+VE83+avMZN4/mzldSXPNX
A6F7+wHb1DjG+FCDcxMghkwDjGc16LOtZGufUo5iRQaC5pmNBOgDWdiObGPKOTEL
/uU8zLtKi2cibbkhRm22IGOzGyZMZN6zvEtPzlCp3eZEGMW0Ig+kbl6SaSDrSJNK
wElYcr/kJ9QF6CQ2iwZCGeL2jH5QaOi5uj1LXONpCd9nPeyDXc+Z20gXZiqkwRLc
IBPKza6hq/+4nwHBq8DNLv0W4xNC59jLbIhpABEBAAG0LEZyYW5rIE5vdGhhZnQg
PGZub3RoYWZ0QGFsdW1uaS5zdGFuZm9yZC5lZHU+iQE9BBMBCgAnBQJTqzDXAhsD
BQkHhh+ABQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJECqYOYG1w7FJOr4IAK8x
ec4jbjd6jkKe0YJGdPzg6TM73ISV5VrUlJX7O3jgxHB4M8KIHN/8A/+ZxLk7WM96
iq0C8atWHkCkQBtNduWhzAFccQlpxrrb18T5/oItcrmX9Dx2H5WeIl4WAoqe0MTk
iMPv29RMMH9RJvXL0ihuuH4Z0VxV5nurI9QmGzG69QOzfP9qY1EfQEceO7OqXXvY
vvBEUbmWshLuHJ6tOQY5ib3+aLO7m+yJTgJ7s6DHBDqLhqJPW0g7jiJcrDhYXsoS
JMMhMdUhckeZfTXm1N3Dc+/t9/E8NZjdZ2q/ZZzvygC4mu0uihwBKFqoFvXCHRaW
Rf4uYxE+/Upna/mbXQi5AQ0EU6sw1wEIALSp9Cc4t/F2k+rwEfEMXihXLcLM9Dmh
ukz++kMSCSuq4QHE+I4rLda/lVSNJCXaXrGVkzJuzmpEeQFdhr6nLW9ZYhzK8FIc
YyfsYTQxXUVf5W4e/XfKNoG9lrwQd5XHxJTBJ57XjjoWJYPQ69NWH8622foOBpux
xewgR2LEFgl+ksu7aQL4cQif6D3dko3EiIf1t0LDBXxFEREFCg+vkDFsDIW5bdaI
mDYwewGj7dAPLuo0sx1We+uBxb+j30xw/ASDOBhO3ratQWs+4w2FC7gw7cuf0CJC
/hMEw8nloGsIbqBmAnLdlQBxkfFG9DqRBNdSUM8xI66F0eGaaPHJ/S8AEQEAAYkB
JQQYAQoADwUCU6sw1wIbDAUJB4YfgAAKCRAqmDmBtcOxSZvvB/4w6S5YZQUmDVYK
9HPOm49qWxGPd5dLHr2g388sJ4LDK98Q9oicHgf2R35OXTyqhv4kFJL3eukQ6oLW
QOqQKLRycrQUu7eSESAiVmJ1gbuXLAWJmvUABGSYzj3BjWQRexYW/MZ51XqNftF9
oOSAoFWrdqeJbHoxPTXIb6P8EWk4Ei2j2bSIfBBSbBMSB6Kfk9IjpISM8+97RS5o
6605rmM5MY1Lz8cq8AZIYJs/MnUCZrpQ0c9QSWrflHAeWAy6xMGfdSynbEExQ4z8
AIfKWMro74nRFbAnv/BzrF2R8uHmdE7T6q9ZZsAydlaxQbdmyhCeGAdw93CwAypb
vHVobJ8A
=mIC1
-----END PGP PUBLIC KEY BLOCK-----`,
}
return validate(r, tps, fps)
}
func generateTestValues() []string {
// Sample JWT from RFC-7519
jwtSuffix := ".eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
// Validate known header parameters
// https://www.iana.org/assignments/jose/jose.xhtml
headers := map[string][]string{
"alg": {
`"ES256"`,
`"ES384"`,
`"ES512"`,
`"ECDH-ES"`,
`"HS256"`,
`"HS384"`,
`"HS512"`,
`"RS256"`,
`"RS384"`,
`"RS512"`,
`"PS256"`,
`"PS384"`, `"PS512"`,
`"none"`,
// Nonstandard
`"A128KW"`,
`"ECDH-ES+A256KW"`,
`"RSA-OAEP"`,
},
"apu": {`"Tx9qG69ZfodhRos-8qfhTPc6ZFnNUcgNDVdHqX1UR3s"`, `"RfXdxTfIzilWBzWWX3ovHBDzgDcLNy0BFJWSxa0dqnw"`},
"apv": {`"ZGlkOmVsZW06cm9wc3RlbjpFa"`, `"ZGlkOmtleTp6Nk1rak1TWWF1dU1neDlhekV5VW5UVzVvNWpGUmtiQnU1VDgzZjM5dU53bnNHbW0jejZMU29HdFpTclVNWnVkQWFnekVmWWY3azhqSFpjR0Q3OVNveDd2NHdDa0RLTlN3"`},
"aud": {`"https://vault.example.com"`, `"http://example.com"`},
"b64": {`true`, `false`},
"crit": {`["exp"]`},
"cty": {`"example"`, `"json"`},
"epk": {`{"crv":"X25519","kty":"OKP","x":"Tx9qG69ZfodhRos-8qfhTPc6ZFnNUcgNDVdHqX1UR3s"}`, `{"kty":"OKP","crv":"X25519","x":"RfXdxTfIzilWBzWWX3ovHBDzgDcLNy0BFJWSxa0dqnw"}`},
"enc": {`"A256GCM"`, `"A256CBC-HS512"`, `"A128CBC-HS256"`},
"jku": {`"https://c2id.com/jwks.json"`},
"jwk": {`{"crv":"P-256","kid":"DB2X:GSG2:72H3:AE3R:KCMI:Y77E:W7TF:ERHK:V5HR:JJ2Y:YMS6:HFGJ","kty":"EC","x":"jyr9-xZBorSC9fhqNsmfU_Ud31wbaZ-bVGz0HmySvbQ","y":"vkE6qZCCvYRWjSUwgAOvibQx_s8FipYkAiHS0VnAFNs"}`, `{"kty":"RSA","n":"jyTwiSJACtW_SW-aiihQS5Y5QR704zUwjhlevY0oK-y5wP7SlIc2hq2OPVRarCzjhOxZl2AQFzM5VCR7xRDcnIn9t_pl7Mgsnx9hKDS9yQ24YXzhQ4cMEVVuqwcHvXqPdWDSoCZ1ccMqiiPyBSNGQTXMPY5PBxMOR47XwOb4eNMOPqnzVio3MEtL2wphtEonP3MY6pxJJzzel04wSCRZ4n06reqwER3KwRFPnRpRxAgmSEot5IBLIT3jj-amT5sD7YoUDbPmLk23zgDBIhX88fkClilg1W-fUi1XxYZomEPGvV7OrE1yszt4YDPqKgjJT8t2JPy__1ri-8rZgSxn5Q","e":"AQAB"`},
"iss": {`"http://localhost:8087/realms/grafana"`, `"kubernetes/serviceaccount"`},
"iv": {`"zjJPRrj0TGez9JYkChTrB3iqKoDkiBhn"`, `"10PlAIteHLVABtt"`},
"kid": {`"my_key_id"`, `"did:example:123#zC1Rnuvw9rVa6E5TKF4uQVRuQuaCpVgB81Um2u17Fu7UK"`},
"key_ops": {`["sign"]`, `["decrypt"]`, `["encrypt"]`},
"kty": {`"EC"`, `"RSA"`},
"nonce": {`"Os_sBjfWzVZenwwjvLrwXA"`, `"LDDZAGcBuKYpuNlFTCxPYw"`},
"p2c": {`4096`, `1000`},
"p2s": {`"c_ORk4HSsqZD2LvVeCUHqg"`},
"ppt": {`"foo"`},
"sub": {`"project_path:my-group/my-project:ref_type:branch:ref:feature-branch-1"`, `"1234567890"`},
// I cannot find any real-world examples of the svt header
// and the RFC doesn't seem to explicitly state the content.
"svt": {``},
"tag": {`"h6mJqHn33oCsDd5X57MI-g"`},
"typ": {`"JWT"`, `"JWK"`, `"JSOE"`, `"JSON"`, `"plain"`},
"url": {`"https://example.com"`},
"use": {`"enc"`, `"sig"`},
"ver": {`"2"`, `"3"`},
"version": {`"2"`, `"3"`},
"x5c": {`["MIICmzCCAYMCBgF4HR7HNDANBgkqhkiG9w0BAQsFADARMQ8wDQYDVQQDDAZtYXN0ZXIwHhcNMjEwMzEwMTcwOTE5WhcNMzEwMzEwMTcxMDU5WjARMQ8wDQYDVQQDDAZtYXN0ZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDCpLzXHp8i09R2HU5YJPyncC4tiAWWmaDrVZenqynWlWKOjIXb0Y5JoP3ET68u16Bf7mHQGc/u9rRvCw4A92HpJ15WyUSJ80YcK0gPTE0Woc1ZxdK3h4t9AoA8VSrROwQ77w/VAdGrrJ4bwkAVrFqSRpqAsW5XxV3/bU8YkVaG8mh0kuFf/5ib0vxdSkg+mz+ZCuIxQ5YN77kNaMecO19XuaBo7FsG9WjfCPxXYuajkuLgdptPgwTN4np70h0WjaSP/jhjL2ixf48w+27wFDP+ic+B/TCOtVa3fj1GPo6RLxHGU0Zh64jFhmvRM6E/kX7IQ+FJcOwp1VPA9/vMABopAgMBAAEwDQYJKoZIhvcNAQELBQADggEBALILq1Z4oQNJZEUt24VZcvknsWtQtvPxl3JNcBQgDR5/IMgl5VndRZ9OT56KUqrR5xRsWiCvh5Lgv4fUEzAAo9ToiPLub1SKP063zWrvfgi3YZ19bty0iXFm7l2cpQ3ejFV7WpcdLJE0lapFdPLo6QaRdgNu/1p4vbYg7zSK1fQ0OY5b3ajhAx/bhWlrN685owRbO5/r4rUOa6oo9l4Qn7jUxKUx4rcoe7zUM7qrpOPqKvn0DBp3n1/+9pOZXCjIfZGvYwP5NhzBDCkRzaXcJHlOqWzMBzyovVrzVmUilBcj+EsTYJs0gVXKzduX5zO6YWhFs23lu7AijdkxTY65YM0="]`},
"x5t": {`"IYIeevIT57t8ppUejM42Bqx6f3I"`},
"x5t#S256": {`"TuOrBy2NcTlFSWuZ8Kh8W8AjQagb4fnfP1SlKMO8-So"`},
"x5u": {`"https://tel.example.org/passport.cer"`},
"zip": {`"DEF"`},
}
var examples []string
for key, values := range headers {
for _, value := range values {
header := fmt.Sprintf(`{"%s":%s}`, key, value)
jwt := []byte(b64.RawURLEncoding.EncodeToString([]byte(header)) + jwtSuffix)
examples = append(examples, b64.StdEncoding.EncodeToString(jwt))
examples = append(examples, b64.RawStdEncoding.EncodeToString(jwt))
examples = append(examples, b64.URLEncoding.EncodeToString(jwt))
examples = append(examples, b64.RawURLEncoding.EncodeToString(jwt))
}
}
return examples
} }
+3 -3
View File
@@ -9,10 +9,10 @@ func KrakenAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "kraken-access-token", RuleID: "kraken-access-token",
Description: "Identified a Kraken Access Token, potentially compromising cryptocurrency trading accounts and financial security.", Description: "Kraken Access Token",
Regex: generateSemiGenericRegex([]string{"kraken"}, Regex: generateSemiGenericRegex([]string{"kraken"},
alphaNumericExtendedLong("80,90"), true), alphaNumericExtendedLong("80,90")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"kraken", "kraken",
}, },
+6 -6
View File
@@ -9,9 +9,9 @@ func KucoinAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "kucoin-access-token", RuleID: "kucoin-access-token",
Description: "Found a Kucoin Access Token, risking unauthorized access to cryptocurrency exchange services and transactions.", Description: "Kucoin Access Token",
Regex: generateSemiGenericRegex([]string{"kucoin"}, hex("24"), true), Regex: generateSemiGenericRegex([]string{"kucoin"}, hex("24")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"kucoin", "kucoin",
}, },
@@ -28,9 +28,9 @@ func KucoinSecretKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "kucoin-secret-key", RuleID: "kucoin-secret-key",
Description: "Discovered a Kucoin Secret Key, which could lead to compromised cryptocurrency operations and financial data breaches.", Description: "Kucoin Secret Key",
Regex: generateSemiGenericRegex([]string{"kucoin"}, hex8_4_4_4_12(), true), Regex: generateSemiGenericRegex([]string{"kucoin"}, hex8_4_4_4_12()),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"kucoin", "kucoin",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func LaunchDarklyAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "launchdarkly-access-token", RuleID: "launchdarkly-access-token",
Description: "Uncovered a Launchdarkly Access Token, potentially compromising feature flag management and application functionality.", Description: "Launchdarkly Access Token",
Regex: generateSemiGenericRegex([]string{"launchdarkly"}, alphaNumericExtended("40"), true), Regex: generateSemiGenericRegex([]string{"launchdarkly"}, alphaNumericExtended("40")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"launchdarkly", "launchdarkly",
}, },
+4 -3
View File
@@ -10,7 +10,7 @@ import (
func LinearAPIToken() *config.Rule { func LinearAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Linear API Token, posing a risk to project management tools and sensitive task data.", Description: "Linear API Token",
RuleID: "linear-api-key", RuleID: "linear-api-key",
Regex: regexp.MustCompile(`lin_api_(?i)[a-z0-9]{40}`), Regex: regexp.MustCompile(`lin_api_(?i)[a-z0-9]{40}`),
Keywords: []string{"lin_api_"}, Keywords: []string{"lin_api_"},
@@ -26,10 +26,11 @@ func LinearAPIToken() *config.Rule {
func LinearClientSecret() *config.Rule { func LinearClientSecret() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a Linear Client Secret, which may compromise secure integrations and sensitive project management data.", Description: "Linear Client Secret",
RuleID: "linear-client-secret", RuleID: "linear-client-secret",
Regex: generateSemiGenericRegex([]string{"linear"}, hex("32"), true), Regex: generateSemiGenericRegex([]string{"linear"}, hex("32")),
Keywords: []string{"linear"}, Keywords: []string{"linear"},
SecretGroup: 1,
} }
// validate // validate
+6 -6
View File
@@ -9,12 +9,12 @@ 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: "LinkedIn Client secret",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"linkedin", "linkedin",
"linked-in", "linked-in",
}, alphaNumeric("16"), true), }, alphaNumeric("16")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"linkedin", "linkedin",
"linked-in", "linked-in",
@@ -32,12 +32,12 @@ func LinkedinClientID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "linkedin-client-id", RuleID: "linkedin-client-id",
Description: "Found a LinkedIn Client ID, risking unauthorized access to LinkedIn integrations and professional data exposure.", Description: "LinkedIn Client ID",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"linkedin", "linkedin",
"linked-in", "linked-in",
}, alphaNumeric("14"), true), }, alphaNumeric("14")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"linkedin", "linkedin",
"linked-in", "linked-in",
+6 -5
View File
@@ -8,10 +8,10 @@ import (
func LobPubAPIToken() *config.Rule { func LobPubAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a Lob Publishable API Key, posing a risk of exposing mail and print service integrations.", Description: "Lob Publishable API Key",
RuleID: "lob-pub-api-key", RuleID: "lob-pub-api-key",
Regex: generateSemiGenericRegex([]string{"lob"}, `(test|live)_pub_[a-f0-9]{31}`, true), Regex: generateSemiGenericRegex([]string{"lob"}, `(test|live)_pub_[a-f0-9]{31}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"test_pub", "test_pub",
"live_pub", "live_pub",
@@ -29,13 +29,14 @@ func LobPubAPIToken() *config.Rule {
func LobAPIToken() *config.Rule { func LobAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Uncovered a Lob API Key, which could lead to unauthorized access to mailing and address verification services.", Description: "Lob API Key",
RuleID: "lob-api-key", RuleID: "lob-api-key",
Regex: generateSemiGenericRegex([]string{"lob"}, `(live|test)_[a-f0-9]{35}`, true), Regex: generateSemiGenericRegex([]string{"lob"}, `(live|test)_[a-f0-9]{35}`),
Keywords: []string{ Keywords: []string{
"test_", "test_",
"live_", "live_",
}, },
SecretGroup: 1,
} }
// validate // validate
+3 -3
View File
@@ -9,9 +9,9 @@ func MailChimp() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "mailchimp-api-key", RuleID: "mailchimp-api-key",
Description: "Identified a Mailchimp API key, potentially compromising email marketing campaigns and subscriber data.", Description: "Mailchimp API key",
Regex: generateSemiGenericRegex([]string{"mailchimp"}, `[a-f0-9]{32}-us20`, true), Regex: generateSemiGenericRegex([]string{"mailchimp"}, `[a-f0-9]{32}-us20`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"mailchimp", "mailchimp",
}, },
+9 -9
View File
@@ -9,9 +9,9 @@ func MailGunPrivateAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "mailgun-private-api-token", RuleID: "mailgun-private-api-token",
Description: "Found a Mailgun private API token, risking unauthorized email service operations and data breaches.", Description: "Mailgun private API token",
Regex: generateSemiGenericRegex([]string{"mailgun"}, `key-[a-f0-9]{32}`, true), Regex: generateSemiGenericRegex([]string{"mailgun"}, `key-[a-f0-9]{32}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"mailgun", "mailgun",
}, },
@@ -28,9 +28,9 @@ func MailGunPubAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "mailgun-pub-key", RuleID: "mailgun-pub-key",
Description: "Discovered a Mailgun public validation key, which could expose email verification processes and associated data.", Description: "Mailgun public validation key",
Regex: generateSemiGenericRegex([]string{"mailgun"}, `pubkey-[a-f0-9]{32}`, true), Regex: generateSemiGenericRegex([]string{"mailgun"}, `pubkey-[a-f0-9]{32}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"mailgun", "mailgun",
}, },
@@ -47,9 +47,9 @@ func MailGunSigningKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "mailgun-signing-key", RuleID: "mailgun-signing-key",
Description: "Uncovered a Mailgun webhook signing key, potentially compromising email automation and data integrity.", Description: "Mailgun webhook signing key",
Regex: generateSemiGenericRegex([]string{"mailgun"}, `[a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8}`, true), Regex: generateSemiGenericRegex([]string{"mailgun"}, `[a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"mailgun", "mailgun",
}, },
+4 -4
View File
@@ -8,11 +8,11 @@ import (
func MapBox() *config.Rule { func MapBox() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Detected a MapBox API token, posing a risk to geospatial services and sensitive location data exposure.", Description: "MapBox API token",
RuleID: "mapbox-api-token", RuleID: "mapbox-api-token",
Regex: generateSemiGenericRegex([]string{"mapbox"}, `pk\.[a-z0-9]{60}\.[a-z0-9]{22}`, true), Regex: generateSemiGenericRegex([]string{"mapbox"}, `pk\.[a-z0-9]{60}\.[a-z0-9]{22}`),
SecretGroup: 1,
Keywords: []string{"mapbox"}, Keywords: []string{"mapbox"},
} }
// validate // validate
+3 -3
View File
@@ -9,9 +9,9 @@ func MattermostAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "mattermost-access-token", RuleID: "mattermost-access-token",
Description: "Identified a Mattermost Access Token, which may compromise team communication channels and data privacy.", Description: "Mattermost Access Token",
Regex: generateSemiGenericRegex([]string{"mattermost"}, alphaNumeric("26"), true), Regex: generateSemiGenericRegex([]string{"mattermost"}, alphaNumeric("26")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"mattermost", "mattermost",
}, },
+6 -6
View File
@@ -8,14 +8,14 @@ import (
func MessageBirdAPIToken() *config.Rule { func MessageBirdAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Found a MessageBird API token, risking unauthorized access to communication platforms and message data.", Description: "MessageBird API token",
RuleID: "messagebird-api-token", RuleID: "messagebird-api-token",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"messagebird", "messagebird",
"message-bird", "message-bird",
"message_bird", "message_bird",
}, alphaNumeric("25"), true), }, alphaNumeric("25")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"messagebird", "messagebird",
"message-bird", "message-bird",
@@ -35,14 +35,14 @@ func MessageBirdAPIToken() *config.Rule {
func MessageBirdClientID() *config.Rule { func MessageBirdClientID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a MessageBird client ID, potentially compromising API integrations and sensitive communication data.", Description: "MessageBird client ID",
RuleID: "messagebird-client-id", RuleID: "messagebird-client-id",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"messagebird", "messagebird",
"message-bird", "message-bird",
"message_bird", "message_bird",
}, hex8_4_4_4_12(), true), }, hex8_4_4_4_12()),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"messagebird", "messagebird",
"message-bird", "message-bird",
+3 -3
View File
@@ -9,10 +9,10 @@ func NetlifyAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "netlify-access-token", RuleID: "netlify-access-token",
Description: "Detected a Netlify Access Token, potentially compromising web hosting services and site management.", Description: "Netlify Access Token",
Regex: generateSemiGenericRegex([]string{"netlify"}, Regex: generateSemiGenericRegex([]string{"netlify"},
alphaNumericExtended("40,46"), true), alphaNumericExtended("40,46")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"netlify", "netlify",
}, },
+9 -9
View File
@@ -9,13 +9,13 @@ func NewRelicUserID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "new-relic-user-api-key", RuleID: "new-relic-user-api-key",
Description: "Discovered a New Relic user API Key, which could lead to compromised application insights and performance monitoring.", Description: "New Relic user API Key",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"new-relic", "new-relic",
"newrelic", "newrelic",
"new_relic", "new_relic",
}, `NRAK-[a-z0-9]{27}`, true), }, `NRAK-[a-z0-9]{27}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"NRAK", "NRAK",
}, },
@@ -32,13 +32,13 @@ func NewRelicUserKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "new-relic-user-api-id", RuleID: "new-relic-user-api-id",
Description: "Found a New Relic user API ID, posing a risk to application monitoring services and data integrity.", Description: "New Relic user API ID",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"new-relic", "new-relic",
"newrelic", "newrelic",
"new_relic", "new_relic",
}, alphaNumeric("64"), true), }, alphaNumeric("64")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"new-relic", "new-relic",
"newrelic", "newrelic",
@@ -57,13 +57,13 @@ func NewRelicBrowserAPIKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "new-relic-browser-api-token", RuleID: "new-relic-browser-api-token",
Description: "Identified a New Relic ingest browser API token, risking unauthorized access to application performance data and analytics.", Description: "New Relic ingest browser API token",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"new-relic", "new-relic",
"newrelic", "newrelic",
"new_relic", "new_relic",
}, `NRJS-[a-f0-9]{19}`, true), }, `NRJS-[a-f0-9]{19}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"NRJS-", "NRJS-",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func NPM() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "npm-access-token", RuleID: "npm-access-token",
Description: "Uncovered an npm access token, potentially compromising package management and code repository access.", Description: "npm access token",
Regex: generateUniqueTokenRegex(`npm_[a-z0-9]{36}`, true), Regex: generateUniqueTokenRegex(`npm_[a-z0-9]{36}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"npm_", "npm_",
}, },
+3 -3
View File
@@ -9,11 +9,11 @@ func NytimesAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "nytimes-access-token", RuleID: "nytimes-access-token",
Description: "Detected a Nytimes Access Token, risking unauthorized access to New York Times APIs and content services.", Description: "Nytimes Access Token",
Regex: generateSemiGenericRegex([]string{ Regex: generateSemiGenericRegex([]string{
"nytimes", "new-york-times,", "newyorktimes"}, "nytimes", "new-york-times,", "newyorktimes"},
alphaNumericExtended("32"), true), alphaNumericExtended("32")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"nytimes", "nytimes",
"new-york-times", "new-york-times",
+3 -3
View File
@@ -9,10 +9,10 @@ func OktaAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "okta-access-token", RuleID: "okta-access-token",
Description: "Identified an Okta Access Token, which may compromise identity management services and user authentication data.", Description: "Okta Access Token",
Regex: generateSemiGenericRegex([]string{"okta"}, Regex: generateSemiGenericRegex([]string{"okta"},
alphaNumericExtended("42"), true), alphaNumericExtended("42")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"okta", "okta",
}, },
-25
View File
@@ -1,25 +0,0 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
func OpenAI() *config.Rule {
// define rule
r := config.Rule{
RuleID: "openai-api-key",
Description: "Found an OpenAI API Key, posing a risk of unauthorized access to AI services and data manipulation.",
Regex: generateUniqueTokenRegex(`sk-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20}`, true),
Keywords: []string{
"T3BlbkFJ",
},
}
// validate
tps := []string{
generateSampleSecret("openaiApiKey", "sk-"+secrets.NewSecret(alphaNumeric("20"))+"T3BlbkFJ"+secrets.NewSecret(alphaNumeric("20"))),
}
return validate(r, tps, nil)
}
+9 -11
View File
@@ -11,10 +11,9 @@ func PlaidAccessID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "plaid-client-id", RuleID: "plaid-client-id",
Description: "Uncovered a Plaid Client ID, which could lead to unauthorized financial service integrations and data breaches.", Description: "Plaid Client ID",
Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("24"), true), Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("24")),
SecretGroup: 1,
Entropy: 3.5,
Keywords: []string{ Keywords: []string{
"plaid", "plaid",
}, },
@@ -31,10 +30,9 @@ func PlaidSecretKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "plaid-secret-key", RuleID: "plaid-secret-key",
Description: "Detected a Plaid Secret key, risking unauthorized access to financial accounts and sensitive transaction data.", Description: "Plaid Secret key",
Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("30"), true), Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("30")),
SecretGroup: 1,
Entropy: 3.5,
Keywords: []string{ Keywords: []string{
"plaid", "plaid",
}, },
@@ -51,10 +49,10 @@ func PlaidAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "plaid-api-token", RuleID: "plaid-api-token",
Description: "Discovered a Plaid API Token, potentially compromising financial data aggregation and banking services.", Description: "Plaid API Token",
Regex: generateSemiGenericRegex([]string{"plaid"}, Regex: generateSemiGenericRegex([]string{"plaid"},
fmt.Sprintf("access-(?:sandbox|development|production)-%s", hex8_4_4_4_12()), true), fmt.Sprintf("access-(?:sandbox|development|production)-%s", hex8_4_4_4_12())),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"plaid", "plaid",
}, },
+9 -9
View File
@@ -9,9 +9,9 @@ func PlanetScalePassword() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "planetscale-password", RuleID: "planetscale-password",
Description: "Discovered a PlanetScale password, which could lead to unauthorized database operations and data breaches.", Description: "PlanetScale password",
Regex: generateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{32,64}`, true), Regex: generateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{32,64}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"pscale_pw_", "pscale_pw_",
}, },
@@ -30,9 +30,9 @@ func PlanetScaleAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "planetscale-api-token", RuleID: "planetscale-api-token",
Description: "Identified a PlanetScale API token, potentially compromising database management and operations.", Description: "PlanetScale API token",
Regex: generateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64}`, true), Regex: generateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"pscale_tkn_", "pscale_tkn_",
}, },
@@ -51,9 +51,9 @@ func PlanetScaleOAuthToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "planetscale-oauth-token", RuleID: "planetscale-oauth-token",
Description: "Found a PlanetScale OAuth token, posing a risk to database access control and sensitive data integrity.", Description: "PlanetScale OAuth token",
Regex: generateUniqueTokenRegex(`pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64}`, true), Regex: generateUniqueTokenRegex(`pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"pscale_oauth_", "pscale_oauth_",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func PostManAPI() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "postman-api-token", RuleID: "postman-api-token",
Description: "Uncovered a Postman API token, potentially compromising API testing and development workflows.", Description: "Postman API token",
Regex: generateUniqueTokenRegex(`PMAK-(?i)[a-f0-9]{24}\-[a-f0-9]{34}`, true), Regex: generateUniqueTokenRegex(`PMAK-(?i)[a-f0-9]{24}\-[a-f0-9]{34}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"PMAK-", "PMAK-",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func Prefect() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "prefect-api-token", RuleID: "prefect-api-token",
Description: "Detected a Prefect API token, risking unauthorized access to workflow management and automation services.", Description: "Prefect API token",
Regex: generateUniqueTokenRegex(`pnu_[a-z0-9]{36}`, true), Regex: generateUniqueTokenRegex(`pnu_[a-z0-9]{36}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"pnu_", "pnu_",
}, },
+2 -5
View File
@@ -9,9 +9,9 @@ import (
func PrivateKey() *config.Rule { func PrivateKey() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.", Description: "Private Key",
RuleID: "private-key", RuleID: "private-key",
Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY( BLOCK)?----`), Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY----`),
Keywords: []string{"-----BEGIN"}, Keywords: []string{"-----BEGIN"},
} }
@@ -23,9 +23,6 @@ anything
abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz
-----END RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----
`, `,
`-----BEGIN PRIVATE KEY BLOCK-----
anything
-----END PRIVATE KEY BLOCK-----`,
} // gitleaks:allow } // gitleaks:allow
return validate(r, tps, nil) return validate(r, tps, nil)
} }
+3 -3
View File
@@ -9,9 +9,9 @@ func PulumiAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "pulumi-api-token", RuleID: "pulumi-api-token",
Description: "Found a Pulumi API token, posing a risk to infrastructure as code services and cloud resource management.", Description: "Pulumi API token",
Regex: generateUniqueTokenRegex(`pul-[a-f0-9]{40}`, true), Regex: generateUniqueTokenRegex(`pul-[a-f0-9]{40}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"pul-", "pul-",
}, },
+1 -1
View File
@@ -10,7 +10,7 @@ import (
func PyPiUploadToken() *config.Rule { func PyPiUploadToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
Description: "Discovered a PyPI upload token, potentially compromising Python package distribution and repository integrity.", Description: "PyPI upload token",
RuleID: "pypi-upload-token", RuleID: "pypi-upload-token",
Regex: regexp.MustCompile( Regex: regexp.MustCompile(
`pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,1000}`), `pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,1000}`),
+3 -3
View File
@@ -9,10 +9,10 @@ func RapidAPIAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "rapidapi-access-token", RuleID: "rapidapi-access-token",
Description: "Uncovered a RapidAPI Access Token, which could lead to unauthorized access to various APIs and data services.", Description: "RapidAPI Access Token",
Regex: generateSemiGenericRegex([]string{"rapidapi"}, Regex: generateSemiGenericRegex([]string{"rapidapi"},
alphaNumericExtendedShort("50"), true), alphaNumericExtendedShort("50")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"rapidapi", "rapidapi",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func ReadMe() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "readme-api-token", RuleID: "readme-api-token",
Description: "Detected a Readme API token, risking unauthorized documentation management and content exposure.", Description: "Readme API token",
Regex: generateUniqueTokenRegex(`rdme_[a-z0-9]{70}`, true), Regex: generateUniqueTokenRegex(`rdme_[a-z0-9]{70}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"rdme_", "rdme_",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func RubyGemsAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "rubygems-api-token", RuleID: "rubygems-api-token",
Description: "Identified a Rubygem API token, potentially compromising Ruby library distribution and package management.", Description: "Rubygem API token",
Regex: generateUniqueTokenRegex(`rubygems_[a-f0-9]{48}`, true), Regex: generateUniqueTokenRegex(`rubygems_[a-f0-9]{48}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"rubygems_", "rubygems_",
}, },
+11 -27
View File
@@ -15,13 +15,11 @@ const (
caseInsensitive = `(?i)` caseInsensitive = `(?i)`
// identifier prefix (just an ignore group) // identifier prefix (just an ignore group)
identifierCaseInsensitivePrefix = `(?i:` identifierPrefix = `(?:`
identifierCaseInsensitiveSuffix = `)` identifierSuffix = `)(?:[0-9a-z\-_\t .]{0,20})(?:[\s|']|[\s|"]){0,3}`
identifierPrefix = `(?:`
identifierSuffix = `)(?:[0-9a-z\-_\t .]{0,20})(?:[\s|']|[\s|"]){0,3}`
// commonly used assignment operators or function call // commonly used assignment operators or function call
operator = `(?:=|>|:{1,3}=|\|\|:|<=|=>|:|\?=)` operator = `(?:=|>|:=|\|\|:|<=|=>|:)`
// boundaries for the secret // boundaries for the secret
// \x60 = ` // \x60 = `
@@ -30,18 +28,12 @@ const (
secretSuffix = `)(?:['|\"|\n|\r|\s|\x60|;]|$)` secretSuffix = `)(?:['|\"|\n|\r|\s|\x60|;]|$)`
) )
func generateSemiGenericRegex(identifiers []string, secretRegex string, isCaseInsensitive bool) *regexp.Regexp { func generateSemiGenericRegex(identifiers []string, secretRegex string) *regexp.Regexp {
var sb strings.Builder var sb strings.Builder
// The identifiers should always be case-insensitive. sb.WriteString(caseInsensitive)
// This is inelegant but prevents an extraneous `(?i:)` from being added to the pattern; it could be removed. sb.WriteString(identifierPrefix)
if isCaseInsensitive { sb.WriteString(strings.Join(identifiers, "|"))
sb.WriteString(caseInsensitive) sb.WriteString(identifierSuffix)
writeIdentifiers(&sb, identifiers)
} else {
sb.WriteString(identifierCaseInsensitivePrefix)
writeIdentifiers(&sb, identifiers)
sb.WriteString(identifierCaseInsensitiveSuffix)
}
sb.WriteString(operator) sb.WriteString(operator)
sb.WriteString(secretPrefix) sb.WriteString(secretPrefix)
sb.WriteString(secretRegex) sb.WriteString(secretRegex)
@@ -49,17 +41,9 @@ func generateSemiGenericRegex(identifiers []string, secretRegex string, isCaseIn
return regexp.MustCompile(sb.String()) return regexp.MustCompile(sb.String())
} }
func writeIdentifiers(sb *strings.Builder, identifiers []string) { func generateUniqueTokenRegex(secretRegex string) *regexp.Regexp {
sb.WriteString(identifierPrefix)
sb.WriteString(strings.Join(identifiers, "|"))
sb.WriteString(identifierSuffix)
}
func generateUniqueTokenRegex(secretRegex string, isCaseInsensitive bool) *regexp.Regexp {
var sb strings.Builder var sb strings.Builder
if isCaseInsensitive { sb.WriteString(caseInsensitive)
sb.WriteString(caseInsensitive)
}
sb.WriteString(secretPrefixUnique) sb.WriteString(secretPrefixUnique)
sb.WriteString(secretRegex) sb.WriteString(secretRegex)
sb.WriteString(secretSuffix) sb.WriteString(secretSuffix)
@@ -91,7 +75,7 @@ func validate(r config.Rule, truePositives []string, falsePositives []string) *c
} }
for _, fp := range falsePositives { for _, fp := range falsePositives {
if len(d.DetectString(fp)) != 0 { if len(d.DetectString(fp)) != 0 {
log.Fatal().Msgf("Failed to validate. For rule ID [%s], false positive [%s] was detected by regexp [%s]", r.RuleID, fp, r.Regex) log.Fatal().Msgf("Failed to validate (fp) [%s]", r.RuleID)
} }
} }
return &r return &r
-24
View File
@@ -1,24 +0,0 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
func ScalingoAPIToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Found a Scalingo API token, posing a risk to cloud platform services and application deployment security.",
RuleID: "scalingo-api-token",
Regex: regexp.MustCompile(`\btk-us-[a-zA-Z0-9-_]{48}\b`),
Keywords: []string{"tk-us-"},
}
// validate
tps := []string{
generateSampleSecret("scalingo", "tk-us-"+secrets.NewSecret(alphaNumericExtendedShort("48"))),
}
return validate(r, tps, nil)
}
+6 -6
View File
@@ -9,9 +9,9 @@ func SendbirdAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "sendbird-access-token", RuleID: "sendbird-access-token",
Description: "Uncovered a Sendbird Access Token, potentially risking unauthorized access to communication services and user data.", Description: "Sendbird Access Token",
Regex: generateSemiGenericRegex([]string{"sendbird"}, hex("40"), true), Regex: generateSemiGenericRegex([]string{"sendbird"}, hex("40")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"sendbird", "sendbird",
}, },
@@ -28,9 +28,9 @@ func SendbirdAccessID() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "sendbird-access-id", RuleID: "sendbird-access-id",
Description: "Discovered a Sendbird Access ID, which could compromise chat and messaging platform integrations.", Description: "Sendbird Access ID",
Regex: generateSemiGenericRegex([]string{"sendbird"}, hex8_4_4_4_12(), true), Regex: generateSemiGenericRegex([]string{"sendbird"}, hex8_4_4_4_12()),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"sendbird", "sendbird",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func SendGridAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "sendgrid-api-token", RuleID: "sendgrid-api-token",
Description: "Detected a SendGrid API token, posing a risk of unauthorized email service operations and data exposure.", Description: "SendGrid API token",
Regex: generateUniqueTokenRegex(`SG\.(?i)[a-z0-9=_\-\.]{66}`, true), Regex: generateUniqueTokenRegex(`SG\.(?i)[a-z0-9=_\-\.]{66}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"SG.", "SG.",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func SendInBlueAPIToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "sendinblue-api-token", RuleID: "sendinblue-api-token",
Description: "Identified a Sendinblue API token, which may compromise email marketing services and subscriber data privacy.", Description: "Sendinblue API token",
Regex: generateUniqueTokenRegex(`xkeysib-[a-f0-9]{64}\-(?i)[a-z0-9]{16}`, true), Regex: generateUniqueTokenRegex(`xkeysib-[a-f0-9]{64}\-(?i)[a-z0-9]{16}`),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"xkeysib-", "xkeysib-",
}, },
+3 -3
View File
@@ -9,9 +9,9 @@ func SentryAccessToken() *config.Rule {
// define rule // define rule
r := config.Rule{ r := config.Rule{
RuleID: "sentry-access-token", RuleID: "sentry-access-token",
Description: "Found a Sentry Access Token, risking unauthorized access to error tracking services and sensitive application data.", Description: "Sentry Access Token",
Regex: generateSemiGenericRegex([]string{"sentry"}, hex("64"), true), Regex: generateSemiGenericRegex([]string{"sentry"}, hex("64")),
SecretGroup: 1,
Keywords: []string{ Keywords: []string{
"sentry", "sentry",
}, },
Loaded 100 of 240 files, more files were not shown because too many files have changed in this diff. Show more