Compare commits

...
29 Commits
Author SHA1 Message Date
Zachary Rice 9463ffaa5e fix flag access (#1506) 2024-09-14 04:01:27 -05:00
Zachary Rice 44ad62e0b1 Deprecate detect and protect. Add git, dir, stdin (#1504)
* init backwards compatible cmd

* update readme, todos

* ...

* moar comments, sprucing up root

* readme change
2024-09-13 19:44:22 -05:00
Dewan Ishtiaque Ahmed e93a7c0d26 Update Harness rules to add _ and - in the account ID part. (#1503) 2024-09-11 19:48:12 -05:00
Richard Gomez 4e43d11093 chore: fix gl workflow error (#1487) 2024-08-26 17:47:02 -05:00
Richard Gomez bd81872eee Make config generation utils public (#1480)
* chore(generate): make utils public

* chore(generate): change validate log messages

* chore(generate): split functions into files

* chore(config): add warning for public funcs
2024-08-26 13:11:18 -05:00
Richard Gomez 3be7faa1ff Update Hashicorp Vault token pattern (#1483)
* feat(vault): add old pat, tweak new pat

* feat(hashicorp): add entropy to tf rule
2024-08-25 15:19:37 -05:00
Richard Gomez 1aae66d564 feat(config): update rule validation (#1466) 2024-08-22 09:55:44 -05:00
Zachary Rice 6dfcf5e949 Update .gitleaksignore 2024-08-20 06:57:30 -05:00
Richard Gomez f361c5ef71 fix(detect): handle EOF with bytes (#1472) 2024-08-19 14:00:47 -05:00
malmor 8a1ca9ecc9 Added poetry.lock to default allowlist paths (#1474) 2024-08-19 11:47:42 -05:00
Richard Gomez 525c4b4451 refactor(sarif): remove |name| and change |shortDescription| (#1473) 2024-08-19 09:11:31 -05:00
Richard Gomez c0fda4358e Use rule id for config validation error (#1463)
* chore(config): use rule id for error

* feat(config): ensure rule.id is not empty
2024-08-08 15:47:34 -05:00
Richard Gomez d3c4b9078e Use first non-empty group if secretGroup isn't set (#1459)
* feat(detect): secret is first non-empty group

* test: fix errors

- update capture groups
- update expected data
2024-08-07 12:10:05 -05:00
Richard Gomez b4009bfba4 chore: remove unnecessary capture groups (#1460) 2024-08-07 12:09:16 -05:00
Richard Gomez 80bd1779e3 Return non-0 exit code from DetectGit (#1461)
* fix(detect): exit code for git errors

* chore(detect): add consistent error msgs
2024-08-07 10:14:00 -05:00
niklas-w7andniklas.w 0334ec1076 add gradle verification-metadata.xml to global allowlist (#1446)
Co-authored-by: niklas.w <niklas.wissmueller@ext.ibmix.de>
2024-08-05 20:35:54 -05:00
Richard Gomez c1345e1b2b feat(openshift): add user token (#1449) 2024-08-05 20:22:31 -05:00
LeonandZach 7697b3e989 (feat): Adding secret detection rule for Kubernetes secrets (#1454)
* (feat): Adding secret detection rule for Kubernetes secrets

Signed-off-by: localleon <me@lrau.xyz>

* (fix): Limiting kubernetes secret detection only to .yaml/.yml files

Signed-off-by: localleon <me@lrau.xyz>

* (fix): Fixing path validation testing for kubernetes-secret

Signed-off-by: localleon <me@lrau.xyz>

* (fix): refactoring path validation regex for kubernetes secret

* (fix): fixing keyword for kubernetes secret

Signed-off-by: localleon <me@lrau.xyz>

* (fix): fixing config.toml for kubernetes-secret and reording rules/main.go

Signed-off-by: localleon <me@lrau.xyz>

* (feat): Implementing proxmitiy matching for data-key in kubernetes secrets

Signed-off-by: localleon <me@lrau.xyz>

* (fix): Adding regex sugestions for quoted strings and qouted test-cases

* (fix): Updating kubernetes-secret regex to allow '-character before secret e.g if theres quoting

* limit whitespace

---------

Signed-off-by: localleon <me@lrau.xyz>
Co-authored-by: Zach <zricer@protonmail.com>
2024-08-05 20:20:52 -05:00
Zachary Rice 26f34692fa add version to default 2024-06-14 16:48:12 -04:00
AislingHPE bc979deb0f Add go.work and go.work.sum to global allowlist (#1353) 2024-06-14 15:31:04 -04:00
Dewan Ishtiaque AhmedandZachary Rice b899915813 Add harness PAT and SAT rules (#1406)
* Add Harness PAT rule.

* Add support for Harness PAT and SAT.

* Update comment for Harness SAT.

* Consolidate PAT and SAT into Harness API Key

* add ignore and capture group to match

---------

Co-authored-by: Zachary Rice <zachary.rice@trufflesec.com>
2024-06-14 15:30:07 -04:00
Zachary Rice 4c5195b700 Update README.md 2024-06-14 15:22:23 -04:00
becojoandBecojo 02808f45d0 Limit hashicorp-tf-password to .tf/.hcl files (#1420)
* Limit hashicorp-tf-password to .tf/.hcl files

* fix tests

---------

Co-authored-by: Becojo <Becojo@users.noreply.github.com>
2024-06-13 11:23:26 -04:00
Zachary Rice 07e1c30592 rm print 2024-06-13 11:14:44 -04:00
Zachary Rice db63fc1bf4 reduce telegram... todo url and xml for later 2024-06-13 11:14:02 -04:00
Zachary Rice 9a4538c4d6 coderabbit.ai <3 2024-06-13 09:16:17 -04:00
danielap-ma fe94ef9ca3 Add NewRelic insert key detection (#1417) 2024-06-02 18:18:52 -05:00
Toxandtoxyl bb4424d454 Improved Telegram bot token rule regex and added more test cases (#1404)
Co-authored-by: toxyl <tox@novasonica.com>
2024-06-01 18:56:14 -05:00
Alexandre GUIOT--VALENTIN 575e923cf8 Add intra42 client secret (#1408)
intra42 is the intranet and API of "42 School", a CS school.
The API is open to all students in 57 campus around the world.
It is thus often subject to credentials leaks on GitHub
See https://42.fr and https://api.intra.42.fr/
2024-06-01 18:55:04 -05:00
138 changed files with 1711 additions and 942 deletions

No files matched your search

+1
View File
@@ -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
+53 -51
View File
@@ -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,13 +197,13 @@ 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.
@@ -402,13 +398,19 @@ class CustomClass:
You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. Note: this feature is experimental and is subject to change in the future.
## Sponsorships
<p align="left">
<h3><a href="https://coderabbit.ai/?utm_source=oss&utm_medium=sponsorship&utm_campaign=gitleaks">coderabbit.ai</h3>
<a href="https://coderabbit.ai/?utm_source=oss&utm_medium=sponsorship&utm_campaign=gitleaks">
<img alt="CodeRabbit.ai Sponsorship" src="https://github.com/gitleaks/gitleaks/assets/15034943/76c30a85-887b-47ca-9956-17a8e55c6c41" width=200>
</a>
</p>
<p align="left">
<a href="https://www.tines.com/?utm_source=oss&utm_medium=sponsorship&utm_campaign=gitleaks">
<img alt="Tines Sponsorship" src="https://user-images.githubusercontent.com/15034943/146411864-4878f936-b4f7-49a0-b625-f9f40c704bfa.png" width=200>
</a>
</p>
## Exit Codes
You can always set the exit code when leaks are encountered with the --exit-code flag. Default exit codes below:
+51 -22
View File
@@ -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)
}
+68
View File
@@ -0,0 +1,68 @@
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)
}
+7 -1
View File
@@ -99,18 +99,22 @@ func main() {
rules.GrafanaApiKey(),
rules.GrafanaCloudApiToken(),
rules.GrafanaServiceAccountToken(),
rules.Hashicorp(),
rules.HarnessApiKey(),
rules.HashiCorpTerraform(),
rules.HashicorpField(),
rules.Heroku(),
rules.HubSpot(),
rules.HuggingFaceAccessToken(),
rules.HuggingFaceOrganizationApiToken(),
rules.Intercom(),
rules.Intra42ClientSecret(),
rules.JFrogAPIKey(),
rules.JFrogIdentityToken(),
rules.JWT(),
rules.JWTBase64(),
rules.KrakenAccessToken(),
rules.KubernetesSecretWithDataAfter(),
rules.KubernetesSecretWithDataBefore(),
rules.KucoinAccessToken(),
rules.KucoinSecretKey(),
rules.LaunchDarklyAccessToken(),
@@ -132,10 +136,12 @@ func main() {
rules.NewRelicUserID(),
rules.NewRelicUserKey(),
rules.NewRelicBrowserAPIKey(),
rules.NewRelicInsertKey(),
rules.NPM(),
rules.NytimesAccessToken(),
rules.OktaAccessToken(),
rules.OpenAI(),
rules.OpenshiftUserToken(),
rules.PlaidAccessID(),
rules.PlaidSecretKey(),
rules.PlaidAccessToken(),
+4 -3
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+2 -1
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+8 -7
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+6 -5
View File
@@ -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)
}
+8 -7
View File
@@ -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)
}
+3 -2
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+6 -5
View File
@@ -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)
}
+4 -2
View File
@@ -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
@@ -15,12 +15,14 @@ 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)$''',
'''(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''',
]
+7 -6
View File
@@ -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)
}
+5 -4
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+5 -4
View File
@@ -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)
}
+10 -9
View File
@@ -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)
}
+10 -9
View File
@@ -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)
}
+4 -3
View File
@@ -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:
+4 -3
View File
@@ -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)
}
+6 -5
View File
@@ -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"},
}
+4 -3
View File
@@ -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)
}
+3 -2
View File
@@ -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)
}
+5 -4
View File
@@ -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)
}
+4 -3
View File
@@ -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 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{"etsy"}, utils.AlphaNumeric("24"), true),
Keywords: []string{
"etsy",
@@ -19,7 +20,7 @@ func EtsyAccessToken() *config.Rule {
// validate
tps := []string{
generateSampleSecret("etsy", secrets.NewSecret(alphaNumeric("24"))),
utils.GenerateSampleSecret("etsy", secrets.NewSecret(utils.AlphaNumeric("24"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
+8 -7
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+3 -2
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+5 -4
View File
@@ -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,7 +30,7 @@ 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[0-9A-Za-z\\-_]{35}`, true),
Keywords: []string{
"AIza",
@@ -38,7 +39,7 @@ func GCPAPIKey() *config.Rule {
// validate
tps := []string{
generateSampleSecret("gcp", secrets.NewSecret(`AIza[0-9A-Za-z\\-_]{35}`)),
utils.GenerateSampleSecret("gcp", secrets.NewSecret(`AIza[0-9A-Za-z\\-_]{35}`)),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
+5 -4
View File
@@ -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)
}
+13 -12
View File
@@ -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 GitHubPat() *config.Rule {
// validate
tps := []string{
generateSampleSecret("github", "ghp_"+secrets.NewSecret(alphaNumeric("36"))),
utils.GenerateSampleSecret("github", "ghp_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
func GitHubFineGrainedPat() *config.Rule {
@@ -34,9 +35,9 @@ func GitHubFineGrainedPat() *config.Rule {
// 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)
return utils.Validate(r, tps, nil)
}
func GitHubOauth() *config.Rule {
@@ -50,9 +51,9 @@ func GitHubOauth() *config.Rule {
// validate
tps := []string{
generateSampleSecret("github", "gho_"+secrets.NewSecret(alphaNumeric("36"))),
utils.GenerateSampleSecret("github", "gho_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
func GitHubApp() *config.Rule {
@@ -60,16 +61,16 @@ 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}`),
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)
return utils.Validate(r, tps, nil)
}
func GitHubRefresh() *config.Rule {
@@ -83,7 +84,7 @@ func GitHubRefresh() *config.Rule {
// validate
tps := []string{
generateSampleSecret("github", "ghr_"+secrets.NewSecret(alphaNumeric("36"))),
utils.GenerateSampleSecret("github", "ghr_"+secrets.NewSecret(utils.AlphaNumeric("36"))),
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
+7 -6
View File
@@ -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)
}
+6 -5
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+14 -13
View File
@@ -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)
}
+29
View File
@@ -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)
}
+21 -12
View File
@@ -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,19 +36,22 @@ 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(`(?i)\.(?:tf|hcl)$`),
}
tps := []string{
tps := map[string]string{
// Example from: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_server.html
"administrator_login_password = " + `"thisIsDog11"`,
"file.tf": "administrator_login_password = " + `"thisIsDog11"`,
// https://registry.terraform.io/providers/petoju/mysql/latest/docs
"password = " + `"rootpasswd"`,
"file.hcl": "password = " + `"rootpasswd"`,
}
fps := []string{
"administrator_login_password = var.db_password",
`password = "${aws_db_instance.default.password}"`,
fps := map[string]string{
"file.tf": "administrator_login_password = var.db_password",
"file.hcl": `password = "${aws_db_instance.default.password}"`,
"unrelated.js": "password = " + `"rootpasswd"`,
}
return validate(r, tps, fps)
return utils.ValidateWithPaths(r, tps, fps)
}
+3 -2
View File
@@ -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)
}
+3 -2
View File
@@ -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)
}
+3 -2
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+30
View File
@@ -0,0 +1,30 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)
func Intra42ClientSecret() *config.Rule {
// define 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: utils.GenerateUniqueTokenRegex(`s-s4t2(?:ud|af)-[abcdef0123456789]{64}`, true),
Keywords: []string{
"intra",
"s-s4t2ud-",
"s-s4t2af-",
},
}
// validate
tps := []string{
"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 utils.Validate(r, tps, nil)
}
+10 -9
View File
@@ -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)
}
+4 -3
View File
@@ -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 {
+6 -5
View File
@@ -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)
}
+69
View File
@@ -0,0 +1,69 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"regexp"
"github.com/zricethezav/gitleaks/v8/config"
)
// The kubernetes rules are split into two functions to make the complex proximity matching of the data-key and the kind-identifier more readable and testable
// KubernetesSecretWithDataBefore validates if we detected a kubernetes secret which contains data, before the resource identifier!
func KubernetesSecretWithDataBefore() *config.Rule {
// define rule
r := config.Rule{
RuleID: "kubernetes-secret-with-data-before",
Description: "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments",
// We try to match secrets by looking if we have the keyword
Regex: utils.GenerateUniqueTokenRegex(`(?i)(?:\b(?:data:))(\W+(?:\w+\W+){0,200}?)\bkind:.{0,10}Secret\b`, true),
Keywords: []string{
"Secret",
},
// Kubernetes secrets are always yaml files, we limit to common yaml-endings to make this rule more safe!
Path: regexp.MustCompile(`(?i)\.ya?ml$`),
}
// validate
tps := map[string]string{
// Sample Kubernetes Secret from https://kubernetes.io/docs/concepts/configuration/secret/
// These secrets contain the "data"-key before the actual identifier "kind: Secret"
"kubernetes.yaml": "apiVersion: v1'\n' data:'\n' extra: YmFyCg=='\n' kind: secret'\n' metadata:'\n' name: secret-sa-sample'\n' annotations:'\n' kubernetes.io/service-account.name: 'sa-name'", // gitleaks:allow
"kubernetes.yml": "apiVersion: v1'\n' data:'\n' password: UyFCXCpkJHpEc2I9'\n' username: YWRtaW4='\n' kind: Secret'\n' metadata:'\n' creationTimestamp: '2022-06-28T17:44:13Z''\n' name: db-user-pass'\n' namespace: default'\n' type: Opaque", // gitleaks:allow
// Quoted Test Cases
"kubernetes-quoted-1.yaml": "apiVersion: v1'\n' data:'\n' extra: YmFyCg=='\n' kind: 'Secret''\n' metadata:'\n' name: 'secret-sa-sample''\n' annotations:'\n' kubernetes.io/service-account.name: 'sa-name'", // gitleaks:allow
"kubernetes-quoted-2.yaml": "apiVersion: v1'\n' data:'\n' extra: YmFyCg=='\n' kind: 'secret''\n' metadata:'\n' name: 'secret-sa-sample''\n' annotations:'\n' kubernetes.io/service-account.name: 'sa-name'", // gitleaks:allow
}
return utils.ValidateWithPaths(r, tps, nil)
}
// KubernetesSecretWithDataAfter validates if we detected a kubernetes secret which contains data, after the resource identifier!
func KubernetesSecretWithDataAfter() *config.Rule {
// define rule
r := config.Rule{
RuleID: "kubernetes-secret-with-data-after",
Description: "Possible Kubernetes Secret detected, posing a risk of leaking credentials/tokens from your deployments",
// We try to match secrets by looking if we have the keyword
Regex: utils.GenerateUniqueTokenRegex(`(?i)(?:\bkind:.{0,10}Secret\b)(?:.|\s){0,200}?\b(?:data:)\s*(.+)`, true),
Keywords: []string{
"Secret",
},
// Kubernetes secrets are always yaml files, we limit to common yaml-endings to make this rule more safe!
Path: regexp.MustCompile(`(?i)\.ya?ml$`),
}
// validate
tps := map[string]string{
// Sample Kubernetes Secret from https://kubernetes.io/docs/concepts/configuration/secret/
// These secrets contain the data after the actual identifier "kind: Secret"
"kubernetes.yaml": "apiVersion: v1'\n' kind: secret'\n' data:'\n' extra: YmFyCg=='\n' metadata:'\n' name: secret-sa-sample'\n' annotations:'\n' kubernetes.io/service-account.name: 'sa-name'", // gitleaks:allow
"kubernetes.yml": "apiVersion: v1'\n' kind: Secret'\n' data:'\n' password: UyFCXCpkJHpEc2I9'\n' username: YWRtaW4='\n' metadata:'\n' creationTimestamp: '2022-06-28T17:44:13Z''\n' name: db-user-pass'\n' namespace: default'\n' type: Opaque", // gitleaks:allow
// Quoted Test Cases
"kubernetes-quoted-1.yaml": "apiVersion: v1'\n' kind: 'Secret''\n' data:'\n' password: UyFCXCpkJHpEc2I9'\n' username: YWRtaW4='\n' metadata:'\n' name: db-user-pass'\n' namespace: default'\n' type: Opaque", // gitleaks:allow
"kubernetes-quoted-2.yaml": "apiVersion: v1'\n' kind: 'secret''\n' data:'\n' password: UyFCXCpkJHpEc2I9'\n' username: YWRtaW4='\n' metadata:'\n' name: db-user-pass'\n' namespace: default'\n' type: Opaque", // gitleaks:allow
}
return utils.ValidateWithPaths(r, tps, nil)
}
+7 -6
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+6 -5
View File
@@ -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)
}
+9 -8
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+10 -9
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+10 -9
View File
@@ -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)
}
+5 -4
View File
@@ -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)
}
+34 -10
View File
@@ -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,7 +72,30 @@ 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 {
// define rule
r := config.Rule{
RuleID: "new-relic-insert-key",
Description: "Discovered a New Relic insight insert key, compromising data injection into the platform.",
Regex: utils.GenerateSemiGenericRegex([]string{
"new-relic",
"newrelic",
"new_relic",
}, `NRII-[a-z0-9-]{32}`, true),
Keywords: []string{
"NRII-",
},
}
// validate
tps := []string{
utils.GenerateSampleSecret("new-relic", "NRII-"+secrets.NewSecret(utils.Hex("32"))),
}
return utils.Validate(r, tps, nil)
}
+4 -3
View File
@@ -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)
}
+5 -4
View File
@@ -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)
}
+5 -4
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+38
View File
@@ -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)
}
+11 -10
View File
@@ -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)
}
+16 -15
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+3 -2
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+6 -5
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
-126
View File
@@ -1,126 +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 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}`
}
+4 -3
View File
@@ -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)
}
+7 -6
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+4 -3
View File
@@ -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)
}
+5 -4
View File
@@ -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)
}
+9 -8
View File
@@ -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"
@@ -17,8 +18,8 @@ func ShopifySharedSecret() *config.Rule {
}
// validate
tps := []string{"shopifySecret := \"shpss_" + secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps, nil)
tps := []string{"shopifySecret := \"shpss_" + secrets.NewSecret(utils.Hex("32")) + "\""}
return utils.Validate(r, tps, nil)
}
func ShopifyAccessToken() *config.Rule {
@@ -31,8 +32,8 @@ func ShopifyAccessToken() *config.Rule {
}
// validate
tps := []string{"shopifyToken := \"shpat_" + secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps, nil)
tps := []string{"shopifyToken := \"shpat_" + secrets.NewSecret(utils.Hex("32")) + "\""}
return utils.Validate(r, tps, nil)
}
func ShopifyCustomAccessToken() *config.Rule {
@@ -45,8 +46,8 @@ func ShopifyCustomAccessToken() *config.Rule {
}
// validate
tps := []string{"shopifyToken := \"shpca_" + secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps, nil)
tps := []string{"shopifyToken := \"shpca_" + secrets.NewSecret(utils.Hex("32")) + "\""}
return utils.Validate(r, tps, nil)
}
func ShopifyPrivateAppAccessToken() *config.Rule {
@@ -59,6 +60,6 @@ func ShopifyPrivateAppAccessToken() *config.Rule {
}
// validate
tps := []string{"shopifyToken := \"shppa_" + secrets.NewSecret(hex("32")) + "\""}
return validate(r, tps, nil)
tps := []string{"shopifyToken := \"shppa_" + secrets.NewSecret(utils.Hex("32")) + "\""}
return utils.Validate(r, tps, nil)
}
+5 -5
View File
@@ -1,6 +1,7 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"regexp"
"github.com/zricethezav/gitleaks/v8/config"
@@ -12,7 +13,7 @@ func SidekiqSecret() *config.Rule {
Description: "Discovered a Sidekiq Secret, which could lead to compromised background job processing and application data breaches.",
RuleID: "sidekiq-secret",
Regex: generateSemiGenericRegex([]string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
Regex: utils.GenerateSemiGenericRegex([]string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
`[a-f0-9]{8}:[a-f0-9]{8}`, true),
Keywords: []string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"},
}
@@ -28,7 +29,7 @@ func SidekiqSecret() *config.Rule {
"export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef;",
"export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef && echo 'hello world'",
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
func SidekiqSensitiveUrl() *config.Rule {
@@ -36,8 +37,7 @@ func SidekiqSensitiveUrl() *config.Rule {
r := config.Rule{
Description: "Uncovered a Sidekiq Sensitive URL, potentially exposing internal job queues and sensitive operation details.",
RuleID: "sidekiq-sensitive-url",
SecretGroup: 2,
Regex: regexp.MustCompile(`(?i)\b(http(?:s??):\/\/)([a-f0-9]{8}:[a-f0-9]{8})@(?:gems.contribsys.com|enterprise.contribsys.com)(?:[\/|\#|\?|:]|$)`),
Regex: regexp.MustCompile(`(?i)\bhttps?://([a-f0-9]{8}:[a-f0-9]{8})@(?:gems.contribsys.com|enterprise.contribsys.com)(?:[\/|\#|\?|:]|$)`),
Keywords: []string{"gems.contribsys.com", "enterprise.contribsys.com"},
}
@@ -56,5 +56,5 @@ func SidekiqSensitiveUrl() *config.Rule {
"http://cafeb4b3:d3adb33f@enterprise.contribsys.com:80",
"http://cafeb4b3:d3adb33f@enterprise.contribsys.com:80/path?param1=true&param2=false#heading1",
}
return validate(r, tps, nil)
return utils.Validate(r, tps, nil)
}
Loaded 100 of 138 files, more files were not shown because too many files have changed in this diff. Show more