mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-27 11:44:23 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed19c4e8b4 | ||
|
|
989ef19fb0 | ||
|
|
191eb43841 | ||
|
|
78f7d3f5df | ||
|
|
7098f6d958 | ||
|
|
97dbe1ef09 | ||
|
|
9e06824372 | ||
|
|
db782603f7 | ||
|
|
df126a7473 | ||
|
|
75dd70e59a | ||
|
|
8510d39ffe | ||
|
|
3698060a2b | ||
|
|
128cd22f7c | ||
|
|
1a6d2b0a7a | ||
|
|
0874ebcc3f | ||
|
|
9463ffaa5e | ||
|
|
44ad62e0b1 | ||
|
|
e93a7c0d26 | ||
|
|
4e43d11093 | ||
|
|
bd81872eee | ||
|
|
3be7faa1ff | ||
|
|
1aae66d564 | ||
|
|
6dfcf5e949 | ||
|
|
f361c5ef71 | ||
|
|
8a1ca9ecc9 | ||
|
|
525c4b4451 | ||
|
|
c0fda4358e | ||
|
|
d3c4b9078e | ||
|
|
b4009bfba4 | ||
|
|
80bd1779e3 | ||
|
|
0334ec1076 | ||
|
|
c1345e1b2b | ||
|
|
7697b3e989 | ||
|
|
26f34692fa | ||
|
|
bc979deb0f | ||
|
|
b899915813 | ||
|
|
4c5195b700 |
No files matched your search
@@ -765,4 +765,5 @@ acce01f2338434a78f6a4a06a097b0fd23280484:README.md:aws-access-token:220
|
||||
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
|
||||
f361c5ef71853923277e3f284890083bc7825205:detect/reader_test.go:aws-access-token:12
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
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.
|
||||
|
||||
```
|
||||
➜ ~/code(master) gitleaks detect --source . -v
|
||||
➜ ~/code(master) gitleaks git -v
|
||||
|
||||
○
|
||||
│╲
|
||||
@@ -64,13 +64,13 @@ brew install gitleaks
|
||||
|
||||
# Docker (DockerHub)
|
||||
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] [OPTIONS] [SOURCE_PATH]
|
||||
|
||||
# Docker (ghcr.io)
|
||||
docker pull ghcr.io/gitleaks/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 ghcr.io/gitleaks/gitleaks:latest [COMMAND] [OPTIONS] [SOURCE_PATH]
|
||||
|
||||
# From Source
|
||||
# From Source (make sure `go` is installed)
|
||||
git clone https://github.com/gitleaks/gitleaks.git
|
||||
cd gitleaks
|
||||
make build
|
||||
@@ -105,7 +105,7 @@ jobs:
|
||||
```
|
||||
repos:
|
||||
- repo: https://github.com/gitleaks/gitleaks
|
||||
rev: v8.16.1
|
||||
rev: v8.19.0
|
||||
hooks:
|
||||
- id: gitleaks
|
||||
```
|
||||
@@ -137,63 +137,59 @@ Usage:
|
||||
|
||||
Available Commands:
|
||||
completion generate the autocompletion script for the specified shell
|
||||
detect detect secrets in code
|
||||
dir scan directories or files for secrets
|
||||
git scan git repositories for secrets
|
||||
help Help about any command
|
||||
protect protect secrets in code
|
||||
stdin detect secrets from stdin
|
||||
version display gitleaks version
|
||||
|
||||
Flags:
|
||||
-b, --baseline-path string path to baseline with issues that can be ignored
|
||||
-c, --config string config file path
|
||||
order of precedence:
|
||||
1. --config/-c
|
||||
2. env var GITLEAKS_CONFIG
|
||||
3. (--source/-s)/.gitleaks.toml
|
||||
If none of the three options are used, then gitleaks will use the default config
|
||||
--exit-code int exit code when leaks have been encountered (default 1)
|
||||
-h, --help help for gitleaks
|
||||
-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
|
||||
--no-color turn off color for verbose output
|
||||
--no-banner suppress banner
|
||||
--redact redact secrets from logs and stdout
|
||||
-f, --report-format string output format (json, csv, junit, sarif) (default "json")
|
||||
-r, --report-path string report file
|
||||
-s, --source string path to source (default ".")
|
||||
-v, --verbose show verbose output from scan
|
||||
-b, --baseline-path string path to baseline with issues that can be ignored
|
||||
-c, --config string config file path
|
||||
order of precedence:
|
||||
1. --config/-c
|
||||
2. env var GITLEAKS_CONFIG
|
||||
3. (target path)/.gitleaks.toml
|
||||
If none of the three options are used, then gitleaks will use the default config
|
||||
--enable-rule strings only enable specific rules by id
|
||||
--exit-code int exit code when leaks have been encountered (default 1)
|
||||
-i, --gitleaks-ignore-path string path to .gitleaksignore file or folder containing one (default ".")
|
||||
-h, --help help for gitleaks
|
||||
--ignore-gitleaks-allow ignore gitleaks:allow comments
|
||||
-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
|
||||
--no-banner suppress banner
|
||||
--no-color turn off color for verbose output
|
||||
--redact uint[=100] redact secrets from logs and stdout. To redact only parts of the secret just apply a percent value from 0..100. For example --redact=20 (default 100%)
|
||||
-f, --report-format string output format (json, csv, junit, sarif) (default "json")
|
||||
-r, --report-path string report file
|
||||
-v, --verbose show verbose output from scan
|
||||
--version version for gitleaks
|
||||
|
||||
Use "gitleaks [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
### Commands
|
||||
|
||||
There are two commands you will use to detect secrets; `detect` and `protect`.
|
||||
⚠️ v8.19.0 introduced a change that deprecated `detect` and `protect`. Those commands are still available but
|
||||
are hidden in the `--help` menu. Take a look at this [gist](https://gist.github.com/zricethezav/b325bb93ebf41b9c0b0507acf12810d2) for easy command translations.
|
||||
If you find v8.19.0 broke an existing command (`detect`/`protect`), please open an issue.
|
||||
|
||||
#### Detect
|
||||
There are three scanning modes: `git`, `dir`, and `stdin`.
|
||||
|
||||
The `detect` command is used to scan repos, directories, and files. This command can be used on developer machines and in CI environments.
|
||||
#### Git
|
||||
The `git` command lets you scan local git repos. Under the hood, gitleaks uses the `git log -p` command to scan patches.
|
||||
You can configure the behavior of `git log -p` with the `log-opts` option.
|
||||
For example, if you wanted to run gitleaks on a range of commits you could use the following
|
||||
command: `gitleaks git -v --log-opts="--all commitA..commitB" path_to_repo`. See the [git log](https://git-scm.com/docs/git-log) documentation for more information.
|
||||
If there is no target specified as a positional argument, then gitleaks will attempt to scan the current working directory as a git repo.
|
||||
|
||||
When running `detect` on a git repository, gitleaks will parse the output of a `git log -p` command (you can see how this executed
|
||||
[here](https://github.com/zricethezav/gitleaks/blob/7240e16769b92d2a1b137c17d6bf9d55a8562899/git/git.go#L17-L25)).
|
||||
[`git log -p` generates patches](https://git-scm.com/docs/git-log#_generating_patch_text_with_p) which gitleaks will use to detect secrets.
|
||||
You can configure what commits `git log` will range over by using the `--log-opts` flag. `--log-opts` accepts any option for `git log -p`.
|
||||
For example, if you wanted to run gitleaks on a range of commits you could use the following command: `gitleaks detect --source . --log-opts="--all commitA..commitB"`.
|
||||
See the `git log` [documentation](https://git-scm.com/docs/git-log) for more information.
|
||||
#### Dir
|
||||
The `dir` (aliases include `files`, `directory`) command lets you scan directories and files. Example: `gitleaks dir -v path_to_directory_or_file`.
|
||||
If there is no target specified as a positional argument, then gitleaks will scan the current working directory.
|
||||
|
||||
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
|
||||
|
||||
The `protect` command is used to scan 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).
|
||||
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
|
||||
`--staged` flag to check for changes in commits that have been `git add`ed. The `--staged` flag should be used when running Gitleaks
|
||||
as a pre-commit.
|
||||
|
||||
**NOTE**: the `protect` command can only be used on git repos, running `protect` on files or directories will result in an error message.
|
||||
#### Stdin
|
||||
You can also stream data to gitleaks with the `stdin` command. Example: `cat some_file | gitleaks -v stdin`
|
||||
|
||||
### Creating a baseline
|
||||
|
||||
@@ -201,65 +197,17 @@ When scanning large repositories or repositories with a long history, it can be
|
||||
gitleaks will ignore any old findings that are present in the baseline. A baseline can be any gitleaks report. To create a gitleaks report, run gitleaks with the `--report-path` parameter.
|
||||
|
||||
```
|
||||
gitleaks detect --report-path gitleaks-report.json # This will save the report in a file called gitleaks-report.json
|
||||
gitleaks git --report-path gitleaks-report.json # This will save the report in a file called gitleaks-report.json
|
||||
```
|
||||
|
||||
Once as baseline is created it can be applied when running the detect command again:
|
||||
|
||||
```
|
||||
gitleaks detect --baseline-path gitleaks-report.json --report-path findings.json
|
||||
gitleaks git --baseline-path gitleaks-report.json --report-path findings.json
|
||||
```
|
||||
|
||||
After running the detect command with the --baseline-path parameter, report output (findings.json) will only contain new issues.
|
||||
|
||||
### Verify Findings
|
||||
|
||||
You can verify a finding found by gitleaks using a `git log` command.
|
||||
Example output:
|
||||
|
||||
```
|
||||
Finding: aws_secret="AKIAIMNOJVGFDXXXE4OA"
|
||||
RuleID: aws-access-token
|
||||
Secret AKIAIMNOJVGFDXXXE4OA
|
||||
Entropy: 3.65
|
||||
File: checks_test.go
|
||||
Line: 37
|
||||
Commit: ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29
|
||||
Author: Zachary Rice
|
||||
Email: z@email.com
|
||||
Date: 2018-01-28T17:39:00Z
|
||||
Fingerprint: ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29:checks_test.go:aws-access-token:37
|
||||
```
|
||||
|
||||
We can use the following format to verify the leak:
|
||||
|
||||
```
|
||||
git log -L {StartLine,EndLine}:{File} {Commit}
|
||||
```
|
||||
|
||||
So in this example it would look like:
|
||||
|
||||
```
|
||||
git log -L 37,37:checks_test.go ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29
|
||||
```
|
||||
|
||||
Which gives us:
|
||||
|
||||
```
|
||||
commit ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29
|
||||
Author: zricethezav <thisispublicanyways@gmail.com>
|
||||
Date: Sun Jan 28 17:39:00 2018 -0500
|
||||
|
||||
[update] entropy check
|
||||
|
||||
diff --git a/checks_test.go b/checks_test.go
|
||||
--- a/checks_test.go
|
||||
+++ b/checks_test.go
|
||||
@@ -28,0 +37,1 @@
|
||||
+ "aws_secret= \"AKIAIMNOJVGFDXXXE4OA\"": true,
|
||||
|
||||
```
|
||||
|
||||
## Pre-Commit hook
|
||||
|
||||
You can run Gitleaks as a pre-commit hook by copying the example `pre-commit.py` script into
|
||||
|
||||
+51
-22
@@ -1,3 +1,21 @@
|
||||
// The `detect` and `protect` command is now deprecated. Here are some equivalent commands
|
||||
// to help guide you.
|
||||
|
||||
// OLD CMD: gitleaks detect --source={repo}
|
||||
// NEW CMD: gitleaks git {repo}
|
||||
|
||||
// OLD CMD: gitleaks protect --source={repo}
|
||||
// NEW CMD: gitleaks git --pre-commit {repo}
|
||||
|
||||
// OLD CMD: gitleaks protect --staged --source={repo}
|
||||
// NEW CMD: gitleaks git --pre-commit --staged {repo}
|
||||
|
||||
// OLD CMD: gitleaks detect --no-git --source={repo}
|
||||
// NEW CMD: gitleaks directory {directory/file}
|
||||
|
||||
// OLD CMD: gitleaks detect --no-git --pipe
|
||||
// NEW CMD: gitleaks stdin
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
@@ -15,20 +33,26 @@ func init() {
|
||||
rootCmd.AddCommand(detectCmd)
|
||||
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("follow-symlinks", false, "scan files that are symlinks to other files")
|
||||
detectCmd.Flags().StringP("source", "s", ".", "path to source")
|
||||
detectCmd.Flags().String("log-opts", "", "git log options")
|
||||
}
|
||||
|
||||
var detectCmd = &cobra.Command{
|
||||
Use: "detect",
|
||||
Short: "detect secrets in code",
|
||||
Run: runDetect,
|
||||
Use: "detect",
|
||||
Short: "detect secrets in code",
|
||||
Run: runDetect,
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
func runDetect(cmd *cobra.Command, args []string) {
|
||||
initConfig()
|
||||
var (
|
||||
findings []report.Finding
|
||||
err error
|
||||
)
|
||||
source, err := cmd.Flags().GetString("source")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("could not get source")
|
||||
}
|
||||
initConfig(source)
|
||||
|
||||
var findings []report.Finding
|
||||
|
||||
// setup config (aka, the thing that defines rules)
|
||||
cfg := Config(cmd)
|
||||
@@ -36,11 +60,6 @@ func runDetect(cmd *cobra.Command, args []string) {
|
||||
// start timer
|
||||
start := time.Now()
|
||||
|
||||
// grab source
|
||||
source, err := cmd.Flags().GetString("source")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("")
|
||||
}
|
||||
detector := Detector(cmd, cfg, source)
|
||||
|
||||
// set exit code
|
||||
@@ -58,43 +77,53 @@ func runDetect(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
fromPipe, err := cmd.Flags().GetBool("pipe")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err)
|
||||
log.Fatal().Err(err).Msg("could not call GetBool() for pipe")
|
||||
}
|
||||
|
||||
// start the detector scan
|
||||
if noGit {
|
||||
paths, err := sources.DirectoryTargets(source, detector.Sema, detector.FollowSymlinks)
|
||||
var paths <-chan sources.ScanTarget
|
||||
paths, err = sources.DirectoryTargets(source, detector.Sema, detector.FollowSymlinks)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err)
|
||||
}
|
||||
|
||||
findings, err = detector.DetectFiles(paths)
|
||||
if err != nil {
|
||||
// don't exit on error, just log it
|
||||
log.Error().Err(err).Msg("")
|
||||
log.Error().Err(err).Msg("failed scan directory")
|
||||
}
|
||||
} else if fromPipe {
|
||||
findings, err = detector.DetectReader(os.Stdin, 10)
|
||||
if err != nil {
|
||||
// log fatal to exit, no need to continue since a report
|
||||
// will not be generated when scanning from a pipe...for now
|
||||
log.Fatal().Err(err).Msg("")
|
||||
log.Fatal().Err(err).Msg("failed scan input from stdin")
|
||||
}
|
||||
} else {
|
||||
var logOpts string
|
||||
var (
|
||||
gitCmd *sources.GitCmd
|
||||
logOpts string
|
||||
)
|
||||
logOpts, err = cmd.Flags().GetString("log-opts")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("")
|
||||
log.Fatal().Err(err).Msg("could not call GetString() for log-opts")
|
||||
}
|
||||
gitCmd, err := sources.NewGitLogCmd(source, logOpts)
|
||||
gitCmd, err = sources.NewGitLogCmd(source, logOpts)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("")
|
||||
log.Fatal().Err(err).Msg("could not create Git cmd")
|
||||
}
|
||||
findings, err = detector.DetectGit(gitCmd)
|
||||
if err != nil {
|
||||
// don't exit on error, just log it
|
||||
log.Error().Err(err).Msg("")
|
||||
log.Error().Err(err).Msg("failed to scan Git repository")
|
||||
}
|
||||
}
|
||||
|
||||
// set follow symlinks flag
|
||||
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
|
||||
log.Fatal().Err(err).Msg("")
|
||||
}
|
||||
|
||||
findingSummaryAndExit(findings, cmd, cfg, exitCode, start, err)
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/report"
|
||||
"github.com/zricethezav/gitleaks/v8/sources"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(directoryCmd)
|
||||
directoryCmd.Flags().Bool("follow-symlinks", false, "scan files that are symlinks to other files")
|
||||
}
|
||||
|
||||
var directoryCmd = &cobra.Command{
|
||||
Use: "dir [flags] [path]",
|
||||
Aliases: []string{"file", "directory"},
|
||||
Short: "scan directories or files for secrets",
|
||||
Run: runDirectory,
|
||||
}
|
||||
|
||||
func runDirectory(cmd *cobra.Command, args []string) {
|
||||
// grab source
|
||||
source := "."
|
||||
if len(args) == 1 {
|
||||
source = args[0]
|
||||
if source == "" {
|
||||
source = "."
|
||||
}
|
||||
}
|
||||
initConfig(source)
|
||||
var (
|
||||
findings []report.Finding
|
||||
err error
|
||||
)
|
||||
|
||||
// setup config (aka, the thing that defines rules)
|
||||
cfg := Config(cmd)
|
||||
|
||||
// start timer
|
||||
start := time.Now()
|
||||
|
||||
detector := Detector(cmd, cfg, source)
|
||||
|
||||
// set exit code
|
||||
exitCode, err := cmd.Flags().GetInt("exit-code")
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("could not get exit code")
|
||||
}
|
||||
|
||||
var paths <-chan sources.ScanTarget
|
||||
paths, err = sources.DirectoryTargets(source, detector.Sema, detector.FollowSymlinks)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err)
|
||||
}
|
||||
|
||||
findings, err = detector.DetectFiles(paths)
|
||||
if err != nil {
|
||||
// don't exit on error, just log it
|
||||
log.Error().Err(err).Msg("failed scan directory")
|
||||
}
|
||||
|
||||
findingSummaryAndExit(findings, cmd, cfg, exitCode, start, err)
|
||||
}
|
||||
@@ -81,6 +81,7 @@ func main() {
|
||||
rules.FlutterwavePublicKey(),
|
||||
rules.FlutterwaveSecretKey(),
|
||||
rules.FlutterwaveEncKey(),
|
||||
rules.FlyIOAccessToken(),
|
||||
rules.FrameIO(),
|
||||
rules.FreshbooksAccessToken(),
|
||||
rules.GoCardless(),
|
||||
@@ -99,7 +100,8 @@ func main() {
|
||||
rules.GrafanaApiKey(),
|
||||
rules.GrafanaCloudApiToken(),
|
||||
rules.GrafanaServiceAccountToken(),
|
||||
rules.Hashicorp(),
|
||||
rules.HarnessApiKey(),
|
||||
rules.HashiCorpTerraform(),
|
||||
rules.HashicorpField(),
|
||||
rules.Heroku(),
|
||||
rules.HubSpot(),
|
||||
@@ -112,6 +114,7 @@ func main() {
|
||||
rules.JWT(),
|
||||
rules.JWTBase64(),
|
||||
rules.KrakenAccessToken(),
|
||||
rules.KubernetesSecret(),
|
||||
rules.KucoinAccessToken(),
|
||||
rules.KucoinSecretKey(),
|
||||
rules.LaunchDarklyAccessToken(),
|
||||
@@ -138,6 +141,7 @@ func main() {
|
||||
rules.NytimesAccessToken(),
|
||||
rules.OktaAccessToken(),
|
||||
rules.OpenAI(),
|
||||
rules.OpenshiftUserToken(),
|
||||
rules.PlaidAccessID(),
|
||||
rules.PlaidSecretKey(),
|
||||
rules.PlaidAccessToken(),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,13 +11,13 @@ func AdafruitAPIKey() *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.",
|
||||
RuleID: "adafruit-api-key",
|
||||
Regex: generateSemiGenericRegex([]string{"adafruit"}, alphaNumericExtendedShort("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"adafruit"}, utils.AlphaNumericExtendedShort("32"), true),
|
||||
Keywords: []string{"adafruit"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("adafruit", secrets.NewSecret(alphaNumericExtendedShort("32"))),
|
||||
utils.GenerateSampleSecret("adafruit", secrets.NewSecret(utils.AlphaNumericExtendedShort("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,15 +11,15 @@ func AdobeClientID() *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.",
|
||||
RuleID: "adobe-client-id",
|
||||
Regex: generateSemiGenericRegex([]string{"adobe"}, hex("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"adobe"}, utils.Hex("32"), true),
|
||||
Keywords: []string{"adobe"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("adobe", secrets.NewSecret(hex("32"))),
|
||||
utils.GenerateSampleSecret("adobe", secrets.NewSecret(utils.Hex("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func AdobeClientSecret() *config.Rule {
|
||||
@@ -26,13 +27,13 @@ func AdobeClientSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a potential Adobe Client Secret, which, if exposed, could allow unauthorized Adobe service access and data manipulation.",
|
||||
RuleID: "adobe-client-secret",
|
||||
Regex: generateUniqueTokenRegex(`(p8e-)(?i)[a-z0-9]{32}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`(p8e-)(?i)[a-z0-9]{32}`, true),
|
||||
Keywords: []string{"p8e-"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
"adobeClient := \"p8e-" + secrets.NewSecret(hex("32")) + "\"",
|
||||
"adobeClient := \"p8e-" + secrets.NewSecret(utils.Hex("32")) + "\"",
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
@@ -19,5 +20,5 @@ func AgeSecretKey() *config.Rule {
|
||||
tps := []string{
|
||||
`apiKey := "AGE-SECRET-KEY-1QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,13 +11,13 @@ func Airtable() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Uncovered a possible Airtable API Key, potentially compromising database access and leading to data leakage or alteration.",
|
||||
RuleID: "airtable-api-key",
|
||||
Regex: generateSemiGenericRegex([]string{"airtable"}, alphaNumeric("17"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"airtable"}, utils.AlphaNumeric("17"), true),
|
||||
Keywords: []string{"airtable"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("airtable", secrets.NewSecret(alphaNumeric("17"))),
|
||||
utils.GenerateSampleSecret("airtable", secrets.NewSecret(utils.AlphaNumeric("17"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,13 +11,13 @@ func AlgoliaApiKey() *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.",
|
||||
RuleID: "algolia-api-key",
|
||||
Regex: generateSemiGenericRegex([]string{"algolia"}, `[a-z0-9]{32}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"algolia"}, `[a-z0-9]{32}`, true),
|
||||
Keywords: []string{"algolia"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
"algolia_key := " + secrets.NewSecret(hex("32")),
|
||||
"algolia_key := " + secrets.NewSecret(utils.Hex("32")),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,15 +11,15 @@ func AlibabaAccessKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected an Alibaba Cloud AccessKey ID, posing a risk of unauthorized cloud resource access and potential data compromise.",
|
||||
RuleID: "alibaba-access-key-id",
|
||||
Regex: generateUniqueTokenRegex(`(LTAI)(?i)[a-z0-9]{20}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`(LTAI)(?i)[a-z0-9]{20}`, true),
|
||||
Keywords: []string{"LTAI"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
"alibabaKey := \"LTAI" + secrets.NewSecret(hex("20")) + "\"",
|
||||
"alibabaKey := \"LTAI" + secrets.NewSecret(utils.Hex("20")) + "\"",
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
// TODO
|
||||
@@ -27,15 +28,15 @@ func AlibabaSecretKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a potential Alibaba Cloud Secret Key, potentially allowing unauthorized operations and data access within Alibaba Cloud.",
|
||||
RuleID: "alibaba-secret-key",
|
||||
Regex: generateSemiGenericRegex([]string{"alibaba"},
|
||||
alphaNumeric("30"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"alibaba"},
|
||||
utils.AlphaNumeric("30"), true),
|
||||
|
||||
Keywords: []string{"alibaba"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("alibaba", secrets.NewSecret(alphaNumeric("30"))),
|
||||
utils.GenerateSampleSecret("alibaba", secrets.NewSecret(utils.AlphaNumeric("30"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,15 +11,15 @@ func AsanaClientID() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a potential Asana Client ID, risking unauthorized access to Asana projects and sensitive task information.",
|
||||
RuleID: "asana-client-id",
|
||||
Regex: generateSemiGenericRegex([]string{"asana"}, numeric("16"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"asana"}, utils.Numeric("16"), true),
|
||||
Keywords: []string{"asana"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("asana", secrets.NewSecret(numeric("16"))),
|
||||
utils.GenerateSampleSecret("asana", secrets.NewSecret(utils.Numeric("16"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func AsanaClientSecret() *config.Rule {
|
||||
@@ -26,14 +27,14 @@ func AsanaClientSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified an Asana Client Secret, which could lead to compromised project management integrity and unauthorized access.",
|
||||
RuleID: "asana-client-secret",
|
||||
Regex: generateSemiGenericRegex([]string{"asana"}, alphaNumeric("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"asana"}, utils.AlphaNumeric("32"), true),
|
||||
|
||||
Keywords: []string{"asana"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("asana", secrets.NewSecret(alphaNumeric("32"))),
|
||||
utils.GenerateSampleSecret("asana", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,15 +11,15 @@ func Atlassian() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected an Atlassian API token, posing a threat to project management and collaboration tool security and data confidentiality.",
|
||||
RuleID: "atlassian-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
"atlassian", "confluence", "jira"}, alphaNumeric("24"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"atlassian", "confluence", "jira"}, utils.AlphaNumeric("24"), true),
|
||||
Keywords: []string{"atlassian", "confluence", "jira"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("atlassian", secrets.NewSecret(alphaNumeric("24"))),
|
||||
generateSampleSecret("confluence", secrets.NewSecret(alphaNumeric("24"))),
|
||||
utils.GenerateSampleSecret("atlassian", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||
utils.GenerateSampleSecret("confluence", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
@@ -13,19 +14,19 @@ func Authress() *config.Rule {
|
||||
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),
|
||||
Regex: utils.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")
|
||||
service_client_id := "sc_" + utils.AlphaNumeric("10")
|
||||
access_key_id := utils.AlphaNumeric("4")
|
||||
account_id := "acc_" + utils.AlphaNumeric("10")
|
||||
signature_key := utils.AlphaNumericExtendedShort("40")
|
||||
|
||||
tps := []string{
|
||||
generateSampleSecret("authress", secrets.NewSecret(fmt.Sprintf(`%s\.%s\.%s\.%s`, service_client_id, access_key_id, account_id, signature_key))),
|
||||
utils.GenerateSampleSecret("authress", secrets.NewSecret(fmt.Sprintf(`%s\.%s\.%s\.%s`, service_client_id, access_key_id, account_id, signature_key))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
@@ -22,6 +23,6 @@ func AWS() *config.Rule {
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{generateSampleSecret("AWS", "AKIALALEMEL33243OLIB")} // gitleaks:allow
|
||||
return validate(r, tps, nil)
|
||||
tps := []string{utils.GenerateSampleSecret("AWS", "AKIALALEMEL33243OLIB")} // gitleaks:allow
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,14 +11,14 @@ func Beamer() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Beamer API token, potentially compromising content management and exposing sensitive notifications and updates.",
|
||||
RuleID: "beamer-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{"beamer"},
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"beamer"},
|
||||
`b_[a-z0-9=_\-]{44}`, true),
|
||||
Keywords: []string{"beamer"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("beamer", "b_"+secrets.NewSecret(alphaNumericExtended("44"))),
|
||||
utils.GenerateSampleSecret("beamer", "b_"+secrets.NewSecret(utils.AlphaNumericExtended("44"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,15 +11,15 @@ func BitBucketClientID() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a potential Bitbucket Client ID, risking unauthorized repository access and potential codebase exposure.",
|
||||
RuleID: "bitbucket-client-id",
|
||||
Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumeric("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"bitbucket"}, utils.AlphaNumeric("32"), true),
|
||||
Keywords: []string{"bitbucket"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("bitbucket", secrets.NewSecret(alphaNumeric("32"))),
|
||||
utils.GenerateSampleSecret("bitbucket", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func BitBucketClientSecret() *config.Rule {
|
||||
@@ -26,14 +27,14 @@ func BitBucketClientSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a potential Bitbucket Client Secret, posing a risk of compromised code repositories and unauthorized access.",
|
||||
RuleID: "bitbucket-client-secret",
|
||||
Regex: generateSemiGenericRegex([]string{"bitbucket"}, alphaNumericExtended("64"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"bitbucket"}, utils.AlphaNumericExtended("64"), true),
|
||||
|
||||
Keywords: []string{"bitbucket"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("bitbucket", secrets.NewSecret(alphaNumeric("64"))),
|
||||
utils.GenerateSampleSecret("bitbucket", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,15 +11,15 @@ func BittrexAccessKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a Bittrex Access Key, which could lead to unauthorized access to cryptocurrency trading accounts and financial loss.",
|
||||
RuleID: "bittrex-access-key",
|
||||
Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"bittrex"}, utils.AlphaNumeric("32"), true),
|
||||
Keywords: []string{"bittrex"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("bittrex", secrets.NewSecret(alphaNumeric("32"))),
|
||||
utils.GenerateSampleSecret("bittrex", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func BittrexSecretKey() *config.Rule {
|
||||
@@ -26,14 +27,14 @@ func BittrexSecretKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Bittrex Secret Key, potentially compromising cryptocurrency transactions and financial security.",
|
||||
RuleID: "bittrex-secret-key",
|
||||
Regex: generateSemiGenericRegex([]string{"bittrex"}, alphaNumeric("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"bittrex"}, utils.AlphaNumeric("32"), true),
|
||||
|
||||
Keywords: []string{"bittrex"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("bittrex", secrets.NewSecret(alphaNumeric("32"))),
|
||||
utils.GenerateSampleSecret("bittrex", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -12,13 +13,13 @@ func Clojars() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Uncovered a possible Clojars API token, risking unauthorized access to Clojure libraries and potential code manipulation.",
|
||||
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"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("clojars", "CLOJARS_"+secrets.NewSecret(alphaNumeric("60"))),
|
||||
utils.GenerateSampleSecret("clojars", "CLOJARS_"+secrets.NewSecret(utils.AlphaNumeric("60"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
@@ -28,7 +29,7 @@ func CloudflareGlobalAPIKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Cloudflare Global API Key, potentially compromising cloud application deployments and operational security.",
|
||||
RuleID: "cloudflare-global-api-key",
|
||||
Regex: generateSemiGenericRegex(identifiers, hex("37"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex(identifiers, utils.Hex("37"), true),
|
||||
|
||||
Keywords: identifiers,
|
||||
}
|
||||
@@ -37,7 +38,7 @@ func CloudflareGlobalAPIKey() *config.Rule {
|
||||
tps := global_keys
|
||||
fps := append(api_keys, origin_ca_keys...)
|
||||
|
||||
return validate(r, tps, fps)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func CloudflareAPIKey() *config.Rule {
|
||||
@@ -45,7 +46,7 @@ func CloudflareAPIKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Cloudflare API Key, potentially compromising cloud application deployments and operational security.",
|
||||
RuleID: "cloudflare-api-key",
|
||||
Regex: generateSemiGenericRegex(identifiers, alphaNumericExtendedShort("40"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex(identifiers, utils.AlphaNumericExtendedShort("40"), true),
|
||||
|
||||
Keywords: identifiers,
|
||||
}
|
||||
@@ -54,7 +55,7 @@ func CloudflareAPIKey() *config.Rule {
|
||||
tps := api_keys
|
||||
fps := append(global_keys, origin_ca_keys...)
|
||||
|
||||
return validate(r, tps, fps)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func CloudflareOriginCAKey() *config.Rule {
|
||||
@@ -63,7 +64,7 @@ func CloudflareOriginCAKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Cloudflare Origin CA Key, potentially compromising cloud application deployments and operational security.",
|
||||
RuleID: "cloudflare-origin-ca-key",
|
||||
Regex: generateUniqueTokenRegex(`v1\.0-`+hex("24")+"-"+hex("146"), false),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`v1\.0-`+utils.Hex("24")+"-"+utils.Hex("146"), false),
|
||||
|
||||
Keywords: ca_identifiers,
|
||||
}
|
||||
@@ -72,5 +73,5 @@ func CloudflareOriginCAKey() *config.Rule {
|
||||
tps := origin_ca_keys
|
||||
fps := append(global_keys, api_keys...)
|
||||
|
||||
return validate(r, tps, fps)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func CodecovAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
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.",
|
||||
Regex: generateSemiGenericRegex([]string{"codecov"}, alphaNumeric("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"codecov"}, utils.AlphaNumeric("32"), true),
|
||||
Keywords: []string{
|
||||
"codecov",
|
||||
},
|
||||
@@ -18,7 +19,7 @@ func CodecovAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("codecov", secrets.NewSecret(alphaNumeric("32"))),
|
||||
utils.GenerateSampleSecret("codecov", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,8 +11,8 @@ func CoinbaseAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "coinbase-access-token",
|
||||
Description: "Detected a Coinbase Access Token, posing a risk of unauthorized access to cryptocurrency accounts and financial transactions.",
|
||||
Regex: generateSemiGenericRegex([]string{"coinbase"},
|
||||
alphaNumericExtendedShort("64"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"coinbase"},
|
||||
utils.AlphaNumericExtendedShort("64"), true),
|
||||
Keywords: []string{
|
||||
"coinbase",
|
||||
},
|
||||
@@ -19,8 +20,8 @@ func CoinbaseAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("coinbase",
|
||||
secrets.NewSecret(alphaNumericExtendedShort("64"))),
|
||||
utils.GenerateSampleSecret("coinbase",
|
||||
secrets.NewSecret(utils.AlphaNumericExtendedShort("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
# This file has been auto-generated. Do not edit manually.
|
||||
# If you would like to contribute new rules, please use
|
||||
# If you would like to contribute new rules, please use
|
||||
# cmd/generate/config/main.go and follow the contributing guidelines
|
||||
# at https://github.com/zricethezav/gitleaks/blob/master/CONTRIBUTING.md
|
||||
|
||||
@@ -14,13 +14,15 @@ title = "gitleaks config"
|
||||
description = "global allow lists"
|
||||
paths = [
|
||||
'''gitleaks.toml''',
|
||||
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe)$''',
|
||||
'''(go.mod|go.sum)$''',
|
||||
'''(.*?)(jpg|gif|doc|docx|zip|xls|pdf|bin|svg|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe|gltf)$''',
|
||||
'''(go.mod|go.sum|go.work|go.work.sum)$''',
|
||||
'''gradle.lockfile''',
|
||||
'''verification-metadata.xml''',
|
||||
'''node_modules''',
|
||||
'''package-lock.json''',
|
||||
'''yarn.lock''',
|
||||
'''pnpm-lock.yaml''',
|
||||
'''poetry.lock''',
|
||||
'''Database.refactorlog''',
|
||||
'''vendor''',
|
||||
]
|
||||
@@ -49,7 +51,7 @@ tags = [
|
||||
regexTarget = "{{ . }}"{{ end -}}
|
||||
{{- with $rule.Allowlist.Regexes }}
|
||||
regexes = [
|
||||
{{ range $j, $regex := . }}"{{ $regex }}",{{ end }}
|
||||
{{ range $j, $regex := . }}'''{{ $regex }}''',{{ end }}
|
||||
]{{ end }}
|
||||
{{- with $rule.Allowlist.Paths }}paths = [
|
||||
{{ range $j, $path := . }}"{{ $path }}",{{ end }}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func ConfluentSecretKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "confluent-secret-key",
|
||||
Description: "Found a Confluent Secret Key, potentially risking unauthorized operations and data access within Confluent services.",
|
||||
Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("64"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"confluent"}, utils.AlphaNumeric("64"), true),
|
||||
Keywords: []string{
|
||||
"confluent",
|
||||
},
|
||||
@@ -18,9 +19,9 @@ func ConfluentSecretKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("confluent", secrets.NewSecret(alphaNumeric("64"))),
|
||||
utils.GenerateSampleSecret("confluent", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func ConfluentAccessToken() *config.Rule {
|
||||
@@ -28,7 +29,7 @@ func ConfluentAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "confluent-access-token",
|
||||
Description: "Identified a Confluent Access Token, which could compromise access to streaming data platforms and sensitive data flow.",
|
||||
Regex: generateSemiGenericRegex([]string{"confluent"}, alphaNumeric("16"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"confluent"}, utils.AlphaNumeric("16"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"confluent",
|
||||
@@ -37,7 +38,7 @@ func ConfluentAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("confluent", secrets.NewSecret(alphaNumeric("16"))),
|
||||
utils.GenerateSampleSecret("confluent", secrets.NewSecret(utils.AlphaNumeric("16"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,14 +11,14 @@ func Contentful() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a Contentful delivery API token, posing a risk to content management systems and data integrity.",
|
||||
RuleID: "contentful-delivery-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{"contentful"},
|
||||
alphaNumericExtended("43"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"contentful"},
|
||||
utils.AlphaNumericExtended("43"), true),
|
||||
Keywords: []string{"contentful"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("contentful", secrets.NewSecret(alphaNumeric("43"))),
|
||||
utils.GenerateSampleSecret("contentful", secrets.NewSecret(utils.AlphaNumeric("43"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,13 +11,13 @@ func Databricks() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Uncovered a Databricks API token, which may compromise big data analytics platforms and sensitive data processing.",
|
||||
RuleID: "databricks-api-token",
|
||||
Regex: generateUniqueTokenRegex(`dapi[a-h0-9]{32}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`dapi[a-h0-9]{32}`, true),
|
||||
Keywords: []string{"dapi"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("databricks", "dapi"+secrets.NewSecret(hex("32"))),
|
||||
utils.GenerateSampleSecret("databricks", "dapi"+secrets.NewSecret(utils.Hex("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,8 +11,8 @@ func DatadogtokenAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "datadog-access-token",
|
||||
Description: "Detected a Datadog Access Token, potentially risking monitoring and analytics data exposure and manipulation.",
|
||||
Regex: generateSemiGenericRegex([]string{"datadog"},
|
||||
alphaNumeric("40"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"datadog"},
|
||||
utils.AlphaNumeric("40"), true),
|
||||
Keywords: []string{
|
||||
"datadog",
|
||||
},
|
||||
@@ -19,7 +20,7 @@ func DatadogtokenAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("datadog", secrets.NewSecret(alphaNumeric("40"))),
|
||||
utils.GenerateSampleSecret("datadog", secrets.NewSecret(utils.AlphaNumeric("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -15,7 +16,7 @@ func DefinedNetworkingAPIToken() *config.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),
|
||||
Regex: utils.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"},
|
||||
@@ -23,7 +24,7 @@ func DefinedNetworkingAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("dnkey", "dnkey-"+secrets.NewSecret(alphaNumericExtended("26"))+"-"+secrets.NewSecret(alphaNumericExtended("52"))),
|
||||
utils.GenerateSampleSecret("dnkey", "dnkey-"+secrets.NewSecret(utils.AlphaNumericExtended("26"))+"-"+secrets.NewSecret(utils.AlphaNumericExtended("52"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -9,14 +10,14 @@ func DigitalOceanPAT() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a DigitalOcean Personal Access Token, posing a threat to cloud infrastructure security and data privacy.",
|
||||
RuleID: "digitalocean-pat",
|
||||
Regex: generateUniqueTokenRegex(`dop_v1_[a-f0-9]{64}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`dop_v1_[a-f0-9]{64}`, true),
|
||||
Keywords: []string{"dop_v1_"},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
generateSampleSecret("do", "dop_v1_"+secrets.NewSecret(hex("64"))),
|
||||
utils.GenerateSampleSecret("do", "dop_v1_"+secrets.NewSecret(utils.Hex("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func DigitalOceanOAuthToken() *config.Rule {
|
||||
@@ -24,14 +25,14 @@ func DigitalOceanOAuthToken() *config.Rule {
|
||||
Description: "Found a DigitalOcean OAuth Access Token, risking unauthorized cloud resource access and data compromise.",
|
||||
RuleID: "digitalocean-access-token",
|
||||
|
||||
Regex: generateUniqueTokenRegex(`doo_v1_[a-f0-9]{64}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`doo_v1_[a-f0-9]{64}`, true),
|
||||
Keywords: []string{"doo_v1_"},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
generateSampleSecret("do", "doo_v1_"+secrets.NewSecret(hex("64"))),
|
||||
utils.GenerateSampleSecret("do", "doo_v1_"+secrets.NewSecret(utils.Hex("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func DigitalOceanRefreshToken() *config.Rule {
|
||||
@@ -39,12 +40,12 @@ func DigitalOceanRefreshToken() *config.Rule {
|
||||
Description: "Uncovered a DigitalOcean OAuth Refresh Token, which could allow prolonged unauthorized access and resource manipulation.",
|
||||
RuleID: "digitalocean-refresh-token",
|
||||
|
||||
Regex: generateUniqueTokenRegex(`dor_v1_[a-f0-9]{64}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`dor_v1_[a-f0-9]{64}`, true),
|
||||
Keywords: []string{"dor_v1_"},
|
||||
}
|
||||
|
||||
tps := []string{
|
||||
generateSampleSecret("do", "dor_v1_"+secrets.NewSecret(hex("64"))),
|
||||
utils.GenerateSampleSecret("do", "dor_v1_"+secrets.NewSecret(utils.Hex("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,15 +11,15 @@ func DiscordAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Discord API key, potentially compromising communication channels and user data privacy on Discord.",
|
||||
RuleID: "discord-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{"discord"}, hex("64"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"discord"}, utils.Hex("64"), true),
|
||||
Keywords: []string{"discord"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("discord", secrets.NewSecret(hex("64"))),
|
||||
utils.GenerateSampleSecret("discord", secrets.NewSecret(utils.Hex("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func DiscordClientID() *config.Rule {
|
||||
@@ -26,15 +27,15 @@ func DiscordClientID() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a Discord client ID, which may lead to unauthorized integrations and data exposure in Discord applications.",
|
||||
RuleID: "discord-client-id",
|
||||
Regex: generateSemiGenericRegex([]string{"discord"}, numeric("18"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"discord"}, utils.Numeric("18"), true),
|
||||
Keywords: []string{"discord"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("discord", secrets.NewSecret(numeric("18"))),
|
||||
utils.GenerateSampleSecret("discord", secrets.NewSecret(utils.Numeric("18"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func DiscordClientSecret() *config.Rule {
|
||||
@@ -42,13 +43,13 @@ func DiscordClientSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a potential Discord client secret, risking compromised Discord bot integrations and data leaks.",
|
||||
RuleID: "discord-client-secret",
|
||||
Regex: generateSemiGenericRegex([]string{"discord"}, alphaNumericExtended("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"discord"}, utils.AlphaNumericExtended("32"), true),
|
||||
Keywords: []string{"discord"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("discord", secrets.NewSecret(numeric("32"))),
|
||||
utils.GenerateSampleSecret("discord", secrets.NewSecret(utils.Numeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -12,15 +13,15 @@ func Doppler() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a Doppler API token, posing a risk to environment and secrets management security.",
|
||||
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"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("doppler", "dp.pt."+secrets.NewSecret(alphaNumeric("43"))),
|
||||
utils.GenerateSampleSecret("doppler", "dp.pt."+secrets.NewSecret(utils.AlphaNumeric("43"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
// TODO add additional doppler formats:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func DroneciAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "droneci-access-token",
|
||||
Description: "Detected a Droneci Access Token, potentially compromising continuous integration and deployment workflows.",
|
||||
Regex: generateSemiGenericRegex([]string{"droneci"}, alphaNumeric("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"droneci"}, utils.AlphaNumeric("32"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"droneci",
|
||||
@@ -19,7 +20,7 @@ func DroneciAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("droneci", secrets.NewSecret(alphaNumeric("32"))),
|
||||
utils.GenerateSampleSecret("droneci", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,16 +11,16 @@ func DropBoxAPISecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a Dropbox API secret, which could lead to unauthorized file access and data breaches in Dropbox storage.",
|
||||
RuleID: "dropbox-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{"dropbox"}, alphaNumeric("15"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"dropbox"}, utils.AlphaNumeric("15"), true),
|
||||
|
||||
Keywords: []string{"dropbox"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("dropbox", secrets.NewSecret(alphaNumeric("15"))),
|
||||
utils.GenerateSampleSecret("dropbox", secrets.NewSecret(utils.AlphaNumeric("15"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func DropBoxShortLivedAPIToken() *config.Rule {
|
||||
@@ -27,7 +28,7 @@ func DropBoxShortLivedAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
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.",
|
||||
Regex: generateSemiGenericRegex([]string{"dropbox"}, `sl\.[a-z0-9\-=_]{135}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"dropbox"}, `sl\.[a-z0-9\-=_]{135}`, true),
|
||||
Keywords: []string{"dropbox"},
|
||||
}
|
||||
|
||||
@@ -40,7 +41,7 @@ func DropBoxLongLivedAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "dropbox-long-lived-api-token",
|
||||
Description: "Found a Dropbox long-lived API token, risking prolonged unauthorized access to cloud storage and sensitive data.",
|
||||
Regex: generateSemiGenericRegex([]string{"dropbox"}, `[a-z0-9]{11}(AAAAAAAAAA)[a-z0-9\-_=]{43}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"dropbox"}, `[a-z0-9]{11}(AAAAAAAAAA)[a-z0-9\-_=]{43}`, true),
|
||||
Keywords: []string{"dropbox"},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -12,13 +13,13 @@ func Duffel() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "duffel-api-token",
|
||||
Description: "Uncovered a Duffel API token, which may compromise travel platform integrations and sensitive customer data.",
|
||||
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"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("duffel", "duffel_test_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
||||
utils.GenerateSampleSecret("duffel", "duffel_test_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -18,7 +19,7 @@ func Dynatrace() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("dynatrace", "dt0c01."+secrets.NewSecret(alphaNumeric("24"))+"."+secrets.NewSecret(alphaNumeric("64"))),
|
||||
utils.GenerateSampleSecret("dynatrace", "dt0c01."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -18,9 +19,9 @@ func EasyPost() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("EZAK", "EZAK"+secrets.NewSecret(alphaNumeric("54"))),
|
||||
utils.GenerateSampleSecret("EZAK", "EZAK"+secrets.NewSecret(utils.AlphaNumeric("54"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func EasyPostTestAPI() *config.Rule {
|
||||
@@ -34,7 +35,7 @@ func EasyPostTestAPI() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("EZTK", "EZTK"+secrets.NewSecret(alphaNumeric("54"))),
|
||||
utils.GenerateSampleSecret("EZTK", "EZTK"+secrets.NewSecret(utils.AlphaNumeric("54"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,8 +12,8 @@ func EtsyAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "etsy-access-token",
|
||||
Description: "Found an Etsy Access Token, potentially compromising Etsy shop management and customer data.",
|
||||
Regex: generateSemiGenericRegex([]string{"etsy"}, alphaNumeric("24"), true),
|
||||
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"(?-i:ETSY|[Ee]tsy)"}, utils.AlphaNumeric("24"), true),
|
||||
Entropy: 3,
|
||||
Keywords: []string{
|
||||
"etsy",
|
||||
},
|
||||
@@ -19,7 +21,15 @@ func EtsyAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("etsy", secrets.NewSecret(alphaNumeric("24"))),
|
||||
utils.GenerateSampleSecret("ETSY", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||
utils.GenerateSampleSecret("etsy", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||
utils.GenerateSampleSecret("Etsy", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
fps := []string{
|
||||
fmt.Sprintf(`SetSysctl = "%s"`, secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||
` if err := sysctl.SetSysctl(sysctlBridgeCallIPTables); err != nil {`,
|
||||
`g6Rib2R5hqhkZXRhY2hlZMOpaGFzaF90eXBlCqNrZXnEIwEgETSYcPQGcaAxl8vuQDLahSfhxkEEHu2flbF9ErAooEoKp3BheWxvYWTFAwB7ImJvZHkiOnsia2V5Ijp7ImVsZGVzdF9raWQiOiIwMTIwMTEzNDk4NzBmNDA2NzFhMDMxOTdjYmVlNDAzMmRhODUyN2UxYzY0MTA0MWVlZDlmOTViMTdkMTJiMDI4YTA0YTBhIiwiaG9zdCI6ImtleWJhc2UuaW8iLCJraWQiOiIwMTIwMTEzNDk4NzBmNDA2NzFhMDMxOTdjYmVlNDAzMmRhODUyN2UxYzY0MTA0MWVlZDlmOTViMTdkMTJiMDI4YTA0YTBhIiwidWlkIjoiYzUyZjc2M2MxNzYyNWZiMTI5YWU1ZDZmZThhMGUzMTkiLCJ1c2VybmFtZSI6ImttYXJla3NwYXJ0eiJ9LCJzZXJ2aWNlIjp7Imhvc3RuYW1lIjoia3lsZS5tYXJlay1zcGFydHoub3JnIiwicHJvdG9jb2wiOiJodHRwOiJ9LCJ0eXBlIjoid2ViX3NlcnZpY2VfYmluZGluZyIsInZlcnNpb24iOjF9LCJjbGllbnQiOnsibmFtZSI6ImtleWJhc2UuaW8gZ28gY2xpZW50IiwidmVyc2lvbiI6IjEuMC4xNCJ9LCJjdGltZSI6MTQ1ODU5MDYyMSwiZXhwaXJlX2luIjo1MDQ1NzYwMDAsIm1lcmtsZV9yb290Ijp7ImN0aW1lIjoxNDU4NTkwNTgzLCJoYXNoIjoiODQ0ZWRkNGU0OTQ3MWUzNWQxZTFkOTM5YTc0ZjUwMDc5Nzg3NzljMTAwYzY1NGE2OGI1NDNhYzY2Y2NlYTQ1MGFjNTllNmY3Yjc4ZGZiN2MyYzdjMmYwMzJiYTA2MzdjMzVjZDk1ZGYyZmRiNjFlNjgxMjVmNDkxNjVlZDkwNzMiLCJzZXFubyI6NDE3Mjk5fSwicHJldiI6IjdmNWFkMGZlZmQxNjM4ZjBlOTc1MTk3NzA5YTk2OTVkZmQ1NzU0MTA4NTYxZGUzMDM0ODc2NDcxODdhMDkyYzUiLCJzZXFubyI6OSwidGFnIjoic2lnbmF0dXJlIn2jc2lnxEDDVCB/SdOzo+BznIUCCa5DgISbH+0noUjyAJ4r0sH/tj8lYNpHw3WR93SBCufeElsl7KrxVdg5qU5ADYj26wgOqHNpZ190eXBlIKN0YWfNAgKndmVyc2lvbgE=`,
|
||||
`in XCBuild.XCBBuildServiceSession.setSystemInfo(operatingSystemVersion: __C.NSOperatingSystemVersion, productBuildVersion: Swift.String, nativeArchitecture: Swift.String, completion: (Swift.Bool) -> ()) -> ()`,
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -12,18 +13,18 @@ func FacebookSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a Facebook Application secret, posing a risk of unauthorized access to Facebook accounts and personal data exposure.",
|
||||
RuleID: "facebook-secret",
|
||||
Regex: generateSemiGenericRegex([]string{"facebook"}, hex("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"facebook"}, utils.Hex("32"), true),
|
||||
|
||||
Keywords: []string{"facebook"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("facebook", secrets.NewSecret(hex("32"))),
|
||||
utils.GenerateSampleSecret("facebook", secrets.NewSecret(utils.Hex("32"))),
|
||||
`facebook_app_secret = "6dca6432e45d933e13650d1882bd5e69"`, // gitleaks:allow
|
||||
`facebook_client_access_token: 26f5fd13099f2c1331aafb86f6489692`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
// https://developers.facebook.com/docs/facebook-login/guides/access-tokens/#apptokens
|
||||
@@ -32,7 +33,7 @@ func FacebookAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a Facebook Access Token, posing a risk of unauthorized access to Facebook accounts and personal data exposure.",
|
||||
RuleID: "facebook-access-token",
|
||||
Regex: generateUniqueTokenRegex(`\d{15,16}(\||%)[0-9a-z\-_]{27,40}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`\d{15,16}(\||%)[0-9a-z\-_]{27,40}`, true),
|
||||
}
|
||||
|
||||
// validate
|
||||
@@ -41,7 +42,7 @@ func FacebookAccessToken() *config.Rule {
|
||||
`1308742762612587|rhoK1cbv0DOU_RTX_87O4MkX7AI`, // gitleaks:allow
|
||||
`1477036645700765|wRPf2v3mt2JfMqCLK8n7oltrEmc`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
// https://developers.facebook.com/docs/facebook-login/guides/access-tokens/#pagetokens
|
||||
@@ -50,7 +51,7 @@ func FacebookPageAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a Facebook Page Access Token, posing a risk of unauthorized access to Facebook accounts and personal data exposure.",
|
||||
RuleID: "facebook-page-access-token",
|
||||
Regex: generateUniqueTokenRegex("EAA[MC]"+alphaNumeric("20,"), true),
|
||||
Regex: utils.GenerateUniqueTokenRegex("EAA[MC]"+utils.AlphaNumeric("20,"), true),
|
||||
Keywords: []string{"EAAM", "EAAC"},
|
||||
}
|
||||
|
||||
@@ -61,5 +62,5 @@ func FacebookPageAccessToken() *config.Rule {
|
||||
`- name: FACEBOOK_TOKEN
|
||||
value: "EAACEdEose0cBA1bad3afsf2aew"`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,14 +11,14 @@ func FastlyAPIToken() *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.",
|
||||
RuleID: "fastly-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{"fastly"}, alphaNumericExtended("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"fastly"}, utils.AlphaNumericExtended("32"), true),
|
||||
|
||||
Keywords: []string{"fastly"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("fastly", secrets.NewSecret(alphaNumericExtended("32"))),
|
||||
utils.GenerateSampleSecret("fastly", secrets.NewSecret(utils.AlphaNumericExtended("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,16 +11,16 @@ func FinicityClientSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a Finicity Client Secret, which could lead to compromised financial service integrations and data breaches.",
|
||||
RuleID: "finicity-client-secret",
|
||||
Regex: generateSemiGenericRegex([]string{"finicity"}, alphaNumeric("20"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"finicity"}, utils.AlphaNumeric("20"), true),
|
||||
|
||||
Keywords: []string{"finicity"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("finicity", secrets.NewSecret(alphaNumeric("20"))),
|
||||
utils.GenerateSampleSecret("finicity", secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func FinicityAPIToken() *config.Rule {
|
||||
@@ -27,14 +28,14 @@ func FinicityAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Finicity API token, potentially risking financial data access and unauthorized financial operations.",
|
||||
RuleID: "finicity-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{"finicity"}, hex("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"finicity"}, utils.Hex("32"), true),
|
||||
|
||||
Keywords: []string{"finicity"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("finicity", secrets.NewSecret(hex("32"))),
|
||||
utils.GenerateSampleSecret("finicity", secrets.NewSecret(utils.Hex("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func FinnhubAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "finnhub-access-token",
|
||||
Description: "Found a Finnhub Access Token, risking unauthorized access to financial market data and analytics.",
|
||||
Regex: generateSemiGenericRegex([]string{"finnhub"}, alphaNumeric("20"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"finnhub"}, utils.AlphaNumeric("20"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"finnhub",
|
||||
@@ -19,7 +20,7 @@ func FinnhubAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("finnhub", secrets.NewSecret(alphaNumeric("20"))),
|
||||
utils.GenerateSampleSecret("finnhub", secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func FlickrAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "flickr-access-token",
|
||||
Description: "Discovered a Flickr Access Token, posing a risk of unauthorized photo management and potential data leakage.",
|
||||
Regex: generateSemiGenericRegex([]string{"flickr"}, alphaNumeric("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"flickr"}, utils.AlphaNumeric("32"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"flickr",
|
||||
@@ -19,7 +20,7 @@ func FlickrAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("flickr", secrets.NewSecret(alphaNumeric("32"))),
|
||||
utils.GenerateSampleSecret("flickr", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -18,9 +19,9 @@ func FlutterwavePublicKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("flutterwavePubKey", "FLWPUBK_TEST-"+secrets.NewSecret(hex("32"))+"-X"),
|
||||
utils.GenerateSampleSecret("flutterwavePubKey", "FLWPUBK_TEST-"+secrets.NewSecret(utils.Hex("32"))+"-X"),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func FlutterwaveSecretKey() *config.Rule {
|
||||
@@ -34,9 +35,9 @@ func FlutterwaveSecretKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(hex("32"))+"-X"),
|
||||
utils.GenerateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(utils.Hex("32"))+"-X"),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func FlutterwaveEncKey() *config.Rule {
|
||||
@@ -50,7 +51,7 @@ func FlutterwaveEncKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(hex("12"))),
|
||||
utils.GenerateSampleSecret("flutterwavePubKey", "FLWSECK_TEST-"+secrets.NewSecret(utils.Hex("12"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
// https://fly.io/docs/security/tokens/
|
||||
// https://github.com/trufflesecurity/trufflehog/pull/2381/files#r1565860579
|
||||
// https://github.com/superfly/macaroon-elixir/blob/8b42043b0a24aada5c8b8eb8505dbf1590557f1b/test/vectors.json#L7
|
||||
func FlyIOAccessToken() *config.Rule {
|
||||
// define rule
|
||||
r := config.Rule{
|
||||
RuleID: "flyio-access-token",
|
||||
Description: "Uncovered a Fly.io API key", // TODO
|
||||
Regex: utils.GenerateUniqueTokenRegex(`(?:fo1_[\w-]{43}|fm1[ar]_[a-zA-Z0-9+\/]{100,}={0,3}|fm2_[a-zA-Z0-9+\/]{100,}={0,3})`, false),
|
||||
Entropy: 4,
|
||||
Keywords: []string{"fo1_", "fm1", "fm2_"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
// fo1_
|
||||
utils.GenerateSampleSecret("fly", secrets.NewSecret(`fo1_[\w-]{43}`)),
|
||||
`Fly access token: fo1_8rz-j7r2eqJ2U7affEOO3HJN0j63DInyog3eV-glQSc
|
||||
`,
|
||||
`=============================================================================================================
|
||||
|
||||
fo1_BtKlzvfztw0M2hlLgTdsfPgDFiwM2jJjQXXy6I2pjuQ
|
||||
fly deploy`,
|
||||
// fm1
|
||||
utils.GenerateSampleSecret("fly", secrets.NewSecret(`fm1[ar]_[a-zA-Z0-9+\/]{100,}={0,3}`)),
|
||||
`ENV FLY_API_TOKEN="FlyV1 fm1r_lJPECAAAAAAAAMqcxBBLMJKXYKJiT0CI58XmukX/wrVodHlwczovL2FwaS5mbHkuaW8vdjGWAJLOAAFmXh8Lk7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxxDy5OfA2M6K6aLEoEDKxehojbj+8ZT9IrXCF5sL/r8m6/1gylwySsNxpD40wnpd/G2ZdjwVaQev1kEuFUgzERxPbtWHDNa+NYIZwbKN6b7/JxdbUprq0M10HI4fwtlxhqhdA/mMaMw70EC4TsfJyghIL98KP4ry5AaXiroRdjrSsFExc/xRCDZKUA5GBzgATuNsfBZGCp2J1aWxkZXIfondnHwHEIMa6NWc4b52S+UY7vjPdwKrz00Uzrc1830mOHzQNLun7,fm1a_lJPERxPbtWHDNa+NYIZwbKN6b7/JxdbUprq0M10HI4fwtlxhqhdA/mMaMw70EC4TsfJyghIL98KP4ry4AaXiroRdjrSsFExc/xRCxBCVlAoRzKV/+qYkxuipIbIcw7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxlgSSzmS4Y7nPAAAAASCwgdcKkc4AAUktDMQQURck2h+upbiOrW66Nf5SA8QgrD03xlWju1WQi0AUhlk7YYFzOLDfhRyJ6nEziO37NUE="`,
|
||||
// fm2
|
||||
utils.GenerateSampleSecret("fly", secrets.NewSecret(`fm2_[a-zA-Z0-9+\/]{100,}={0,3}`)),
|
||||
`# FLY_API_TOKEN: FlyV1 fm2_lJPECAAAAAAAAyZtxBD1hSZ7L5leXsj64ZbDlkm/wrVodHRwczovL2FwaS5mbHkuaW8vdjGWAJLOAAwMDB8Lk7lodHRwczovL2FwaS5mbHkuaW8vYWFhL3YxxDwDnhgJj/ML/nRKMiAYgnvXfNacrGWffj5TdfgGY2LU0ZetT7WzTLQQMO8cN2nRTztl/xLjnnZg5pBwFonETmhNA6Yl0X1tatt8ezA0UjVQiJr93VQ7qAmD5GG2Ce5txhbQv3tmIGsvaC7BOkIqAiR273bhZkO44AYsrCPr2XF8W6Twk7NyU+3UUeDwjw2SlAORgc4APu7vHwWRgqdidWlsZGVyH6J3Zx8BxCAlmLbu1HQDg8ZAGKKmEt4Mbnbqli6lbzBDHsawhcUF4A==,fm2_lJPETmhNA6Yl0X1tatt8ezA0UjVQiJr93VQ7qAmD5GG2Ce5txhbQv3tmIGsvaC7BOkIqAij273bhZkO44AYsrCPr2XF8W6Twk7NyU+3UUeDwj8QQbn07DOV+7SmoLj/uT+dbr8O5aHR0cHM6Ly9hcGkuZmx5LmlvL2FhYS92MZgEks5mqfbvzwAAAAE9PYz9F84AC7QACpHOAAu0AAzEEFfW3B+SzffV/KrAYa8qqpnEIIlD6DqZMZQ9Kt7fEenCCOLA+tUSJ+kmEFIUcc83npOI`,
|
||||
`"BindToParentToken": "FlyV1 fm2_lJPEEKnzKy0lkwV3B+WIlmrdwejEEFv5qmevHU4fMs+2Gr6oOiPC2SAyOTc0NWI4ZmJlNjBlNjJmZTgzNTkxOThhZWE4MjY0M5IMxAMBAgPEIH7VG8u74KwO62hmx8SZO8WaU5o1g3W2IVc7QN6T1VTr",`,
|
||||
}
|
||||
fps := []string{
|
||||
// fo1_
|
||||
`resource "doppler_integration_flyio" "prod" {
|
||||
name = "TF Fly.io"
|
||||
api_key = "fo1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
}`, // https://github.com/DopplerHQ/terraform-provider-doppler/blob/a012e1a7903cce391be511b391850b29ebfdeb68/docs/resources/integration_flyio.md?plain=1#L17
|
||||
`pub const MINIDUMP_SYSMEMINFO1_PERF_CCTOTALDIRTYPAGES_CCDIRTYPAGETHRESHOLD: u32 = 4u32;`, // https://github.com/microsoft/windows-rs/blob/0f7466c34e774e547d21c579b58b60168c4ee6bc/crates/libs/sys/src/Windows/Win32/System/Diagnostics/Debug/mod.rs#L1258
|
||||
`<input type="hidden" name="authenticity_token" value="7SWa-Fo1_hsC6oovfBsJFLGPUl2EhkSWPbJhWANwgaJWBDl1vxd9VNqXTNAefsJqzIRYaZEfYZLffa31rw8zJA" autocomplete="off" />`,
|
||||
// fm1
|
||||
`signature":"I7l2ZXhw9ajjIE2w9tjHNvYjcHg7E2qldMMhoQKjborcWIj8c40rMj83venoy6gXsg6V6B7dlBWxUmzYJR3lJKGECtCSM5BqBvWhL6wX2CN2lZlvwNCyPjG4PCt5MAK1yV1Xv4fqfz8EfT_U49vOzfM1a_nfhXOzrvdg9XgLkAotWBI31vPKjMBrvPqiLcZ12MDNTSK7ubRpVaehSNxiGYHpLhWTkun9qm_APYYXJBjhJYkej50Qcp7Ou8fs3kH02prYIJt4JbWelr5vUDkgMH3AwEx1eYu5NI_8sESlqosl1nhSDx7zq3X1FV1iJlAYCNwGWzW1tjo8PCaJrIHVZZnhBPMN-6ahmOpKb8GViqd4fCQuNe4VUSOeJg8i97kMuk-4r7hwIubR0XfCGzxr7uGDQBdFANi3c4dLlzBAJNifa6b_hT4Xzqja6RCFSv6Cnalyx3hbSkjbyThnXFavJIiR7cvgTcdECg9VxkaxqqRhfAkLAS3hpXQAIYL_bw61M3LN37WHwdgxN_6yZhbSbOsYPmTxiWvdlDaCP_iaCgXgJNfdQ6kep_I89slynE9gdDZ6NSjFJH2Soml4pR6HnQKPjA3OpoTwPSmZjxXY5I78xvrRqRkjdnVzeufqG8LyA-sAEtC0G_312JOxV4GZINquPGk1qFx8WN59Rxw28Tg",`,
|
||||
// fm2
|
||||
`<p><span class="emoji">🗣️</span> Adobe illustrator软件基础精讲课程<br><br><span class="emoji">🏷️</span> <a href="https://t.me/abskoop/8565?q=%23%E8%AE%BE%E8%AE%A1%E5%B8%88">#设计师</a> <a href="https://t.me/abskoop/8565?q=%23%E8%B5%84%E6%BA%90">#资源</a> <a href="https://t.me/abskoop/8565?q=%23%E5%A4%B8%E5%85%8B%E7%BD%91%E7%9B%98">#夸克网盘</a><br><br><span class="emoji">👉</span> <a href="https://www.ahhhhfs.com/62409/" target="_blank" rel="noopener">https://www.ahhhhfs.com/62409/</a></p><img src="https://cdn5.cdn-telegram.org/file/uGoDMy0VXMbL1nki9OT0VbJYtfURvDNLurptsQVuhuzF45tNfm2_z5wgR7CnL7lTZ4bbotjXZtiLWvolNQqWBRFWkcidtzSyhWvta9yPB3E2uyvfJvGpditkaLVIiCCXt9BhFBEdgkXa8ODaM7geHK3pW0tmO_IViHBnG8VZqVfDpaQW0W9IRAUwGv2mPZWVRysPJyDSIuY9b-_3ElUml-Xlpm1r8EDcm9Q2WCTCOYur7Gmef4imQ5D-DLTviqmoONgQDLA10WVS3CApXBK4ADSjoIUeMck62owtjElSXnEYMaSGI_OE3B21QplsspPbPlXVUBScLfLOFb9tn-34tw.jpg" width="800" height="533" referrerpolicy="no-referrer">`,
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -18,7 +19,7 @@ func FrameIO() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("frameio", "fio-u-"+secrets.NewSecret(alphaNumericExtended("64"))),
|
||||
utils.GenerateSampleSecret("frameio", "fio-u-"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func FreshbooksAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "freshbooks-access-token",
|
||||
Description: "Discovered a Freshbooks Access Token, posing a risk to accounting software access and sensitive financial data exposure.",
|
||||
Regex: generateSemiGenericRegex([]string{"freshbooks"}, alphaNumeric("64"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"freshbooks"}, utils.AlphaNumeric("64"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"freshbooks",
|
||||
@@ -19,7 +20,7 @@ func FreshbooksAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("freshbooks", secrets.NewSecret(alphaNumeric("64"))),
|
||||
utils.GenerateSampleSecret("freshbooks", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -21,7 +22,7 @@ func GCPServiceAccount() *config.Rule {
|
||||
tps := []string{
|
||||
`"type": "service_account"`,
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GCPAPIKey() *config.Rule {
|
||||
@@ -29,8 +30,8 @@ func GCPAPIKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "gcp-api-key",
|
||||
Description: "Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.",
|
||||
Regex: generateUniqueTokenRegex(`AIza[0-9A-Za-z\\-_]{35}`, true),
|
||||
|
||||
Regex: utils.GenerateUniqueTokenRegex(`AIza[\w-]{35}`, false),
|
||||
Entropy: 3.0,
|
||||
Keywords: []string{
|
||||
"AIza",
|
||||
},
|
||||
@@ -38,7 +39,15 @@ func GCPAPIKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("gcp", secrets.NewSecret(`AIza[0-9A-Za-z\\-_]{35}`)),
|
||||
utils.GenerateSampleSecret("gcp", secrets.NewSecret(`AIza[\w-]{35}`)),
|
||||
// non-word character at end
|
||||
`AIzaSyNHxIf32IQ1a1yjl3ZJIqKZqzLAK1XhDk-`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
fps := []string{
|
||||
`GWw4hjABFzZCGiRpmlDyDdo87Jn9BN9THUA47muVRNunLxsa82tMAdvmrhOqNkRKiYMEAFbTJAIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDq`, // text boundary start
|
||||
`AIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDqabcd123`, // text boundary end
|
||||
`apiKey: "AIzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"`, // not enough entropy
|
||||
`AIZASYCO2CXRMC9ELSKLHLHRMBSWDEVEDZTLO2O`, // incorrect case
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
@@ -9,7 +10,7 @@ func GenericCredential() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "generic-api-key",
|
||||
Description: "Detected a Generic API Key, potentially exposing access to various services and sensitive operations.",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"key",
|
||||
"api",
|
||||
"token",
|
||||
@@ -39,8 +40,8 @@ func GenericCredential() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443"),
|
||||
generateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"),
|
||||
utils.GenerateSampleSecret("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443"), //gitleaks:allow
|
||||
utils.GenerateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"),
|
||||
`"client_id" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`,
|
||||
`"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",`,
|
||||
}
|
||||
@@ -50,5 +51,5 @@ func GenericCredential() *config.Rule {
|
||||
|
||||
R5: Regulatory--21`,
|
||||
}
|
||||
return validate(r, tps, fps)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -13,14 +14,18 @@ func GitHubPat() *config.Rule {
|
||||
Description: "Uncovered a GitHub Personal Access Token, potentially leading to unauthorized repository access and sensitive content exposure.",
|
||||
RuleID: "github-pat",
|
||||
Regex: regexp.MustCompile(`ghp_[0-9a-zA-Z]{36}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"ghp_"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("github", "ghp_"+secrets.NewSecret(alphaNumeric("36"))),
|
||||
utils.GenerateSampleSecret("github", "ghp_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
fps := []string{
|
||||
"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func GitHubFineGrainedPat() *config.Rule {
|
||||
@@ -28,15 +33,19 @@ func GitHubFineGrainedPat() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Found a GitHub Fine-Grained Personal Access Token, risking unauthorized repository access and code manipulation.",
|
||||
RuleID: "github-fine-grained-pat",
|
||||
Regex: regexp.MustCompile(`github_pat_[0-9a-zA-Z_]{82}`),
|
||||
Regex: regexp.MustCompile(`github_pat_\w{82}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"github_pat_"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("github", "github_pat_"+secrets.NewSecret(alphaNumeric("82"))),
|
||||
utils.GenerateSampleSecret("github", "github_pat_"+secrets.NewSecret(utils.AlphaNumeric("82"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
fps := []string{
|
||||
"github_pat_xxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func GitHubOauth() *config.Rule {
|
||||
@@ -45,14 +54,18 @@ func GitHubOauth() *config.Rule {
|
||||
Description: "Discovered a GitHub OAuth Access Token, posing a risk of compromised GitHub account integrations and data leaks.",
|
||||
RuleID: "github-oauth",
|
||||
Regex: regexp.MustCompile(`gho_[0-9a-zA-Z]{36}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"gho_"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("github", "gho_"+secrets.NewSecret(alphaNumeric("36"))),
|
||||
utils.GenerateSampleSecret("github", "gho_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
fps := []string{
|
||||
"gho_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func GitHubApp() *config.Rule {
|
||||
@@ -60,16 +73,21 @@ func GitHubApp() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a GitHub App Token, which may compromise GitHub application integrations and source code security.",
|
||||
RuleID: "github-app-token",
|
||||
Regex: regexp.MustCompile(`(ghu|ghs)_[0-9a-zA-Z]{36}`),
|
||||
Regex: regexp.MustCompile(`(?:ghu|ghs)_[0-9a-zA-Z]{36}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"ghu_", "ghs_"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("github", "ghu_"+secrets.NewSecret(alphaNumeric("36"))),
|
||||
generateSampleSecret("github", "ghs_"+secrets.NewSecret(alphaNumeric("36"))),
|
||||
utils.GenerateSampleSecret("github", "ghu_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
||||
utils.GenerateSampleSecret("github", "ghs_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
fps := []string{
|
||||
"ghu_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
"ghs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func GitHubRefresh() *config.Rule {
|
||||
@@ -78,12 +96,16 @@ func GitHubRefresh() *config.Rule {
|
||||
Description: "Detected a GitHub Refresh Token, which could allow prolonged unauthorized access to GitHub services.",
|
||||
RuleID: "github-refresh-token",
|
||||
Regex: regexp.MustCompile(`ghr_[0-9a-zA-Z]{36}`),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"ghr_"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("github", "ghr_"+secrets.NewSecret(alphaNumeric("36"))),
|
||||
utils.GenerateSampleSecret("github", "ghr_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
fps := []string{
|
||||
"ghr_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -18,9 +19,9 @@ func GitlabPat() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("gitlab", "glpat-"+secrets.NewSecret(alphaNumeric("20"))),
|
||||
utils.GenerateSampleSecret("gitlab", "glpat-"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GitlabPipelineTriggerToken() *config.Rule {
|
||||
@@ -34,9 +35,9 @@ func GitlabPipelineTriggerToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("gitlab", "glptt-"+secrets.NewSecret(hex("40"))),
|
||||
utils.GenerateSampleSecret("gitlab", "glptt-"+secrets.NewSecret(utils.Hex("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GitlabRunnerRegistrationToken() *config.Rule {
|
||||
@@ -50,7 +51,7 @@ func GitlabRunnerRegistrationToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("gitlab", "GR1348941"+secrets.NewSecret(alphaNumeric("20"))),
|
||||
utils.GenerateSampleSecret("gitlab", "GR1348941"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,8 +11,8 @@ func GitterAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "gitter-access-token",
|
||||
Description: "Uncovered a Gitter Access Token, which may lead to unauthorized access to chat and communication services.",
|
||||
Regex: generateSemiGenericRegex([]string{"gitter"},
|
||||
alphaNumericExtendedShort("40"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"gitter"},
|
||||
utils.AlphaNumericExtendedShort("40"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"gitter",
|
||||
@@ -20,8 +21,8 @@ func GitterAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("gitter",
|
||||
secrets.NewSecret(alphaNumericExtendedShort("40"))),
|
||||
utils.GenerateSampleSecret("gitter",
|
||||
secrets.NewSecret(utils.AlphaNumericExtendedShort("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func GoCardless() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "gocardless-api-token",
|
||||
Description: "Detected a GoCardless API token, potentially risking unauthorized direct debit payment operations and financial data exposure.",
|
||||
Regex: generateSemiGenericRegex([]string{"gocardless"}, `live_(?i)[a-z0-9\-_=]{40}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"gocardless"}, `live_(?i)[a-z0-9\-_=]{40}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"live_",
|
||||
@@ -20,7 +21,7 @@ func GoCardless() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("gocardless", "live_"+secrets.NewSecret(alphaNumericExtended("40"))),
|
||||
utils.GenerateSampleSecret("gocardless", "live_"+secrets.NewSecret(utils.AlphaNumericExtended("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -11,17 +12,17 @@ func GrafanaApiKey() *config.Rule {
|
||||
Description: "Identified a Grafana API key, which could compromise monitoring dashboards and sensitive data analytics.",
|
||||
RuleID: "grafana-api-key",
|
||||
|
||||
Regex: generateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`eyJrIjoi[A-Za-z0-9]{70,400}={0,2}`, true),
|
||||
Keywords: []string{"eyJrIjoi"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("grafana-api-key",
|
||||
utils.GenerateSampleSecret("grafana-api-key",
|
||||
"eyJrIjoi"+
|
||||
secrets.NewSecret(alphaNumeric("70"))),
|
||||
secrets.NewSecret(utils.AlphaNumeric("70"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GrafanaCloudApiToken() *config.Rule {
|
||||
@@ -30,17 +31,17 @@ func GrafanaCloudApiToken() *config.Rule {
|
||||
Description: "Found a Grafana cloud API token, risking unauthorized access to cloud-based monitoring services and data exposure.",
|
||||
RuleID: "grafana-cloud-api-token",
|
||||
|
||||
Regex: generateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`glc_[A-Za-z0-9+/]{32,400}={0,2}`, true),
|
||||
Keywords: []string{"glc_"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("grafana-cloud-api-token",
|
||||
utils.GenerateSampleSecret("grafana-cloud-api-token",
|
||||
"glc_"+
|
||||
secrets.NewSecret(alphaNumeric("32"))),
|
||||
secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func GrafanaServiceAccountToken() *config.Rule {
|
||||
@@ -49,17 +50,17 @@ func GrafanaServiceAccountToken() *config.Rule {
|
||||
Description: "Discovered a Grafana service account token, posing a risk of compromised monitoring services and data integrity.",
|
||||
RuleID: "grafana-service-account-token",
|
||||
|
||||
Regex: generateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}`, true),
|
||||
Keywords: []string{"glsa_"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("grafana-service-account-token",
|
||||
utils.GenerateSampleSecret("grafana-service-account-token",
|
||||
"glsa_"+
|
||||
secrets.NewSecret(alphaNumeric("32"))+
|
||||
secrets.NewSecret(utils.AlphaNumeric("32"))+
|
||||
"_"+
|
||||
secrets.NewSecret((hex("8")))),
|
||||
secrets.NewSecret((utils.Hex("8")))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
func HarnessApiKey() *config.Rule {
|
||||
// Define rule for Harness Personal Access Token (PAT) and Service Account Token (SAT)
|
||||
r := config.Rule{
|
||||
Description: "Identified a Harness Access Token (PAT or SAT), risking unauthorized access to a Harness account.",
|
||||
RuleID: "harness-api-key",
|
||||
Regex: regexp.MustCompile(`(?:pat|sat)\.[a-zA-Z0-9_-]{22}\.[a-zA-Z0-9]{24}\.[a-zA-Z0-9]{20}`),
|
||||
Keywords: []string{"pat.", "sat."},
|
||||
}
|
||||
|
||||
// Generate a sample secret for validation
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("harness", "pat."+secrets.NewSecret(utils.AlphaNumeric("22"))+"."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
utils.GenerateSampleSecret("harness", "sat."+secrets.NewSecret(utils.AlphaNumeric("22"))+"."+secrets.NewSecret(utils.AlphaNumeric("24"))+"."+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
|
||||
// validate the rule
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -2,26 +2,32 @@ package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
func Hashicorp() *config.Rule {
|
||||
func HashiCorpTerraform() *config.Rule {
|
||||
// define rule
|
||||
r := config.Rule{
|
||||
Description: "Uncovered a HashiCorp Terraform user/org API token, which may lead to unauthorized infrastructure management and security breaches.",
|
||||
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}\.(?-i:atlasv1)\.[a-z0-9\-_=]{60,70}`),
|
||||
Entropy: 3.5,
|
||||
Keywords: []string{"atlasv1"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("hashicorpToken", secrets.NewSecret(hex("14"))+".atlasv1."+secrets.NewSecret(alphaNumericExtended("60,70"))),
|
||||
utils.GenerateSampleSecret("hashicorpToken", secrets.NewSecret(utils.Hex("14"))+".atlasv1."+secrets.NewSecret(utils.AlphaNumericExtended("60,70"))),
|
||||
`#token = "hE1hlYILrSqpqh.atlasv1.ARjZuyzl33F71WR55s6ln5GQ1HWIwTDDH3MiRjz7OnpCfaCb1RCF5zGaSncCWmJdcYA"`,
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
fps := []string{
|
||||
`token = "xxxxxxxxxxxxxx.atlasv1.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"`, // low entropy
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func HashicorpField() *config.Rule {
|
||||
@@ -30,9 +36,9 @@ func HashicorpField() *config.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),
|
||||
Regex: utils.GenerateSemiGenericRegex(keywords, fmt.Sprintf(`"%s"`, utils.AlphaNumericExtended("8,20")), true),
|
||||
Keywords: keywords,
|
||||
Path: regexp.MustCompile(`\.(tf|hcl)$`),
|
||||
Path: regexp.MustCompile(`(?i)\.(?:tf|hcl)$`),
|
||||
}
|
||||
|
||||
tps := map[string]string{
|
||||
@@ -47,5 +53,5 @@ func HashicorpField() *config.Rule {
|
||||
"unrelated.js": "password = " + `"rootpasswd"`,
|
||||
}
|
||||
|
||||
return validateWithPaths(r, tps, fps)
|
||||
return utils.ValidateWithPaths(r, tps, fps)
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func VaultServiceToken() *config.Rule {
|
||||
// define rule
|
||||
r := config.Rule{
|
||||
RuleID: "vault-service-token",
|
||||
Description: "Identified a Vault Service Token, potentially compromising infrastructure security and access to sensitive credentials.",
|
||||
Regex: utils.GenerateUniqueTokenRegex(`(?:hvs\.[\w-]{90,120}|s\.(?i:[a-z0-9]{24}))`, false),
|
||||
Entropy: 3.5,
|
||||
Keywords: []string{"hvs", "s."},
|
||||
Allowlist: config.Allowlist{
|
||||
Regexes: []*regexp.Regexp{
|
||||
// https://github.com/gitleaks/gitleaks/issues/1490#issuecomment-2334166357
|
||||
regexp.MustCompile(`s\.[A-Za-z]{24}`),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
// Old
|
||||
utils.GenerateSampleSecret("vault", "s."+secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||
`token: s.ZC9Ecf4M5g9o34Q6RkzGsj0z`,
|
||||
// New
|
||||
utils.GenerateSampleSecret("vault", "hvs."+secrets.NewSecret(utils.AlphaNumericExtendedShort("90"))),
|
||||
`-vaultToken hvs.CAESIP2jTxc9S2K7Z6CtcFWQv7-044m_oSsxnPE1H3nF89l3GiYKHGh2cy5sQmlIZVNyTWJNcDRsYWJpQjlhYjVlb1cQh6PL8wEYAg"`, // longer than 100 chars
|
||||
}
|
||||
fps := []string{
|
||||
// Old
|
||||
` credentials: new AWS.SharedIniFileCredentials({ profile: '<YOUR_PROFILE>' })`, // word boundary start
|
||||
`INFO 4 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean`, // word boundary end
|
||||
`s.xxxxxxxxxxxxxxxxxxxxxxxx`, // low entropy
|
||||
`s.THISSTRINGISALLUPPERCASE`, // uppercase
|
||||
`s.thisstringisalllowercase`, // lowercase
|
||||
`s.AcceptanceTimeoutSeconds `, // pascal-case
|
||||
`s.makeKubeConfigController = args`, // camel-case
|
||||
// New
|
||||
`hvs.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`, // low entropy
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func VaultBatchToken() *config.Rule {
|
||||
// define rule
|
||||
r := config.Rule{
|
||||
Description: "Detected a Vault Batch Token, risking unauthorized access to secret management services and sensitive data.",
|
||||
RuleID: "vault-batch-token",
|
||||
Regex: utils.GenerateUniqueTokenRegex(`hvb\.[a-z0-9_-]{138,212}`, true),
|
||||
Keywords: []string{"hvb"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("vault", "hvb."+secrets.NewSecret(utils.AlphaNumericExtendedShort("138"))),
|
||||
}
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
@@ -9,7 +10,7 @@ func Heroku() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Heroku API Key, potentially compromising cloud application deployments and operational security.",
|
||||
RuleID: "heroku-api-key",
|
||||
Regex: generateSemiGenericRegex([]string{"heroku"}, hex8_4_4_4_12(), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"heroku"}, utils.Hex8_4_4_4_12(), true),
|
||||
|
||||
Keywords: []string{"heroku"},
|
||||
}
|
||||
@@ -19,5 +20,5 @@ func Heroku() *config.Rule {
|
||||
`const HEROKU_KEY = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||
`heroku_api_key = "832d2129-a846-4e27-99f4-7004b6ad53ef"`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
@@ -9,7 +10,7 @@ func HubSpot() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Found a HubSpot API Token, posing a risk to CRM data integrity and unauthorized marketing operations.",
|
||||
RuleID: "hubspot-api-key",
|
||||
Regex: generateSemiGenericRegex([]string{"hubspot"},
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"hubspot"},
|
||||
`[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}`, true),
|
||||
|
||||
Keywords: []string{"hubspot"},
|
||||
@@ -19,5 +20,5 @@ func HubSpot() *config.Rule {
|
||||
tps := []string{
|
||||
`const hubspotKey = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -63,7 +64,7 @@ func HuggingFaceAccessToken() *config.Rule {
|
||||
`# HuggingFace API Token https://huggingface.co/settings/tokens
|
||||
HUGGINGFACE_API_TOKEN=hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,`,
|
||||
}
|
||||
return validate(r, tps, fps)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
// Will be deprecated Aug 1st, 2023.
|
||||
@@ -111,5 +112,5 @@ func HuggingFaceOrganizationApiToken() *config.Rule {
|
||||
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)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -17,7 +18,7 @@ func InfracostAPIToken() *config.Rule {
|
||||
// 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),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`ico-[a-zA-Z0-9]{32}`, true),
|
||||
|
||||
// Keywords used for string matching on fragments (think of this as a prefilter)
|
||||
Keywords: []string{"ico-"},
|
||||
@@ -25,7 +26,7 @@ func InfracostAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("ico", "ico-"+secrets.NewSecret("[A-Za-z0-9]{32}")),
|
||||
utils.GenerateSampleSecret("ico", "ico-"+secrets.NewSecret("[A-Za-z0-9]{32}")),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,14 +11,14 @@ func Intercom() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified an Intercom API Token, which could compromise customer communication channels and data privacy.",
|
||||
RuleID: "intercom-api-key",
|
||||
Regex: generateSemiGenericRegex([]string{"intercom"}, alphaNumericExtended("60"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"intercom"}, utils.AlphaNumericExtended("60"), true),
|
||||
|
||||
Keywords: []string{"intercom"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("intercom", secrets.NewSecret(alphaNumericExtended("60"))),
|
||||
utils.GenerateSampleSecret("intercom", secrets.NewSecret(utils.AlphaNumericExtended("60"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func Intra42ClientSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Found a Intra42 client secret, which could lead to unauthorized access to the 42School API and sensitive data.",
|
||||
RuleID: "intra42-client-secret",
|
||||
Regex: generateUniqueTokenRegex(`s-s4t2(?:ud|af)-[abcdef0123456789]{64}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`s-s4t2(?:ud|af)-[abcdef0123456789]{64}`, true),
|
||||
Keywords: []string{
|
||||
"intra",
|
||||
"s-s4t2ud-",
|
||||
@@ -20,10 +21,10 @@ func Intra42ClientSecret() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
"clientSecret := \"s-s4t2ud-" + secrets.NewSecret(hex("64")) + "\"",
|
||||
"clientSecret := \"s-s4t2af-" + secrets.NewSecret(hex("64")) + "\"",
|
||||
"clientSecret := \"s-s4t2ud-" + secrets.NewSecret(utils.Hex("64")) + "\"",
|
||||
"clientSecret := \"s-s4t2af-" + secrets.NewSecret(utils.Hex("64")) + "\"",
|
||||
"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", // gitleaks:allow
|
||||
"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", // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
@@ -21,16 +22,16 @@ func JFrogAPIKey() *config.Rule {
|
||||
// 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),
|
||||
Regex: utils.GenerateSemiGenericRegex(keywords, utils.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"))),
|
||||
fmt.Sprintf("--set imagePullSecretJfrog.password=%s", secrets.NewSecret(utils.AlphaNumeric("73"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func JFrogIdentityToken() *config.Rule {
|
||||
@@ -47,7 +48,7 @@ func JFrogIdentityToken() *config.Rule {
|
||||
// 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),
|
||||
Regex: utils.GenerateSemiGenericRegex(keywords, utils.AlphaNumeric("64"), true),
|
||||
|
||||
// Keywords used for string matching on fragments (think of this as a prefilter)
|
||||
Keywords: keywords,
|
||||
@@ -55,10 +56,10 @@ func JFrogIdentityToken() *config.Rule {
|
||||
|
||||
// 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"))),
|
||||
utils.GenerateSampleSecret("jfrog", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
utils.GenerateSampleSecret("artifactory", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
utils.GenerateSampleSecret("bintray", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
utils.GenerateSampleSecret("xray", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package rules
|
||||
import (
|
||||
b64 "encoding/base64"
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
@@ -13,7 +14,7 @@ func JWT() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.",
|
||||
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: utils.GenerateUniqueTokenRegex(`ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9\/\\_-]{17,}\.(?:[a-zA-Z0-9\/\\_-]{10,}={0,2})?`, false),
|
||||
Keywords: []string{"ey"},
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ func JWT() *config.Rule {
|
||||
`# Req: Invoke-RestMethod -Uri 'http://localhost:8085/users' -Headers @{ 'X-API-KEY' = 'eyJhbGciOiJub25lIn0.eyJ1c2VybmFtZSI6Im1vcnR5Iiwic3ViIjoiMTIzIn0.' }`, // gitleaks:allow
|
||||
}
|
||||
fps := []string{}
|
||||
return validate(r, tps, fps)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func JWTBase64() *config.Rule {
|
||||
@@ -109,7 +110,7 @@ vHVobJ8A
|
||||
=mIC1
|
||||
-----END PGP PUBLIC KEY BLOCK-----`,
|
||||
}
|
||||
return validate(r, tps, fps)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
|
||||
func generateTestValues() []string {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,8 +11,8 @@ func KrakenAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "kraken-access-token",
|
||||
Description: "Identified a Kraken Access Token, potentially compromising cryptocurrency trading accounts and financial security.",
|
||||
Regex: generateSemiGenericRegex([]string{"kraken"},
|
||||
alphaNumericExtendedLong("80,90"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"kraken"},
|
||||
utils.AlphaNumericExtendedLong("80,90"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"kraken",
|
||||
@@ -20,8 +21,8 @@ func KrakenAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("kraken",
|
||||
secrets.NewSecret(alphaNumericExtendedLong("80,90"))),
|
||||
utils.GenerateSampleSecret("kraken",
|
||||
secrets.NewSecret(utils.AlphaNumericExtendedLong("80,90"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -0,0 +1,413 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
// KubernetesSecret validates if we detected a kubernetes secret which contains data!
|
||||
func KubernetesSecret() *config.Rule {
|
||||
// Only match basic variations of `kind: secret`, we don't want things like `kind: ExternalSecret`.
|
||||
//language=regexp
|
||||
kindPat := `\bkind:[ \t]*["']?secret["']?`
|
||||
// Only matches values (`key: value`) under `data:` that are:
|
||||
// - valid base64 characters
|
||||
// - longer than 10 characters (no "YmFyCg==")
|
||||
//language=regexp
|
||||
dataPat := `\bdata:(?:.|\s){0,100}?\s+([\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:["']?[a-z0-9]{10,}={0,3}["']?|\{\{[ \t\w"|$:=,.-]+}}|""|''))`
|
||||
|
||||
// define rule
|
||||
r := config.Rule{
|
||||
RuleID: "kubernetes-secret-yaml",
|
||||
Description: "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments",
|
||||
Regex: regexp.MustCompile(fmt.Sprintf(
|
||||
//language=regexp
|
||||
`(?i)(?:%s(?:.|\s){0,200}?%s|%s(?:.|\s){0,200}?%s)`, kindPat, dataPat, dataPat, kindPat)),
|
||||
Keywords: []string{
|
||||
"secret",
|
||||
},
|
||||
// Kubernetes secrets are usually yaml files.
|
||||
Path: regexp.MustCompile(`(?i)\.ya?ml$`),
|
||||
Allowlist: config.Allowlist{
|
||||
Regexes: []*regexp.Regexp{
|
||||
// Ignore empty or placeholder values.
|
||||
// variable: {{ .Values.Example }} (https://helm.sh/docs/chart_template_guide/variables/)
|
||||
// variable: ""
|
||||
// variable: ''
|
||||
regexp.MustCompile(`[\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:\{\{[ \t\w"|$:=,.-]+}}|""|'')`),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := map[string]string{
|
||||
"comment.yaml": `
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: heketi-secret
|
||||
namespace: default
|
||||
data:
|
||||
# base64 encoded password. E.g.: echo -n "mypassword" | base64
|
||||
key: bXlwYXNzd29yZA==`,
|
||||
// The "data"-key is before the identifier "kind: Secret"
|
||||
"before-kubernetes.yaml": `apiVersion: v1
|
||||
data:
|
||||
extra: YWRtaW46cGFzc3dvcmQ=
|
||||
kind: secret
|
||||
metadata:
|
||||
name: secret-sa-sample
|
||||
annotations:
|
||||
kubernetes.io/service-account.name: 'sa-name'`,
|
||||
"before-kubernetes.yml": `apiVersion: v1
|
||||
data:
|
||||
password: UyFCXCpkJHpEc2I9
|
||||
username: YWRtaW4=
|
||||
kind: Secret
|
||||
metadata:
|
||||
creationTimestamp: '2022-06-28T17:44:13Z'
|
||||
name: db-user-pass
|
||||
namespace: default
|
||||
type: Opaque`,
|
||||
"before-comment.yml": `apiVersion: v1
|
||||
data:
|
||||
# the data is abbreviated in this example
|
||||
password: UyFCXCpkJHpEc2I9
|
||||
username: YWRtaW4=
|
||||
kind: Secret
|
||||
metadata:
|
||||
creationTimestamp: '2022-06-28T17:44:13Z'
|
||||
name: db-user-pass
|
||||
namespace: default
|
||||
type: Opaque`,
|
||||
"before-quoted-1.yaml": `apiVersion: 'v1'
|
||||
data:
|
||||
extra: 'YWRtaW46cGFzc3dvcmQ='
|
||||
kind: 'Secret'
|
||||
metadata:
|
||||
name: 'secret-sa-sample'
|
||||
annotations:
|
||||
kubernetes.io/service-account.name: 'sa-name'`,
|
||||
"before-quoted-2.yaml": `apiVersion: "v1"
|
||||
data:
|
||||
extra: "YWRtaW46cGFzc3dvcmQ="
|
||||
kind: "secret"
|
||||
metadata:
|
||||
name: "secret-sa-sample"
|
||||
annotations:
|
||||
kubernetes.io/service-account.name: "sa-name"`,
|
||||
"before-multiline-literal.yaml": `apiVersion: v1
|
||||
data:
|
||||
.dockercfg: |
|
||||
eyJhdXRocyI6eyJodHRwczovL2V4YW1wbGUvdjEvIjp7ImF1dGgiOiJvcGVuc2VzYW1lIn19fQo=
|
||||
metadata:
|
||||
name: secret-dockercfg
|
||||
type: kubernetes.io/dockercfg
|
||||
kind: Secret
|
||||
`,
|
||||
"before-multiline-folded.yaml": `apiVersion: v1
|
||||
data:
|
||||
.dockercfg: >
|
||||
eyJhdXRocyI6eyJodHRwczovL2V4YW1wbGUvdjEvIjp7ImF1dGgiOiJvcGVuc2VzYW1lIn19fQo=
|
||||
metadata:
|
||||
name: secret-dockercfg
|
||||
type: kubernetes.io/dockercfg
|
||||
kind: Secret`,
|
||||
// Sample Kubernetes Secret from https://kubernetes.io/docs/concepts/configuration/secret/
|
||||
// The "data"-key is after the identifier "kind: Secret"
|
||||
"after-kubernetes.yaml": `apiVersion: v1
|
||||
kind: secret
|
||||
data:
|
||||
extra: YWRtaW46cGFzc3dvcmQ=
|
||||
metadata:
|
||||
name: secret-sa-sample
|
||||
annotations:
|
||||
kubernetes.io/service-account.name: 'sa-name'`,
|
||||
"after-kubernetes.yml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: ca-secret
|
||||
type: Opaque
|
||||
data:
|
||||
ca.pem: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR4RENDQXF5Z0F3SUJBZ0lVV3pqUDl5RUk0eHlRSnBzVHVERU4yV2ROaUFzd0RRWUpLb1pJaHZjTkFRRUwKQlFBd2FERUxNQWtHQTFVRUJoTUNWVk14RHpBTkJnTlZCQWdUQms5eVpXZHZiakVSTUE4R0ExVUVCeE1JVUc5eQpkR3hoYm1ReEV6QVJCZ05WQkFvVENrdDFZbVZ5Ym1WMFpYTXhDekFKQmdOVkJBc1RBa05CTVJNd0VRWURWUVFECkV3cExkV0psY201bGRHVnpNQjRYRFRFMk1EZ3hNVEUyTkRnd01Gb1hEVEl4TURneE1ERTJORGd3TUZvd2FERUwKTUFrR0ExVUVCaE1DVlZNeER6QU5CZ05WQkFnVEJrOXlaV2R2YmpFUk1BOEdBMVVFQnhNSVVHOXlkR3hoYm1ReApFekFSQmdOVkJBb1RDa3QxWW1WeWJtVjBaWE14Q3pBSkJnTlZCQXNUQWtOQk1STXdFUVlEVlFRREV3cExkV0psCmNtNWxkR1Z6TUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUF3QkhNOGN6anc0Q1cKK05wbklhV012RzZlcVhtelNZT20vbHdaNUhOMnVLck9xaTNHYUUyTjFKd2tzcGRmMXNOUGFZMHdPR2xkbURIZgoxSnlyTW8rUFdLVUVjWko1WGE4Vm02d2I0MlpjczN3MEp5dlEzWFJjaDQyMFJRWGRKayszcmMybWRvSVRkL0lmCnZjWms0N0RzQTMrQU5QSUlSTzdWRmZpS1JNRFpTUDR1OThnVjI2eW1zbjc0TzFVKzNVUHR1TEFTVTFLck9FTk4KR01FWG0ydTJpdmVvbTJrbjFlZTZuM1hCR1o2bU52cUNPdWUxRXdza0gvWkhoUVh1UDgyV1U5dVk0aGVORnoyQwpBNmR0Q0Q0c3Z6eHc3ZFQ2cVhsV0ZIWUYrc3VLVDhXNkczd3NkOWxzV0ZVY0ZWL0lwaTVobEVaTWprNFNoY3RqCjdpYnlrRURKM1FJREFRQUJvMll3WkRBT0JnTlZIUThCQWY4RUJBTUNBUVl3RWdZRFZSMFRBUUgvQkFnd0JnRUIKL3dJQkFqQWRCZ05WSFE0RUZnUVVOdnhRZ3o5ZTNXS2VscU1KTmZXNE1KUHYzc0V3SHdZRFZSMGpCQmd3Rm9BVQpOdnhRZ3o5ZTNXS2VscU1KTmZXNE1KUHYzc0V3RFFZSktvWklodmNOQVFFTEJRQURnZ0VCQUp1TUhYUms1TEVyCmxET1p4Mm9aRUNQZ29reXMzSGJsM05oempXd2pncXdxNVN6a011V3QrUnVkdnRTK0FUQjFtTjRjYTN0eSt2bWcKT09heTkvaDZoditmSE5jZHpYdWR5dFZYZW1KN3F4ZFoxd25DUUcwdnpqOWRZY0xFSGpJWi94dU1jNlY3dnJ4YwpSc0preGp5aE01UXBmRHd0eVZKeGpkUmVBZ0huSyswTkNieHdtQ3cyRGIvOXpudm9LWGk4TEQwbkQzOFQxY3R3CmhmdGxwTmRoZXFNRlpEZXBuTUYwY2g2cHo5TFV5Mkh1cnhrV2dkWVNjY2VNU0hPTzBMcG4xeVVBMWczOTJhUjUKWk81Zm5KMW95Vm1LVWFCeDJCMndsSVlUSXlES1ZiMnY1UXNHbnYvRHVTMDZhcmVLTmsvTGpHRTRlMXlHOHJkcwpacnZHMzNvUmtEbz0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
|
||||
`,
|
||||
"after-comment.yml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
creationTimestamp: '2022-06-28T17:44:13Z'
|
||||
name: db-user-pass
|
||||
namespace: default
|
||||
type: Opaque
|
||||
data:
|
||||
# the data is abbreviated in this example
|
||||
password: UyFCXCpkJHpEc2I9
|
||||
username: YWRtaW4=
|
||||
`,
|
||||
"after-quoted-1.yaml": `apiVersion: 'v1'
|
||||
kind: 'Secret'
|
||||
data:
|
||||
password: 'UyFCXCpkJHpEc2I9'
|
||||
username: 'YWRtaW4='
|
||||
metadata:
|
||||
name: 'db-user-pass'
|
||||
namespace: 'default'
|
||||
type: 'Opaque'`,
|
||||
"after-quoted-2.yaml": `apiVersion: "v1"
|
||||
kind: "Secret"
|
||||
data:
|
||||
password: "UyFCXCpkJHpEc2I9"
|
||||
username: "YWRtaW4="
|
||||
metadata:
|
||||
name: "db-user-pass"
|
||||
namespace: "default"
|
||||
type: "Opaque"`,
|
||||
"after-multiline-literal.yaml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: secret-dockercfg
|
||||
type: kubernetes.io/dockercfg
|
||||
data:
|
||||
.dockercfg: |
|
||||
eyJhdXRocyI6eyJodHRwczovL2V4YW1wbGUvdjEvIjp7ImF1dGgiOiJvcGVuc2VzYW1lIn19fQo=
|
||||
`,
|
||||
"after-multiline-folded.yaml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: secret-dockercfg
|
||||
type: kubernetes.io/dockercfg
|
||||
data:
|
||||
.dockercfg: >
|
||||
eyJhdXRocyI6eyJodHRwczovL2V4YW1wbGUvdjEvIjp7ImF1dGgiOiJvcGVuc2VzYW1lIn19fQo=`,
|
||||
}
|
||||
fps := map[string]string{
|
||||
"empty-quotes1.yml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: registry-auth-data
|
||||
type: Opaque
|
||||
data:
|
||||
htpasswd: ''
|
||||
`,
|
||||
"empty-quotes2.yml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: registry-auth-data
|
||||
type: Opaque
|
||||
data:
|
||||
htpasswd: ""
|
||||
`,
|
||||
"overly-permissive1.yaml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: registry-auth-data
|
||||
type: Opaque
|
||||
data:
|
||||
htpasswd: {{ htpasswd }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ReplicationController`,
|
||||
"overly-permissive2.yaml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
addonmanager.kubernetes.io/mode: EnsureExists
|
||||
name: kubernetes-dashboard-csrf
|
||||
namespace: kubernetes-dashboard
|
||||
type: Opaque
|
||||
data:
|
||||
csrf: ""
|
||||
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
addonmanager.kubernetes.io/mode: EnsureExists
|
||||
name: kubernetes-dashboard-key-holder
|
||||
namespace: kubernetes-dashboard
|
||||
type: Opaque
|
||||
`,
|
||||
"sopssecret.yaml": `apiVersion: isindir.github.com/v1alpha3
|
||||
kind: SopsSecret
|
||||
metadata:
|
||||
name: app1-sopssecret
|
||||
namespace: test
|
||||
spec:
|
||||
suspend: false
|
||||
secretTemplates:
|
||||
- name: ENC[AES256_GCM,data:W3PiZ6lD6bpfAdI=,iv:2qF98ZkchgfWF4tZo8fok6zY0ZLNRV3wFpl8n2iyC7I=,tag:FzoL+CZHkLEqfWKniRApBA==,type:str]
|
||||
labels:
|
||||
app: ENC[AES256_GCM,data:t9ujIQ==,iv:slZBpmKF+DOg/wVBWmq5iTqkRBZUMao0a3MdoxzJs3s=,tag:xJyhdJ4rn/cB/4mxHzmGig==,type:str]
|
||||
stringData:
|
||||
db-password: ENC[AES256_GCM,data:O+5l4g==,iv:c/dS4BCBMbnKsXYuzBuCuVQt8RV9bOv5HgdpL+iwmns=,tag:KkQfh6OymvCt4uC13p318g==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
azure_kv: []
|
||||
hc_vault: []
|
||||
lastmodified: '2021-10-21T10:56:37Z'
|
||||
mac: ENC[AES256_GCM,data:Tl1V1PuI5tZ0Hu3qxxzpDNeKQkuW0g/x/Mlp1yM6HaBqDr+r2FukLdYSYqjjJ3A8g+YkpvMib50M7j0V7zoX9sgCvMKEg86pRsWtThv8n/L+bsjClVTqnhJ9nfYlaPOMlvggbiMOE5hXPIuVz8WXYoVYJ2cVNCd/GfwOraUmj7I=,iv:n7HVI13okfbW3FS/ZsJ2GNmibudxc/TlkLa3umQQ+vc=,tag:R4ikep1wlxlDWlODJqFHHw==,type:str]
|
||||
pgp:
|
||||
- created_at: '2021-10-21T10:56:37Z'
|
||||
enc: |
|
||||
-----BEGIN PGP MESSAGE-----
|
||||
|
||||
hQGMA3muqimBu2IIAQwAkhR19/6roLq06oaD12vqDMes3/8FweAHxa6TLKg+LRjp
|
||||
2/ntiRJHPBP9DYYFZbkTo8lAmIdVF7KfGIqWgPm5JiNhqfVRhyGPCRgBE7+I8qH6
|
||||
EML9Vo/76kJLHtIjs5rOg7OXgwwitaibs1q6uyVY8TuaGXYIOO1iwL9xVtbayIry
|
||||
NMQd1tFcNb6Vb86Plqm+T1VnSOJMUvryxrLelx89UNM0ctepyVu6YY9jpBjV0QLJ
|
||||
NqNkKAGIMv3RNa9bZHTwveo9T0oXtFnk5H33BxH0ky/DGpD+5Ch1YgbzbqVnr+Bm
|
||||
RX0R/GRhS9IDInd+eiyVX6y3LR5di0fc8TuK43+96wTG+2+ck+lbMrkHYsL2UJNv
|
||||
bAjlOWmIcL4UwGlEOj4EzwcEx+xP3dq57pJ+DasfNwVqps2Kk+ofodR7d6gx7ELH
|
||||
UQmLypCtkRic9v8fVSA2vEL8hAlg9bT8tpHLhHMOwe228cL5dTzFD60RoP+ovRar
|
||||
jIU59Pnu1bnM4pXWEVA20l4BzJ8Fd6gj3TfAg/7Mat+dnTaUwnPgRSybFn0ZZHMW
|
||||
RJDBPkMGFfSGRDfLeD37d61mI31360/w/61LaVp1sdDYodBJCRZFA1YzbqZcxnDl
|
||||
YRjRmpcVRnO+o72CnU/P
|
||||
=V4l4
|
||||
-----END PGP MESSAGE-----
|
||||
fp: 73019E949C1D3C3D1BE8B718C7CD51A565AB592C
|
||||
encrypted_suffix: Templates
|
||||
version: 3.6.1`, // https://github.com/luca-iachini/argocd-test/blob/af0c8eaba270bc918108c8bc3b909f26a4fe995d/kustomize/base/app1/secrets.enc.yaml#L4
|
||||
// The "data"-key is before the identifier "kind: Secret"
|
||||
"before-min-length.yaml": `apiVersion: v1
|
||||
data:
|
||||
extra: YmFyCg==
|
||||
kind: secret
|
||||
metadata:
|
||||
name: secret-sa-sample
|
||||
annotations:
|
||||
kubernetes.io/service-account.name: 'sa-name'`,
|
||||
"before-template.yaml": `apiVersion: v1
|
||||
data:
|
||||
password: {{ .Values.Password }}
|
||||
kind: secret
|
||||
metadata:
|
||||
name: secret-sa-sample
|
||||
annotations:
|
||||
kubernetes.io/service-account.name: 'sa-name'`,
|
||||
"before-externalsecret1.yml": `apiVersion: 'kubernetes-client.io/v1'
|
||||
metadata:
|
||||
name: actions-exporter
|
||||
namespace: github-actions-exporter
|
||||
spec:
|
||||
backendType: secretsManager
|
||||
data:
|
||||
- key: MySecretManagerKey
|
||||
name: github_token
|
||||
property: github_token
|
||||
kind: ExternalSecret
|
||||
`,
|
||||
"before-externalsecret2.yml": `apiVersion: external-secrets.io/v1beta1
|
||||
spec:
|
||||
secretStoreRef:
|
||||
kind: ClusterSecretStore
|
||||
name: aws-secretsmanager
|
||||
refreshInterval: 1h
|
||||
target:
|
||||
creationPolicy: Owner
|
||||
data:
|
||||
- secretKey: api-key
|
||||
remoteRef:
|
||||
key: my-secrets-manager-secret
|
||||
metadata:
|
||||
name: api-key
|
||||
namespace: my-namespace
|
||||
kind: ExternalSecret
|
||||
`,
|
||||
"before-sopssecret.yml": `apiVersion: isindir.github.com/v1alpha3
|
||||
spec:
|
||||
secretTemplates:
|
||||
- name: my-secret-name-1
|
||||
labels:
|
||||
label1: value1
|
||||
annotations:
|
||||
key1: value1
|
||||
data:
|
||||
data-name1: ZGF0YS12YWx1ZTE=
|
||||
data-nameM: ZGF0YS12YWx1ZU0=
|
||||
kind: SopsSecret
|
||||
metadata:
|
||||
name: sopssecret-sample
|
||||
`, // https://github.com/isindir/sops-secrets-operator/blob/8aaf8bb368dc841a2d57f251bd839f08216a9328/config/samples/isindir_v1alpha3_sopssecret.yaml#L4
|
||||
// The "data"-key is after the identifier "kind: Secret"
|
||||
"after-min-length.yaml": `apiVersion: v1
|
||||
kind: secret
|
||||
data:
|
||||
extra: YmFyCg==
|
||||
metadata:
|
||||
name: secret-sa-sample
|
||||
annotations:
|
||||
kubernetes.io/service-account.name: 'sa-name'`,
|
||||
"after-externalsecret1.yml": `apiVersion: 'kubernetes-client.io/v1'
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: actions-exporter
|
||||
namespace: github-actions-exporter
|
||||
spec:
|
||||
backendType: secretsManager
|
||||
data:
|
||||
- key: MySecretManagerKey
|
||||
name: github_token
|
||||
property: github_token
|
||||
- key: MySecretManagerKey`,
|
||||
"after-externalsecret2.yml": `apiVersion: external-secrets.io/v1beta1
|
||||
kind: ExternalSecret
|
||||
metadata:
|
||||
name: api-key
|
||||
namespace: my-namespace
|
||||
spec:
|
||||
secretStoreRef:
|
||||
kind: ClusterSecretStore
|
||||
name: aws-secretsmanager
|
||||
refreshInterval: 1h
|
||||
target:
|
||||
creationPolicy: Owner
|
||||
data:
|
||||
- secretKey: api-key
|
||||
remoteRef:
|
||||
key: my-secrets-manager-secret`,
|
||||
"after-sopssecret.yml": `apiVersion: isindir.github.com/v1alpha3
|
||||
kind: SopsSecret
|
||||
metadata:
|
||||
name: sopssecret-sample
|
||||
spec:
|
||||
secretTemplates:
|
||||
- name: my-secret-name-0
|
||||
labels:
|
||||
label0: value0
|
||||
labelK: valueK
|
||||
annotations:
|
||||
key0: value0
|
||||
keyN: valueN
|
||||
stringData:
|
||||
data-name0: data-value0
|
||||
data-nameL: data-valueL
|
||||
- name: my-secret-name-1
|
||||
labels:
|
||||
label1: value1
|
||||
annotations:
|
||||
key1: value1
|
||||
data:
|
||||
data-name1: ZGF0YS12YWx1ZTE=
|
||||
data-nameM: ZGF0YS12YWx1ZU0=`,
|
||||
"after-empty-data.yaml": `apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kubernetes-dashboard
|
||||
addonmanager.kubernetes.io/mode: EnsureExists
|
||||
name: kubernetes-dashboard-csrf
|
||||
namespace: kubernetes-dashboard
|
||||
type: Opaque
|
||||
data:
|
||||
csrf: ""
|
||||
`,
|
||||
}
|
||||
return utils.ValidateWithPaths(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func KucoinAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "kucoin-access-token",
|
||||
Description: "Found a Kucoin Access Token, risking unauthorized access to cryptocurrency exchange services and transactions.",
|
||||
Regex: generateSemiGenericRegex([]string{"kucoin"}, hex("24"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"kucoin"}, utils.Hex("24"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"kucoin",
|
||||
@@ -19,9 +20,9 @@ func KucoinAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("kucoin", secrets.NewSecret(hex("24"))),
|
||||
utils.GenerateSampleSecret("kucoin", secrets.NewSecret(utils.Hex("24"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func KucoinSecretKey() *config.Rule {
|
||||
@@ -29,7 +30,7 @@ func KucoinSecretKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "kucoin-secret-key",
|
||||
Description: "Discovered a Kucoin Secret Key, which could lead to compromised cryptocurrency operations and financial data breaches.",
|
||||
Regex: generateSemiGenericRegex([]string{"kucoin"}, hex8_4_4_4_12(), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"kucoin"}, utils.Hex8_4_4_4_12(), true),
|
||||
|
||||
Keywords: []string{
|
||||
"kucoin",
|
||||
@@ -38,7 +39,7 @@ func KucoinSecretKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("kucoin", secrets.NewSecret(hex8_4_4_4_12())),
|
||||
utils.GenerateSampleSecret("kucoin", secrets.NewSecret(utils.Hex8_4_4_4_12())),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func LaunchDarklyAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "launchdarkly-access-token",
|
||||
Description: "Uncovered a Launchdarkly Access Token, potentially compromising feature flag management and application functionality.",
|
||||
Regex: generateSemiGenericRegex([]string{"launchdarkly"}, alphaNumericExtended("40"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"launchdarkly"}, utils.AlphaNumericExtended("40"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"launchdarkly",
|
||||
@@ -19,7 +20,7 @@ func LaunchDarklyAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("launchdarkly", secrets.NewSecret(alphaNumericExtended("40"))),
|
||||
utils.GenerateSampleSecret("launchdarkly", secrets.NewSecret(utils.AlphaNumericExtended("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -18,9 +19,9 @@ func LinearAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("linear", "lin_api_"+secrets.NewSecret(alphaNumeric("40"))),
|
||||
utils.GenerateSampleSecret("linear", "lin_api_"+secrets.NewSecret(utils.AlphaNumeric("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func LinearClientSecret() *config.Rule {
|
||||
@@ -28,13 +29,13 @@ func LinearClientSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a Linear Client Secret, which may compromise secure integrations and sensitive project management data.",
|
||||
RuleID: "linear-client-secret",
|
||||
Regex: generateSemiGenericRegex([]string{"linear"}, hex("32"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"linear"}, utils.Hex("32"), true),
|
||||
Keywords: []string{"linear"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("linear", secrets.NewSecret(hex("32"))),
|
||||
utils.GenerateSampleSecret("linear", secrets.NewSecret(utils.Hex("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,10 +11,10 @@ func LinkedinClientSecret() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "linkedin-client-secret",
|
||||
Description: "Discovered a LinkedIn Client secret, potentially compromising LinkedIn application integrations and user data.",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"linkedin",
|
||||
"linked-in",
|
||||
}, alphaNumeric("16"), true),
|
||||
}, utils.AlphaNumeric("16"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"linkedin",
|
||||
@@ -23,9 +24,9 @@ func LinkedinClientSecret() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("linkedin", secrets.NewSecret(alphaNumeric("16"))),
|
||||
utils.GenerateSampleSecret("linkedin", secrets.NewSecret(utils.AlphaNumeric("16"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func LinkedinClientID() *config.Rule {
|
||||
@@ -33,10 +34,10 @@ func LinkedinClientID() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "linkedin-client-id",
|
||||
Description: "Found a LinkedIn Client ID, risking unauthorized access to LinkedIn integrations and professional data exposure.",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"linkedin",
|
||||
"linked-in",
|
||||
}, alphaNumeric("14"), true),
|
||||
}, utils.AlphaNumeric("14"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"linkedin",
|
||||
@@ -46,7 +47,7 @@ func LinkedinClientID() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("linkedin", secrets.NewSecret(alphaNumeric("14"))),
|
||||
utils.GenerateSampleSecret("linkedin", secrets.NewSecret(utils.AlphaNumeric("14"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func LobPubAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a Lob Publishable API Key, posing a risk of exposing mail and print service integrations.",
|
||||
RuleID: "lob-pub-api-key",
|
||||
Regex: generateSemiGenericRegex([]string{"lob"}, `(test|live)_pub_[a-f0-9]{31}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"lob"}, `(test|live)_pub_[a-f0-9]{31}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"test_pub",
|
||||
@@ -21,9 +22,9 @@ func LobPubAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("lob", "test_pub_"+secrets.NewSecret(hex("31"))),
|
||||
utils.GenerateSampleSecret("lob", "test_pub_"+secrets.NewSecret(utils.Hex("31"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func LobAPIToken() *config.Rule {
|
||||
@@ -31,7 +32,7 @@ func LobAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Uncovered a Lob API Key, which could lead to unauthorized access to mailing and address verification services.",
|
||||
RuleID: "lob-api-key",
|
||||
Regex: generateSemiGenericRegex([]string{"lob"}, `(live|test)_[a-f0-9]{35}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"lob"}, `(live|test)_[a-f0-9]{35}`, true),
|
||||
Keywords: []string{
|
||||
"test_",
|
||||
"live_",
|
||||
@@ -40,7 +41,7 @@ func LobAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("lob", "test_"+secrets.NewSecret(hex("35"))),
|
||||
utils.GenerateSampleSecret("lob", "test_"+secrets.NewSecret(utils.Hex("35"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func MailChimp() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "mailchimp-api-key",
|
||||
Description: "Identified a Mailchimp API key, potentially compromising email marketing campaigns and subscriber data.",
|
||||
Regex: generateSemiGenericRegex([]string{"MailchimpSDK.initialize", "mailchimp"}, hex("32")+`-us\d\d`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"MailchimpSDK.initialize", "mailchimp"}, utils.Hex("32")+`-us\d\d`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"mailchimp",
|
||||
@@ -19,7 +20,7 @@ func MailChimp() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("mailchimp", secrets.NewSecret(hex("32"))+"-us20"),
|
||||
utils.GenerateSampleSecret("mailchimp", secrets.NewSecret(utils.Hex("32"))+"-us20"),
|
||||
`mailchimp_api_key: cefa780880ba5f5696192a34f6292c35-us18`, // gitleaks:allow
|
||||
`MAILCHIMPE_KEY = "b5b9f8e50c640da28993e8b6a48e3e53-us18"`, // gitleaks:allow
|
||||
}
|
||||
@@ -27,5 +28,5 @@ func MailChimp() *config.Rule {
|
||||
// False Negative
|
||||
`MailchimpSDK.initialize(token: 3012a5754bbd716926f99c028f7ea428-us18)`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, fps)
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func MailGunPrivateAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "mailgun-private-api-token",
|
||||
Description: "Found a Mailgun private API token, risking unauthorized email service operations and data breaches.",
|
||||
Regex: generateSemiGenericRegex([]string{"mailgun"}, `key-[a-f0-9]{32}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"mailgun"}, `key-[a-f0-9]{32}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"mailgun",
|
||||
@@ -19,9 +20,9 @@ func MailGunPrivateAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("mailgun", "key-"+secrets.NewSecret(hex("32"))),
|
||||
utils.GenerateSampleSecret("mailgun", "key-"+secrets.NewSecret(utils.Hex("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func MailGunPubAPIToken() *config.Rule {
|
||||
@@ -29,7 +30,7 @@ func MailGunPubAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "mailgun-pub-key",
|
||||
Description: "Discovered a Mailgun public validation key, which could expose email verification processes and associated data.",
|
||||
Regex: generateSemiGenericRegex([]string{"mailgun"}, `pubkey-[a-f0-9]{32}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"mailgun"}, `pubkey-[a-f0-9]{32}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"mailgun",
|
||||
@@ -38,9 +39,9 @@ func MailGunPubAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("mailgun", "pubkey-"+secrets.NewSecret(hex("32"))),
|
||||
utils.GenerateSampleSecret("mailgun", "pubkey-"+secrets.NewSecret(utils.Hex("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func MailGunSigningKey() *config.Rule {
|
||||
@@ -48,7 +49,7 @@ func MailGunSigningKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "mailgun-signing-key",
|
||||
Description: "Uncovered a Mailgun webhook signing key, potentially compromising email automation and data integrity.",
|
||||
Regex: generateSemiGenericRegex([]string{"mailgun"}, `[a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"mailgun"}, `[a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"mailgun",
|
||||
@@ -57,7 +58,7 @@ func MailGunSigningKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("mailgun", secrets.NewSecret(hex("32"))+"-00001111-22223333"),
|
||||
utils.GenerateSampleSecret("mailgun", secrets.NewSecret(utils.Hex("32"))+"-00001111-22223333"),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,14 +11,14 @@ func MapBox() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Detected a MapBox API token, posing a risk to geospatial services and sensitive location data exposure.",
|
||||
RuleID: "mapbox-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{"mapbox"}, `pk\.[a-z0-9]{60}\.[a-z0-9]{22}`, true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"mapbox"}, `pk\.[a-z0-9]{60}\.[a-z0-9]{22}`, true),
|
||||
|
||||
Keywords: []string{"mapbox"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("mapbox", "pk."+secrets.NewSecret(alphaNumeric("60"))+"."+secrets.NewSecret(alphaNumeric("22"))),
|
||||
utils.GenerateSampleSecret("mapbox", "pk."+secrets.NewSecret(utils.AlphaNumeric("60"))+"."+secrets.NewSecret(utils.AlphaNumeric("22"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func MattermostAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "mattermost-access-token",
|
||||
Description: "Identified a Mattermost Access Token, which may compromise team communication channels and data privacy.",
|
||||
Regex: generateSemiGenericRegex([]string{"mattermost"}, alphaNumeric("26"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"mattermost"}, utils.AlphaNumeric("26"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"mattermost",
|
||||
@@ -19,7 +20,7 @@ func MattermostAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("mattermost", secrets.NewSecret(alphaNumeric("26"))),
|
||||
utils.GenerateSampleSecret("mattermost", secrets.NewSecret(utils.AlphaNumeric("26"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,11 +11,11 @@ func MessageBirdAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Found a MessageBird API token, risking unauthorized access to communication platforms and message data.",
|
||||
RuleID: "messagebird-api-token",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"messagebird",
|
||||
"message-bird",
|
||||
"message_bird",
|
||||
}, alphaNumeric("25"), true),
|
||||
}, utils.AlphaNumeric("25"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"messagebird",
|
||||
@@ -25,11 +26,11 @@ func MessageBirdAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("messagebird", secrets.NewSecret(alphaNumeric("25"))),
|
||||
generateSampleSecret("message-bird", secrets.NewSecret(alphaNumeric("25"))),
|
||||
generateSampleSecret("message_bird", secrets.NewSecret(alphaNumeric("25"))),
|
||||
utils.GenerateSampleSecret("messagebird", secrets.NewSecret(utils.AlphaNumeric("25"))),
|
||||
utils.GenerateSampleSecret("message-bird", secrets.NewSecret(utils.AlphaNumeric("25"))),
|
||||
utils.GenerateSampleSecret("message_bird", secrets.NewSecret(utils.AlphaNumeric("25"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func MessageBirdClientID() *config.Rule {
|
||||
@@ -37,11 +38,11 @@ func MessageBirdClientID() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Discovered a MessageBird client ID, potentially compromising API integrations and sensitive communication data.",
|
||||
RuleID: "messagebird-client-id",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"messagebird",
|
||||
"message-bird",
|
||||
"message_bird",
|
||||
}, hex8_4_4_4_12(), true),
|
||||
}, utils.Hex8_4_4_4_12(), true),
|
||||
|
||||
Keywords: []string{
|
||||
"messagebird",
|
||||
@@ -54,5 +55,5 @@ func MessageBirdClientID() *config.Rule {
|
||||
tps := []string{
|
||||
`const MessageBirdClientID = "12345678-ABCD-ABCD-ABCD-1234567890AB"`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,8 +11,8 @@ func NetlifyAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "netlify-access-token",
|
||||
Description: "Detected a Netlify Access Token, potentially compromising web hosting services and site management.",
|
||||
Regex: generateSemiGenericRegex([]string{"netlify"},
|
||||
alphaNumericExtended("40,46"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"netlify"},
|
||||
utils.AlphaNumericExtended("40,46"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"netlify",
|
||||
@@ -20,7 +21,7 @@ func NetlifyAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("netlify", secrets.NewSecret(alphaNumericExtended("40,46"))),
|
||||
utils.GenerateSampleSecret("netlify", secrets.NewSecret(utils.AlphaNumericExtended("40,46"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func NewRelicUserID() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "new-relic-user-api-key",
|
||||
Description: "Discovered a New Relic user API Key, which could lead to compromised application insights and performance monitoring.",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"new-relic",
|
||||
"newrelic",
|
||||
"new_relic",
|
||||
@@ -23,9 +24,9 @@ func NewRelicUserID() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("new-relic", "NRAK-"+secrets.NewSecret(alphaNumeric("27"))),
|
||||
utils.GenerateSampleSecret("new-relic", "NRAK-"+secrets.NewSecret(utils.AlphaNumeric("27"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func NewRelicUserKey() *config.Rule {
|
||||
@@ -33,11 +34,11 @@ func NewRelicUserKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "new-relic-user-api-id",
|
||||
Description: "Found a New Relic user API ID, posing a risk to application monitoring services and data integrity.",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"new-relic",
|
||||
"newrelic",
|
||||
"new_relic",
|
||||
}, alphaNumeric("64"), true),
|
||||
}, utils.AlphaNumeric("64"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"new-relic",
|
||||
@@ -48,9 +49,9 @@ func NewRelicUserKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("new-relic", secrets.NewSecret(alphaNumeric("64"))),
|
||||
utils.GenerateSampleSecret("new-relic", secrets.NewSecret(utils.AlphaNumeric("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func NewRelicBrowserAPIKey() *config.Rule {
|
||||
@@ -58,7 +59,7 @@ func NewRelicBrowserAPIKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "new-relic-browser-api-token",
|
||||
Description: "Identified a New Relic ingest browser API token, risking unauthorized access to application performance data and analytics.",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"new-relic",
|
||||
"newrelic",
|
||||
"new_relic",
|
||||
@@ -71,9 +72,9 @@ func NewRelicBrowserAPIKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("new-relic", "NRJS-"+secrets.NewSecret(hex("19"))),
|
||||
utils.GenerateSampleSecret("new-relic", "NRJS-"+secrets.NewSecret(utils.Hex("19"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func NewRelicInsertKey() *config.Rule {
|
||||
@@ -81,7 +82,7 @@ func NewRelicInsertKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "new-relic-insert-key",
|
||||
Description: "Discovered a New Relic insight insert key, compromising data injection into the platform.",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"new-relic",
|
||||
"newrelic",
|
||||
"new_relic",
|
||||
@@ -94,7 +95,7 @@ func NewRelicInsertKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("new-relic", "NRII-"+secrets.NewSecret(hex("32"))),
|
||||
utils.GenerateSampleSecret("new-relic", "NRII-"+secrets.NewSecret(utils.Hex("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func NPM() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "npm-access-token",
|
||||
Description: "Uncovered an npm access token, potentially compromising package management and code repository access.",
|
||||
Regex: generateUniqueTokenRegex(`npm_[a-z0-9]{36}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`npm_[a-z0-9]{36}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"npm_",
|
||||
@@ -19,7 +20,7 @@ func NPM() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("npmAccessToken", "npm_"+secrets.NewSecret(alphaNumeric("36"))),
|
||||
utils.GenerateSampleSecret("npmAccessToken", "npm_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,9 +11,9 @@ func NytimesAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "nytimes-access-token",
|
||||
Description: "Detected a Nytimes Access Token, risking unauthorized access to New York Times APIs and content services.",
|
||||
Regex: generateSemiGenericRegex([]string{
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{
|
||||
"nytimes", "new-york-times,", "newyorktimes"},
|
||||
alphaNumericExtended("32"), true),
|
||||
utils.AlphaNumericExtended("32"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"nytimes",
|
||||
@@ -23,7 +24,7 @@ func NytimesAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("nytimes", secrets.NewSecret(alphaNumeric("32"))),
|
||||
utils.GenerateSampleSecret("nytimes", secrets.NewSecret(utils.AlphaNumeric("32"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,8 +11,8 @@ func OktaAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "okta-access-token",
|
||||
Description: "Identified an Okta Access Token, which may compromise identity management services and user authentication data.",
|
||||
Regex: generateSemiGenericRegex([]string{"okta"},
|
||||
alphaNumericExtended("42"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"okta"},
|
||||
utils.AlphaNumericExtended("42"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"okta",
|
||||
@@ -20,7 +21,7 @@ func OktaAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("okta", secrets.NewSecret(alphaNumeric("42"))),
|
||||
utils.GenerateSampleSecret("okta", secrets.NewSecret(utils.AlphaNumeric("42"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func OpenAI() *config.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),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`sk-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"T3BlbkFJ",
|
||||
@@ -19,7 +20,7 @@ func OpenAI() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("openaiApiKey", "sk-"+secrets.NewSecret(alphaNumeric("20"))+"T3BlbkFJ"+secrets.NewSecret(alphaNumeric("20"))),
|
||||
utils.GenerateSampleSecret("openaiApiKey", "sk-"+secrets.NewSecret(utils.AlphaNumeric("20"))+"T3BlbkFJ"+secrets.NewSecret(utils.AlphaNumeric("20"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
|
||||
// OpenShift 4 user tokens are prefixed with `sha256~`.
|
||||
// https://docs.redhat.com/en/documentation/openshift_container_platform/4.10/html-single/authentication_and_authorization/index#oauth-view-details-tokens_managing-oauth-access-tokens
|
||||
func OpenshiftUserToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "openshift-user-token",
|
||||
Description: "Found an OpenShift user token, potentially compromising an OpenShift/Kubernetes cluster.",
|
||||
// TODO: Do tokens vary in length or are they always 43?
|
||||
Regex: regexp.MustCompile(`\b(sha256~[\w-]{43})(?:[^\w-]|\z)`),
|
||||
Entropy: 3.5,
|
||||
SecretGroup: 0,
|
||||
Keywords: []string{
|
||||
"sha256~",
|
||||
},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
`Authorization: Bearer sha256~kV46hPnEYhCWFnB85r5NrprAxggzgb6GOeLbgcKNsH0`, // https://github.com/openshift/console/blob/edae2305e01c2e0e8c33727af720ef960088eee3/dynamic-demo-plugin/README.md?plain=1#L114
|
||||
`oc login --token=sha256~ZBMKw9VAayhdnyANaHvjJeXDiGwA7Fsr5gtLKj3-eh- `, // https://github.com/IBM/tekton-tutorial-openshift/blob/2a97d22ba282accad50821bca069210ea89de706/docs/lab1/0_setup.md?plain=1#L85
|
||||
"sha256~" + secrets.NewSecret(`[\w-]{43}`),
|
||||
}
|
||||
fps := []string{
|
||||
`--set kraken.kubeconfig.token.token="sha256~XXXXXXXXXX_PUT_YOUR_TOKEN_HERE_XXXXXXXXXXXX" \`, // https://github.com/krkn-chaos/krkn/blob/f3933f0e6239824eb9b5c46ff0e5d503b8465d6a/docs/index.md?plain=1#L307
|
||||
`oc login --token=sha256~_xxxxxx_xxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxx-X \
|
||||
--server=https://api.${zone}.appuio.cloud:6443`,
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
@@ -12,7 +13,7 @@ func PlaidAccessID() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "plaid-client-id",
|
||||
Description: "Uncovered a Plaid Client ID, which could lead to unauthorized financial service integrations and data breaches.",
|
||||
Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("24"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"plaid"}, utils.AlphaNumeric("24"), true),
|
||||
|
||||
Entropy: 3.5,
|
||||
Keywords: []string{
|
||||
@@ -22,9 +23,9 @@ func PlaidAccessID() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("plaid", secrets.NewSecret(alphaNumeric("24"))),
|
||||
utils.GenerateSampleSecret("plaid", secrets.NewSecret(utils.AlphaNumeric("24"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func PlaidSecretKey() *config.Rule {
|
||||
@@ -32,7 +33,7 @@ func PlaidSecretKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "plaid-secret-key",
|
||||
Description: "Detected a Plaid Secret key, risking unauthorized access to financial accounts and sensitive transaction data.",
|
||||
Regex: generateSemiGenericRegex([]string{"plaid"}, alphaNumeric("30"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"plaid"}, utils.AlphaNumeric("30"), true),
|
||||
|
||||
Entropy: 3.5,
|
||||
Keywords: []string{
|
||||
@@ -42,9 +43,9 @@ func PlaidSecretKey() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("plaid", secrets.NewSecret(alphaNumeric("30"))),
|
||||
utils.GenerateSampleSecret("plaid", secrets.NewSecret(utils.AlphaNumeric("30"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func PlaidAccessToken() *config.Rule {
|
||||
@@ -52,8 +53,8 @@ func PlaidAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "plaid-api-token",
|
||||
Description: "Discovered a Plaid API Token, potentially compromising financial data aggregation and banking services.",
|
||||
Regex: generateSemiGenericRegex([]string{"plaid"},
|
||||
fmt.Sprintf("access-(?:sandbox|development|production)-%s", hex8_4_4_4_12()), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"plaid"},
|
||||
fmt.Sprintf("access-(?:sandbox|development|production)-%s", utils.Hex8_4_4_4_12()), true),
|
||||
|
||||
Keywords: []string{
|
||||
"plaid",
|
||||
@@ -62,7 +63,7 @@ func PlaidAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("plaid", secrets.NewSecret(fmt.Sprintf("access-(?:sandbox|development|production)-%s", hex8_4_4_4_12()))),
|
||||
utils.GenerateSampleSecret("plaid", secrets.NewSecret(fmt.Sprintf("access-(?:sandbox|development|production)-%s", utils.Hex8_4_4_4_12()))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func PlanetScalePassword() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "planetscale-password",
|
||||
Description: "Discovered a PlanetScale password, which could lead to unauthorized database operations and data breaches.",
|
||||
Regex: generateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`pscale_pw_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"pscale_pw_",
|
||||
@@ -19,11 +20,11 @@ func PlanetScalePassword() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("32"))),
|
||||
generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
||||
generateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(alphaNumericExtended("64"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_pw_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func PlanetScaleAPIToken() *config.Rule {
|
||||
@@ -31,7 +32,7 @@ func PlanetScaleAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "planetscale-api-token",
|
||||
Description: "Identified a PlanetScale API token, potentially compromising database management and operations.",
|
||||
Regex: generateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`pscale_tkn_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"pscale_tkn_",
|
||||
@@ -40,11 +41,11 @@ func PlanetScaleAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("32"))),
|
||||
generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
||||
generateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(alphaNumericExtended("64"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_tkn_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func PlanetScaleOAuthToken() *config.Rule {
|
||||
@@ -52,7 +53,7 @@ func PlanetScaleOAuthToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "planetscale-oauth-token",
|
||||
Description: "Found a PlanetScale OAuth token, posing a risk to database access control and sensitive data integrity.",
|
||||
Regex: generateUniqueTokenRegex(`pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`pscale_oauth_(?i)[a-z0-9=\-_\.]{32,64}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"pscale_oauth_",
|
||||
@@ -61,9 +62,9 @@ func PlanetScaleOAuthToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(alphaNumericExtended("32"))),
|
||||
generateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(alphaNumericExtended("43"))),
|
||||
generateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(alphaNumericExtended("64"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("32"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("43"))),
|
||||
utils.GenerateSampleSecret("planetScalePassword", "pscale_oauth_"+secrets.NewSecret(utils.AlphaNumericExtended("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func PostManAPI() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "postman-api-token",
|
||||
Description: "Uncovered a Postman API token, potentially compromising API testing and development workflows.",
|
||||
Regex: generateUniqueTokenRegex(`PMAK-(?i)[a-f0-9]{24}\-[a-f0-9]{34}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`PMAK-(?i)[a-f0-9]{24}\-[a-f0-9]{34}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"PMAK-",
|
||||
@@ -19,7 +20,7 @@ func PostManAPI() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("postmanAPItoken", "PMAK-"+secrets.NewSecret(hex("24"))+"-"+secrets.NewSecret(hex("34"))),
|
||||
utils.GenerateSampleSecret("postmanAPItoken", "PMAK-"+secrets.NewSecret(utils.Hex("24"))+"-"+secrets.NewSecret(utils.Hex("34"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func Prefect() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "prefect-api-token",
|
||||
Description: "Detected a Prefect API token, risking unauthorized access to workflow management and automation services.",
|
||||
Regex: generateUniqueTokenRegex(`pnu_[a-z0-9]{36}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`pnu_[a-z0-9]{36}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"pnu_",
|
||||
@@ -19,7 +20,7 @@ func Prefect() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("api-token", "pnu_"+secrets.NewSecret(alphaNumeric("36"))),
|
||||
utils.GenerateSampleSecret("api-token", "pnu_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
@@ -11,7 +12,7 @@ func PrivateKey() *config.Rule {
|
||||
r := config.Rule{
|
||||
Description: "Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.",
|
||||
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(?: BLOCK)?----`),
|
||||
Keywords: []string{"-----BEGIN"},
|
||||
}
|
||||
|
||||
@@ -27,5 +28,5 @@ abcdefghijklmnopqrstuvwxyz
|
||||
anything
|
||||
-----END PRIVATE KEY BLOCK-----`,
|
||||
} // gitleaks:allow
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func PulumiAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "pulumi-api-token",
|
||||
Description: "Found a Pulumi API token, posing a risk to infrastructure as code services and cloud resource management.",
|
||||
Regex: generateUniqueTokenRegex(`pul-[a-f0-9]{40}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`pul-[a-f0-9]{40}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"pul-",
|
||||
@@ -19,7 +20,7 @@ func PulumiAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("pulumi-api-token", "pul-"+secrets.NewSecret(hex("40"))),
|
||||
utils.GenerateSampleSecret("pulumi-api-token", "pul-"+secrets.NewSecret(utils.Hex("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"regexp"
|
||||
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
@@ -20,7 +21,7 @@ func PyPiUploadToken() *config.Rule {
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{"pypiToken := \"pypi-AgEIcHlwaS5vcmc" + secrets.NewSecret(hex("32")) +
|
||||
secrets.NewSecret(hex("32")) + "\""}
|
||||
return validate(r, tps, nil)
|
||||
tps := []string{"pypiToken := \"pypi-AgEIcHlwaS5vcmc" + secrets.NewSecret(utils.Hex("32")) +
|
||||
secrets.NewSecret(utils.Hex("32")) + "\""}
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,8 +11,8 @@ func RapidAPIAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "rapidapi-access-token",
|
||||
Description: "Uncovered a RapidAPI Access Token, which could lead to unauthorized access to various APIs and data services.",
|
||||
Regex: generateSemiGenericRegex([]string{"rapidapi"},
|
||||
alphaNumericExtendedShort("50"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"rapidapi"},
|
||||
utils.AlphaNumericExtendedShort("50"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"rapidapi",
|
||||
@@ -20,8 +21,8 @@ func RapidAPIAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("rapidapi",
|
||||
secrets.NewSecret(alphaNumericExtendedShort("50"))),
|
||||
utils.GenerateSampleSecret("rapidapi",
|
||||
secrets.NewSecret(utils.AlphaNumericExtendedShort("50"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func ReadMe() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "readme-api-token",
|
||||
Description: "Detected a Readme API token, risking unauthorized documentation management and content exposure.",
|
||||
Regex: generateUniqueTokenRegex(`rdme_[a-z0-9]{70}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`rdme_[a-z0-9]{70}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"rdme_",
|
||||
@@ -19,7 +20,7 @@ func ReadMe() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("api-token", "rdme_"+secrets.NewSecret(alphaNumeric("70"))),
|
||||
utils.GenerateSampleSecret("api-token", "rdme_"+secrets.NewSecret(utils.AlphaNumeric("70"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func RubyGemsAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "rubygems-api-token",
|
||||
Description: "Identified a Rubygem API token, potentially compromising Ruby library distribution and package management.",
|
||||
Regex: generateUniqueTokenRegex(`rubygems_[a-f0-9]{48}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`rubygems_[a-f0-9]{48}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"rubygems_",
|
||||
@@ -19,7 +20,7 @@ func RubyGemsAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("rubygemsAPIToken", "rubygems_"+secrets.NewSecret(hex("48"))),
|
||||
utils.GenerateSampleSecret("rubygemsAPIToken", "rubygems_"+secrets.NewSecret(utils.Hex("48"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
"github.com/zricethezav/gitleaks/v8/detect"
|
||||
)
|
||||
|
||||
const (
|
||||
// case insensitive prefix
|
||||
caseInsensitive = `(?i)`
|
||||
|
||||
// identifier prefix (just an ignore group)
|
||||
identifierCaseInsensitivePrefix = `(?i:`
|
||||
identifierCaseInsensitiveSuffix = `)`
|
||||
identifierPrefix = `(?:`
|
||||
identifierSuffix = `)(?:[0-9a-z\-_\t .]{0,20})(?:[\s|']|[\s|"]){0,3}`
|
||||
|
||||
// commonly used assignment operators or function call
|
||||
operator = `(?:=|>|:{1,3}=|\|\|:|<=|=>|:|\?=)`
|
||||
|
||||
// boundaries for the secret
|
||||
// \x60 = `
|
||||
secretPrefixUnique = `\b(`
|
||||
secretPrefix = `(?:'|\"|\s|=|\x60){0,5}(`
|
||||
secretSuffix = `)(?:['|\"|\n|\r|\s|\x60|;]|$)`
|
||||
)
|
||||
|
||||
func generateSemiGenericRegex(identifiers []string, secretRegex string, isCaseInsensitive bool) *regexp.Regexp {
|
||||
var sb strings.Builder
|
||||
// The identifiers should always be case-insensitive.
|
||||
// This is inelegant but prevents an extraneous `(?i:)` from being added to the pattern; it could be removed.
|
||||
if isCaseInsensitive {
|
||||
sb.WriteString(caseInsensitive)
|
||||
writeIdentifiers(&sb, identifiers)
|
||||
} else {
|
||||
sb.WriteString(identifierCaseInsensitivePrefix)
|
||||
writeIdentifiers(&sb, identifiers)
|
||||
sb.WriteString(identifierCaseInsensitiveSuffix)
|
||||
}
|
||||
sb.WriteString(operator)
|
||||
sb.WriteString(secretPrefix)
|
||||
sb.WriteString(secretRegex)
|
||||
sb.WriteString(secretSuffix)
|
||||
return regexp.MustCompile(sb.String())
|
||||
}
|
||||
|
||||
func writeIdentifiers(sb *strings.Builder, identifiers []string) {
|
||||
sb.WriteString(identifierPrefix)
|
||||
sb.WriteString(strings.Join(identifiers, "|"))
|
||||
sb.WriteString(identifierSuffix)
|
||||
}
|
||||
|
||||
func generateUniqueTokenRegex(secretRegex string, isCaseInsensitive bool) *regexp.Regexp {
|
||||
var sb strings.Builder
|
||||
if isCaseInsensitive {
|
||||
sb.WriteString(caseInsensitive)
|
||||
}
|
||||
sb.WriteString(secretPrefixUnique)
|
||||
sb.WriteString(secretRegex)
|
||||
sb.WriteString(secretSuffix)
|
||||
return regexp.MustCompile(sb.String())
|
||||
}
|
||||
|
||||
func generateSampleSecret(identifier string, secret string) string {
|
||||
return fmt.Sprintf("%s_api_token = \"%s\"", identifier, secret)
|
||||
}
|
||||
|
||||
func validate(r config.Rule, truePositives []string, falsePositives []string) *config.Rule {
|
||||
// normalize keywords like in the config package
|
||||
var keywords []string
|
||||
for _, k := range r.Keywords {
|
||||
keywords = append(keywords, strings.ToLower(k))
|
||||
}
|
||||
r.Keywords = keywords
|
||||
|
||||
rules := make(map[string]config.Rule)
|
||||
rules[r.RuleID] = r
|
||||
d := detect.NewDetector(config.Config{
|
||||
Rules: rules,
|
||||
Keywords: keywords,
|
||||
})
|
||||
for _, tp := range truePositives {
|
||||
if len(d.DetectString(tp)) != 1 {
|
||||
log.Fatal().Msgf("Failed to validate. For rule ID [%s], true positive [%s] was not detected by regexp [%s]", r.RuleID, tp, r.Regex)
|
||||
}
|
||||
}
|
||||
for _, fp := range falsePositives {
|
||||
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)
|
||||
}
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func validateWithPaths(r config.Rule, truePositives map[string]string, falsePositives map[string]string) *config.Rule {
|
||||
var keywords []string
|
||||
for _, k := range r.Keywords {
|
||||
keywords = append(keywords, strings.ToLower(k))
|
||||
}
|
||||
r.Keywords = keywords
|
||||
|
||||
rules := make(map[string]config.Rule)
|
||||
rules[r.RuleID] = r
|
||||
d := detect.NewDetector(config.Config{
|
||||
Rules: rules,
|
||||
Keywords: keywords,
|
||||
})
|
||||
for path, tp := range truePositives {
|
||||
f := detect.Fragment{Raw: tp, FilePath: path}
|
||||
if len(d.Detect(f)) != 1 {
|
||||
log.Fatal().Msgf("Failed to validate. For rule ID [%s], true positive [%s] in %s was not detected by regexp [%s] path [%s]", r.RuleID, tp, path, r.Regex, r.Path)
|
||||
}
|
||||
}
|
||||
for path, fp := range falsePositives {
|
||||
f := detect.Fragment{Raw: fp, FilePath: path}
|
||||
if len(d.Detect(f)) != 0 {
|
||||
log.Fatal().Msgf("Failed to validate. For rule ID [%s], false positive [%s] in %s was detected by regexp [%s] path [%s]", r.RuleID, fp, path, r.Regex, r.Path)
|
||||
}
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
func numeric(size string) string {
|
||||
return fmt.Sprintf(`[0-9]{%s}`, size)
|
||||
}
|
||||
|
||||
func hex(size string) string {
|
||||
return fmt.Sprintf(`[a-f0-9]{%s}`, size)
|
||||
}
|
||||
|
||||
func alphaNumeric(size string) string {
|
||||
return fmt.Sprintf(`[a-z0-9]{%s}`, size)
|
||||
}
|
||||
|
||||
func alphaNumericExtendedShort(size string) string {
|
||||
return fmt.Sprintf(`[a-z0-9_-]{%s}`, size)
|
||||
}
|
||||
|
||||
func alphaNumericExtended(size string) string {
|
||||
return fmt.Sprintf(`[a-z0-9=_\-]{%s}`, size)
|
||||
}
|
||||
|
||||
func alphaNumericExtendedLong(size string) string {
|
||||
return fmt.Sprintf(`[a-z0-9\/=_\+\-]{%s}`, size)
|
||||
}
|
||||
|
||||
func hex8_4_4_4_12() string {
|
||||
return `[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,14 +11,14 @@ func ScalingoAPIToken() *config.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: generateUniqueTokenRegex(`tk-us-[a-zA-Z0-9-_]{48}`, false),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`tk-us-[a-zA-Z0-9-_]{48}`, false),
|
||||
Keywords: []string{"tk-us-"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("scalingo", "tk-us-"+secrets.NewSecret(alphaNumericExtendedShort("48"))),
|
||||
utils.GenerateSampleSecret("scalingo", "tk-us-"+secrets.NewSecret(utils.AlphaNumericExtendedShort("48"))),
|
||||
`scalingo_api_token = "tk-us-loys7ib9yrxcys_ta2sq85mjar6lgcsspkd9x61s7h5epf_-"`, // gitleaks:allow
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func SendbirdAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "sendbird-access-token",
|
||||
Description: "Uncovered a Sendbird Access Token, potentially risking unauthorized access to communication services and user data.",
|
||||
Regex: generateSemiGenericRegex([]string{"sendbird"}, hex("40"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"sendbird"}, utils.Hex("40"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"sendbird",
|
||||
@@ -19,9 +20,9 @@ func SendbirdAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("sendbird", secrets.NewSecret(hex("40"))),
|
||||
utils.GenerateSampleSecret("sendbird", secrets.NewSecret(utils.Hex("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
|
||||
func SendbirdAccessID() *config.Rule {
|
||||
@@ -29,7 +30,7 @@ func SendbirdAccessID() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "sendbird-access-id",
|
||||
Description: "Discovered a Sendbird Access ID, which could compromise chat and messaging platform integrations.",
|
||||
Regex: generateSemiGenericRegex([]string{"sendbird"}, hex8_4_4_4_12(), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"sendbird"}, utils.Hex8_4_4_4_12(), true),
|
||||
|
||||
Keywords: []string{
|
||||
"sendbird",
|
||||
@@ -38,7 +39,7 @@ func SendbirdAccessID() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("sendbird", secrets.NewSecret(hex8_4_4_4_12())),
|
||||
utils.GenerateSampleSecret("sendbird", secrets.NewSecret(utils.Hex8_4_4_4_12())),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func SendGridAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "sendgrid-api-token",
|
||||
Description: "Detected a SendGrid API token, posing a risk of unauthorized email service operations and data exposure.",
|
||||
Regex: generateUniqueTokenRegex(`SG\.(?i)[a-z0-9=_\-\.]{66}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`SG\.(?i)[a-z0-9=_\-\.]{66}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"SG.",
|
||||
@@ -19,7 +20,7 @@ func SendGridAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("sengridAPIToken", "SG."+secrets.NewSecret(alphaNumericExtended("66"))),
|
||||
utils.GenerateSampleSecret("sengridAPIToken", "SG."+secrets.NewSecret(utils.AlphaNumericExtended("66"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func SendInBlueAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "sendinblue-api-token",
|
||||
Description: "Identified a Sendinblue API token, which may compromise email marketing services and subscriber data privacy.",
|
||||
Regex: generateUniqueTokenRegex(`xkeysib-[a-f0-9]{64}\-(?i)[a-z0-9]{16}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`xkeysib-[a-f0-9]{64}\-(?i)[a-z0-9]{16}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"xkeysib-",
|
||||
@@ -19,7 +20,7 @@ func SendInBlueAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("sendinblue", "xkeysib-"+secrets.NewSecret(hex("64"))+"-"+secrets.NewSecret(alphaNumeric("16"))),
|
||||
utils.GenerateSampleSecret("sendinblue", "xkeysib-"+secrets.NewSecret(utils.Hex("64"))+"-"+secrets.NewSecret(utils.AlphaNumeric("16"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func SentryAccessToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "sentry-access-token",
|
||||
Description: "Found a Sentry Access Token, risking unauthorized access to error tracking services and sensitive application data.",
|
||||
Regex: generateSemiGenericRegex([]string{"sentry"}, hex("64"), true),
|
||||
Regex: utils.GenerateSemiGenericRegex([]string{"sentry"}, utils.Hex("64"), true),
|
||||
|
||||
Keywords: []string{
|
||||
"sentry",
|
||||
@@ -19,7 +20,7 @@ func SentryAccessToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("sentry", secrets.NewSecret(hex("64"))),
|
||||
utils.GenerateSampleSecret("sentry", secrets.NewSecret(utils.Hex("64"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package rules
|
||||
|
||||
import (
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ func ShippoAPIToken() *config.Rule {
|
||||
r := config.Rule{
|
||||
RuleID: "shippo-api-token",
|
||||
Description: "Discovered a Shippo API token, potentially compromising shipping services and customer order data.",
|
||||
Regex: generateUniqueTokenRegex(`shippo_(live|test)_[a-f0-9]{40}`, true),
|
||||
Regex: utils.GenerateUniqueTokenRegex(`shippo_(live|test)_[a-f0-9]{40}`, true),
|
||||
|
||||
Keywords: []string{
|
||||
"shippo_",
|
||||
@@ -19,8 +20,8 @@ func ShippoAPIToken() *config.Rule {
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
generateSampleSecret("shippo", "shippo_live_"+secrets.NewSecret(hex("40"))),
|
||||
generateSampleSecret("shippo", "shippo_test_"+secrets.NewSecret(hex("40"))),
|
||||
utils.GenerateSampleSecret("shippo", "shippo_live_"+secrets.NewSecret(utils.Hex("40"))),
|
||||
utils.GenerateSampleSecret("shippo", "shippo_test_"+secrets.NewSecret(utils.Hex("40"))),
|
||||
}
|
||||
return validate(r, tps, nil)
|
||||
return utils.Validate(r, tps, nil)
|
||||
}
|
||||
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user