Compare commits

...
75 Commits
Author SHA1 Message Date
Zachary Rice 5361c7c917 mhm (#1801) 2025-03-22 06:50:51 -05:00
Tom Payne 6cc0e386ac feat(regexp): use standard regexp by default, make go-re2 opt-in (#1798) 2025-03-20 19:48:18 -05:00
Zachary Rice b4df42364d Update README.md 2025-03-17 19:26:18 -05:00
Jesse Portnoy 4344b00934 Readme badge revisions (#1744)
* - Added badges:
    * Go docs
    * Go report card
    * License
- Replaced HTML code for badges with Markdown

* Amend CI badge
2025-03-17 16:08:57 -05:00
Zach f74ced7985 ignore 2025-03-12 20:30:06 -05:00
Zachary Rice c08cb1dc9a Fix decoded line allowlist (#1788)
* fix

* B patch

* buh bye
2025-03-12 20:16:16 -05:00
Nikolas Grottendieck 991a940412 Prevent Yocto/BitBake false positives with generic-api-key rule (#1783)
* fix: make config template work when providing non-iota values for MatchCondition

https://pkg.go.dev/text/template#hdr-Actions

> {{with pipeline}} T1 {{end}}
>	If the value of the pipeline is empty, no output is generated;
>	otherwise, dot is set to the value of the pipeline and T1 is
>	executed.

Within the `with` block `.MatchCondition` is implicit and must be omitted to
work. The fault/bug was not triggered before because this is the first
non-default MatchCondition apparently.

* feat: exclude false positive matches for Yocto/Bitbake from generic-api-key rule

Fixes #1775
2025-03-11 09:58:56 -05:00
Richard Gomez ade376ab77 feat(generic): ignore csrf-tokens (#1779) 2025-03-06 19:32:36 -06:00
Zach 1c81ae02fa leet and myspace 2025-03-02 21:00:13 -06:00
Zach e9b93c6033 report templates 2025-03-02 20:41:52 -06:00
Zachary Rice de105fca6d smdh 2025-03-02 20:25:21 -06:00
Richard Gomez a3be7222a6 feat(report): infer format from file extension (#1776) 2025-03-01 10:33:08 -06:00
Zachary Rice b44958220e Merge branch 'master' of github.com:gitleaks/gitleaks 2025-02-26 12:07:01 -06:00
Zachary Rice 2f6b9f72d1 tech influencer larp 2025-02-26 12:06:52 -06:00
Richard Gomez 3fdc9c13d2 build: upgrade rs/zerolog, spf13/cobra, and spf13/viper (#1769)
This eliminates golang.org/x/text@v0.3.0 from the dependency chain, which is associated with a critical CVE that can cause Gitleaks to be flagged in regulated environments.
2025-02-24 08:50:31 -06:00
Christophe GoessenandChristophe Goessen 96b92c3d07 fix: upgrade x/crypto to 0.31.0 to get rid of CVE-2024-45337 (#1768)
Co-authored-by: Christophe Goessen <christophe@gssn.net>
2025-02-24 08:42:05 -06:00
bplaxco f6a7439306 Make AddFindings public (#1767)
- Rename d.addFindings -> d.AddFindings
- Add d.Findings()

To allow other tools using d.Detect() to leverage the code in
AddFindings
2025-02-24 08:28:06 -06:00
Richard Gomez 59fdd904af fix(cmd): parse platform in detect (#1765) 2025-02-20 11:32:47 -06:00
Richard Gomez c2afd56bbe Make paths and fingerprints platform-agnostic (#1622)
* test: windows

* fix: make paths platform-agnostic

this change also fixes, or skips, windows failures
2025-02-19 19:36:42 -06:00
Ricardo Zandonai 818e32f7a4 Add Sonar rule (#1756) 2025-02-19 08:02:35 -06:00
Richard Gomez 3fa5a3a954 Minor false positive improvements (#1758)
* feat(generic): add 'keypress' to allowlist

* feat(privatekey): ignore empty/impossible matches

* feat(config): ignore 'secrets' that are file paths

* fix(sentry): handle special character at end
Prevent common test error of 'Failed to Validate. True positive was not detected by regex.' because the generated value didn't play nicely with word boundary.
2025-02-19 07:46:09 -06:00
ahrav 2020e6a9ab Add support for streaming DetectReader (#1760) 2025-02-19 07:38:34 -06:00
Daniel Bos 9122a2d359 chore: Update github.com/wasilibs/go-re2 to v1.9.0 (#1763)
Fixes #1751
2025-02-19 05:15:04 -06:00
Roger Meier 398d0c46dd docs: describe extended rules take precedence over base rules (#1563)
Closes #1384
2025-02-11 07:53:00 -06:00
Richard Gomez ae26eff464 feat(git): disable link generation (#1748)
Add an option to disable link creation. If there are any weird edge cases, it shouldn't block scanning
2025-02-10 13:15:44 -06:00
Kashif KhanandRichard Gomez c6424a6fc3 added sourcegraph token rule (#1736)
* added sourcegraph token rule

* updated ruleid

Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>

* added more true positive test cases

---------

Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>
2025-01-31 09:34:37 -06:00
Richard Gomez 6411402d43 feat(config): add rule for .p12 files (#1738) 2025-01-31 09:33:38 -06:00
Jan-Otto Kröpke d71d95d65e add deno.lock to default exclusions (#1740)
* add deno.lock to default exclusions

* Update config.go
2025-01-31 09:32:41 -06:00
Daniel Grimm 3188ad6005 Don't exit with error if git repacking is required (#1711)
Repacking writes a message to stderr but is not problematic. It is
required quite often when using shallow/treeless clones, which is common
in CI/CD environments. Fixes #1168.
2025-01-28 19:58:15 -06:00
Richard Gomez 7fc11bb264 refactor(config): use non-capture groups for allowlists (#1735)
Non-capture groups appear to be measurably faster.
2025-01-28 19:54:20 -06:00
Aris Zagakos 36c52c6b73 chore: Enhance curl-auth-user to detect empty usernames or passwords (#1726) 2025-01-27 08:49:40 -06:00
Richard Gomez 1f323d8b69 fix(cmd): read log-opts before GitLogCmd (#1730) 2025-01-27 08:41:33 -06:00
Zachary Rice d88bc094f7 facebook keyword 2025-01-22 19:15:25 -06:00
Richard Gomez 3fdaefdaa3 fix(meraki): restrict keyword case (#1722) 2025-01-22 10:25:45 -06:00
Richard Gomez f3ae52e138 feat(generic-api-key): detect base64 (#1598) 2025-01-22 09:27:45 -06:00
Zachary Rice d6a828a530 great branch name (#1721)
* great branch name

* update test
2025-01-21 19:52:05 -06:00
Richard Gomez d2ffffecbd fix(git): remove .git suffix for links (#1716) 2025-01-21 19:17:26 -06:00
Richard Gomez a43dc0d3d0 chore: refine generic-api-key fps + trace logging (#1720) 2025-01-21 08:29:24 -06:00
Richard Gomez 69ed20e25e fix(generate): move newline out of char range (#1719) 2025-01-21 08:25:27 -06:00
Zachary Rice 52b895a603 newline literal (#1718) 2025-01-20 21:37:19 -06:00
Richard Gomez 3f4d91fc22 build: support either stdlib or 3rd-party regexp (#1706) 2025-01-20 10:45:31 -06:00
Richard Gomez 049f5b2435 chore(detect): update trace logging (#1713) 2025-01-20 09:30:59 -06:00
Richard Gomez 7a6183dab0 feat(git): redact passwords from remote URL (#1709) 2025-01-19 15:17:07 -06:00
Richard Gomez 3c7f3f0e08 feat(git): include link in report (#1698) 2025-01-19 14:03:57 -06:00
Richard Gomez 0e3f4f7abb chore: reduce generic-api-key fps (#1707)
Based on scanning ziglang/zig and oven-sh/bun
2025-01-19 07:37:39 -06:00
Zach 3ed85671a4 blorp 2025-01-17 19:24:22 -06:00
Kashif KhanandRichard Gomez e977850ab4 added new rule for cisco meraki api key (#1700)
* added new rule for cisco meraki cloud api key

* Updated style preference

Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>

* updated keywords

Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>

* Added entropy

Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>

* resolved comments

---------

Co-authored-by: Richard Gomez <32133502+rgmz@users.noreply.github.com>
2025-01-17 19:17:49 -06:00
Richard Gomez ad7a4fb4ea feat: general fp tweaks (#1703) 2025-01-17 19:13:33 -06:00
Richard Gomez b2cf03c7e3 chore(generate): use \x60 instead of literal (#1702) 2025-01-17 09:37:50 -06:00
Ben-grmbl a3f623cc69 chore(regex): simplify secretPrefix, suffix (#1620)
combined character ranges,
removed duplicates in same character range,
replaced \x060 with literal `
combined \s with \r\n
2025-01-15 18:21:44 -06:00
William Bille Meyling cc71bb1e9a update version for pre-commit in README.md (#1699) 2025-01-15 15:12:07 -06:00
Roger Meier 7bad9f7654 chore(gcp): add firebase example keys to the gcp-api-key allowlists (#1635) 2025-01-15 06:47:08 -06:00
Richard Gomez 977236cb5f fix: unaligned 64-bit atomic operation panic (#1696) 2025-01-15 06:45:37 -06:00
Zach a211b1601f force push to master everyday 2025-01-14 19:14:21 -06:00
Richard Gomez 0e5f644b67 feat(config): disable extended rule (#1535) 2025-01-14 18:52:57 -06:00
Piotr Idzik f320a60e6f style: prevent globbing and word splitting (#1543) 2025-01-14 16:42:07 -06:00
Richard Gomez c4526b2c55 refactor(generic-api-key): remove hard-coded 'magic' (#1600) 2025-01-13 19:57:25 -06:00
Richard Gomez 748076d976 chore(generate): add failing test case (#1690) 2025-01-13 10:21:29 -06:00
Richard Gomez db8e5e672e feat(generate): use multiple allowlists (#1691) 2025-01-13 08:49:12 -06:00
Richard Gomez 973c794cf0 chore(rules): include fps in reference (#1471) 2025-01-13 08:40:20 -06:00
rmdwe f0d4499064 Add comma as operator for GenerateSemiGenericRegex (#1679)
* feat: add comma as operator for GenerateSemiGenericRegex

* test: fix tests.
2025-01-13 08:21:45 -06:00
Richard Gomez ab38a46986 refactor: central logger (#1692) 2025-01-13 08:09:22 -06:00
Zachary Rice b022d1c856 friendship ended with tines 2025-01-02 10:24:13 -06:00
almaz045andAlmaz Vakhitov b69b5157a0 Entropy trace (#1659)
* I do an entropy check earlier than the others and add the info to the trace

Maybe I'm wrong, but it seems to me that if the regex allowlist is large, it's easier to first check for entropy, since we won't have to go through all these regexes. Plus, we need to check entropy anyway.
Additionally, when using -l trace, there was no information that the find was missed precisely because of entropy. Now it will be shown

* adding info into trace about entropy

* Fixed name of variables

---------

Co-authored-by: Almaz Vakhitov <a.vakhitov@vk.team>
2024-12-30 10:15:51 -06:00
Richard Gomez 7357adca5e build: add 'toolchain' to go.mod (#1682) 2024-12-30 10:08:24 -06:00
Richard Gomez 4c3da6ebb7 refactor(detect): create readUntilSafeBoundary + add tests (#1676) 2024-12-28 15:14:49 -06:00
Zachary Rice dbe3746455 twitter really does suck ass now 2024-12-28 10:22:25 -06:00
Ben-grmbl 7edfc6b5d5 chore(tests): test cases for generate.go (#1623)
GenerateSemiGenericRegex,
GenerateUniqueTokenRegex

to clarify and document current behavior
2024-12-20 20:55:10 -06:00
Richard Gomez efe40cae39 fix: only use non-empty secret groups (#1632) 2024-12-20 20:53:44 -06:00
Richard Gomez 7cb5f6f64c build: upgrade sprig v2->v3 (#1674) 2024-12-20 19:44:18 -06:00
Kenichi Kamiya 2930537190 fix: generate report file even if no findings (#1673) 2024-12-20 10:17:23 -06:00
ahrav a91c6717a0 replace std library regex engine with go-re2 (#1669) 2024-12-20 09:53:01 -06:00
David Mateo 906085fba6 Update golang version to 1.23 (#1672)
Because go mod 1.23 has been updated, the golang image needs it too
2024-12-20 08:38:11 -06:00
Zach d0ba52e2be bump go in dockerfile 2024-12-20 05:54:52 -06:00
Zachary Rice 8a8306288e log bytes (#1670) 2024-12-20 05:46:25 -06:00
107 changed files with 7141 additions and 1789 deletions

No files matched your search

+1
View File
@@ -4,6 +4,7 @@ jobs:
scan:
name: gitleaks
runs-on: ubuntu-latest
if: ${{ github.repository == 'gitleaks/gitleaks' }}
steps:
- uses: actions/checkout@v3
with:
+11 -3
View File
@@ -10,20 +10,28 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.22
go-version: 1.23
- name: Build
run: go build -v ./...
- name: Set up gotestsum
run: |
go install gotest.tools/gotestsum@latest
- name: Test
run: make test
run: |
gotestsum --raw-command -- go test -json ./... --race
- name: Validate Config
run: go generate ./... && git diff --exit-code
+2
View File
@@ -938,3 +938,5 @@ e56870aecf8ac2733affc82e1ac25e3be9092db3:cmd/generate/config/rules/curl.go:gener
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/prefect.go:prefect-api-token:26
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/databricks.go:databricks-api-token:25
239e6323639b18ba8a1081f17788a658da075dd7:cmd/generate/config/rules/databricks.go:generic-api-key:22
c24a3a654b18d689732ec3199f0a19a254505b04:detect/detect_test.go:generic-api-key:52
c08cb1dc9aee87186dba4eebbc13b8aaa2351f0c:detect/detect_test.go:generic-api-key:52
+1 -1
View File
@@ -16,7 +16,7 @@ builds:
- "6"
- "7"
ldflags:
- -s -w -X=github.com/zricethezav/gitleaks/v8/cmd.Version={{.Version}}
- -tags=gore2regex -s -w -X=github.com/zricethezav/gitleaks/v8/cmd.Version={{.Version}}
archives:
- builds: [gitleaks]
format_overrides:
+4 -1
View File
@@ -49,7 +49,10 @@ If you want to add a new rule to the [default Gitleaks configuration](https://gi
tps := []string{
generateSampleSecret("beamer", "b_"+secrets.NewSecret(alphaNumericExtended("44"))),
}
return validate(r, tps, nil)
fps := []string{
`R21A-A-V010SP13RC181024R16900-CN-B_250K-Release-OTA-97B6C6C59241976086FABDC41472150C.bfu`,
}
return validate(r, tps, fps)
}
```
+2 -2
View File
@@ -1,8 +1,8 @@
FROM golang:1.22 AS build
FROM golang:1.23 AS build
WORKDIR /go/src/github.com/zricethezav/gitleaks
COPY . .
RUN VERSION=$(git describe --tags --abbrev=0) && \
CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X="github.com/zricethezav/gitleaks/v8/cmd.Version=${VERSION}
CGO_ENABLED=0 go build -o bin/gitleaks -ldflags "-X=github.com/zricethezav/gitleaks/v8/cmd.Version=${VERSION}"
FROM alpine:3.19
RUN apk add --no-cache bash git openssh-client
+51 -34
View File
@@ -8,22 +8,30 @@
└─░───┘
```
<p align="left">
<p align="left">
<a href="https://github.com/gitleaks/gitleaks/actions/workflows/test.yml">
<img alt="Github Test" src="https://github.com/gitleaks/gitleaks/actions/workflows/test.yml/badge.svg">
</a>
<a href="https://hub.docker.com/r/zricethezav/gitleaks">
<img src="https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg" />
</a>
<a href="https://github.com/gitleaks/gitleaks-action">
<img alt="gitleaks badge" src="https://img.shields.io/badge/protected%20by-gitleaks-blue">
</a>
<a href="https://twitter.com/intent/follow?screen_name=zricethezav">
<img src="https://img.shields.io/twitter/follow/zricethezav?label=Follow%20zricethezav&style=social&color=blue" alt="Follow @zricethezav" />
</a>
</p>
</p>
[license]: ./LICENSE
[badge-license]: https://img.shields.io/github/license/gitleaks/gitleaks.svg
[go-docs-badge]: https://pkg.go.dev/badge/github.com/gitleaks/gitleaks/v8?status
[go-docs]: https://pkg.go.dev/github.com/zricethezav/gitleaks/v8
[badge-build]: https://github.com/gitleaks/gitleaks/actions/workflows/test.yml/badge.svg
[build]: https://github.com/gitleaks/gitleaks/actions/workflows/test.yml
[go-report-card-badge]: https://goreportcard.com/badge/github.com/gitleaks/gitleaks/v8
[go-report-card]: https://goreportcard.com/report/github.com/gitleaks/gitleaks/v8
[dockerhub]: https://hub.docker.com/r/zricethezav/gitleaks
[dockerhub-badge]: https://img.shields.io/docker/pulls/zricethezav/gitleaks.svg
[gitleaks-action]: https://github.com/gitleaks/gitleaks-action
[gitleaks-badge]: https://img.shields.io/badge/protected%20by-gitleaks-blue
[gitleaks-playground-badge]: https://img.shields.io/badge/gitleaks%20-playground-blue
[gitleaks-playground]: https://gitleaks.io/playground
[![Github Action Test][badge-build]][build]
[![Docker Hub][dockerhub-badge]][dockerhub]
[![Gitleaks Playground][gitleaks-playground-badge]][gitleaks-playground]
[![Gitleaks Action][gitleaks-badge]][gitleaks-action]
[![GoDoc][go-docs-badge]][go-docs]
[![GoReportCard][go-report-card-badge]][go-report-card]
[![License][badge-license]][license]
### Join our Discord! [![Discord](https://img.shields.io/discord/1102689410522284044.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.gg/8Hzbrnkr7E)
@@ -105,7 +113,7 @@ jobs:
```
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.19.0
rev: v8.23.1
hooks:
- id: gitleaks
```
@@ -221,23 +229,37 @@ Gitleaks offers a configuration format you can follow to write your own secret d
```toml
# Title for the gitleaks configuration file.
title = "Gitleaks title"
title = "Custom Gitleaks configuration"
# You have basically two options for your custom configuration:
#
# 1. define your own configuration, default rules do not apply
#
# use e.g., the default configuration as starting point:
# https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
#
# 2. extend a configuration, the rules are overwritten or extended
#
# When you extend a configuration the extended rules take precedence over the
# default rules. I.e., if there are duplicate rules in both the extended
# configuration and the default configuration the extended rules or
# attributes of them will override the default rules.
# Another thing to know with extending configurations is you can chain
# together multiple configuration files to a depth of 2. Allowlist arrays are
# appended and can contain duplicates.
# Extend the base (this) configuration. When you extend a configuration
# the base rules take precedence over the extended rules. I.e., if there are
# duplicate rules in both the base configuration and the extended configuration
# the base rules will override the extended rules.
# Another thing to know with extending configurations is you can chain together
# multiple configuration files to a depth of 2. Allowlist arrays are appended
# and can contain duplicates.
# useDefault and path can NOT be used at the same time. Choose one.
[extend]
# useDefault will extend the base configuration with the default gitleaks config:
# useDefault will extend the default gitleaks config built in to the binary
# the latest version is located at:
# https://github.com/gitleaks/gitleaks/blob/master/config/gitleaks.toml
useDefault = true
# or you can supply a path to a configuration. Path is relative to where gitleaks
# was invoked, not the location of the base config.
path = "common_config.toml"
# or you can provide a path to a configuration to extend from.
# The path is relative to where gitleaks was invoked,
# not the location of the base config.
# path = "common_config.toml"
# If there are any rules you don't want to inherit, they can be specified here.
disabledRules = [ "generic-api-key"]
# An array of tables that contain information that define instructions
# on how to detect secrets
@@ -443,11 +465,6 @@ $ gitleaks dir ~/leaky-repo/ --report-path "report.json" --report-format templat
<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
+37 -51
View File
@@ -22,9 +22,11 @@ import (
"os"
"time"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/zricethezav/gitleaks/v8/cmd/scm"
"github.com/zricethezav/gitleaks/v8/detect"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/sources"
)
@@ -36,6 +38,7 @@ func init() {
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")
detectCmd.Flags().String("platform", "", "the target platform used to generate links (github, gitlab)")
}
var detectCmd = &cobra.Command{
@@ -46,86 +49,69 @@ var detectCmd = &cobra.Command{
}
func runDetect(cmd *cobra.Command, args []string) {
source, err := cmd.Flags().GetString("source")
if err != nil {
log.Fatal().Err(err).Msg("could not get source")
}
initConfig(source)
var findings []report.Finding
// setup config (aka, the thing that defines rules)
cfg := Config(cmd)
// start timer
start := time.Now()
source := mustGetStringFlag(cmd, "source")
// setup config (aka, the thing that defines rules)
initConfig(source)
cfg := Config(cmd)
// create detector
detector := Detector(cmd, cfg, source)
// set follow symlinks flag
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
log.Fatal().Err(err).Msg("")
}
// set exit code
exitCode, err := cmd.Flags().GetInt("exit-code")
if err != nil {
log.Fatal().Err(err).Msg("could not get exit code")
}
// parse flags
detector.FollowSymlinks = mustGetBoolFlag(cmd, "follow-symlinks")
exitCode := mustGetIntFlag(cmd, "exit-code")
noGit := mustGetBoolFlag(cmd, "no-git")
fromPipe := mustGetBoolFlag(cmd, "pipe")
// determine what type of scan:
// - git: scan the history of the repo
// - no-git: scan files by treating the repo as a plain directory
noGit, err := cmd.Flags().GetBool("no-git")
if err != nil {
log.Fatal().Err(err).Msg("could not call GetBool() for no-git")
}
fromPipe, err := cmd.Flags().GetBool("pipe")
if err != nil {
log.Fatal().Err(err).Msg("could not call GetBool() for pipe")
}
// start the detector scan
var (
findings []report.Finding
err error
)
if noGit {
var paths <-chan sources.ScanTarget
paths, err = sources.DirectoryTargets(
paths, err := sources.DirectoryTargets(
source,
detector.Sema,
detector.FollowSymlinks,
detector.Config.Allowlist.PathAllowed,
)
if err != nil {
log.Fatal().Err(err)
logging.Fatal().Err(err).Send()
}
findings, err = detector.DetectFiles(paths)
if err != nil {
if findings, err = detector.DetectFiles(paths); err != nil {
// don't exit on error, just log it
log.Error().Err(err).Msg("failed scan directory")
logging.Error().Err(err).Msg("failed scan directory")
}
} else if fromPipe {
findings, err = detector.DetectReader(os.Stdin, 10)
if err != nil {
if findings, err = detector.DetectReader(os.Stdin, 10); 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("failed scan input from stdin")
logging.Fatal().Err(err).Msg("failed scan input from stdin")
}
} else {
var (
gitCmd *sources.GitCmd
logOpts string
logOpts = mustGetStringFlag(cmd, "log-opts")
gitCmd *sources.GitCmd
scmPlatform scm.Platform
remote *detect.RemoteInfo
)
logOpts, err = cmd.Flags().GetString("log-opts")
if err != nil {
log.Fatal().Err(err).Msg("could not call GetString() for log-opts")
if gitCmd, err = sources.NewGitLogCmd(source, logOpts); err != nil {
logging.Fatal().Err(err).Msg("could not create Git cmd")
}
gitCmd, err = sources.NewGitLogCmd(source, logOpts)
if err != nil {
log.Fatal().Err(err).Msg("could not create Git cmd")
if scmPlatform, err = scm.PlatformFromString(mustGetStringFlag(cmd, "platform")); err != nil {
logging.Fatal().Err(err).Send()
}
findings, err = detector.DetectGit(gitCmd)
if err != nil {
remote = detect.NewRemoteInfo(scmPlatform, source)
if findings, err = detector.DetectGit(gitCmd, remote); err != nil {
// don't exit on error, just log it
log.Error().Err(err).Msg("failed to scan Git repository")
logging.Error().Err(err).Msg("failed to scan Git repository")
}
}
+5 -5
View File
@@ -3,9 +3,9 @@ package cmd
import (
"time"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/sources"
)
@@ -47,12 +47,12 @@ func runDirectory(cmd *cobra.Command, args []string) {
// set follow symlinks flag
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
log.Fatal().Err(err).Msg("")
logging.Fatal().Err(err).Msg("")
}
// set exit code
exitCode, err := cmd.Flags().GetInt("exit-code")
if err != nil {
log.Fatal().Err(err).Msg("could not get exit code")
logging.Fatal().Err(err).Msg("could not get exit code")
}
var paths <-chan sources.ScanTarget
@@ -63,13 +63,13 @@ func runDirectory(cmd *cobra.Command, args []string) {
detector.Config.Allowlist.PathAllowed,
)
if err != nil {
log.Fatal().Err(err)
logging.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")
logging.Error().Err(err).Msg("failed scan directory")
}
findingSummaryAndExit(detector, findings, exitCode, start, err)
+34 -27
View File
@@ -2,10 +2,10 @@ package base
import (
"fmt"
"regexp"
"strings"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func CreateGlobalConfig() config.Config {
@@ -33,9 +33,9 @@ func CreateGlobalConfig() config.Config {
}(),
// ----------- Environment Variables -----------
regexp.MustCompile(`^\$(\d+|{\d+})$`),
regexp.MustCompile(`^\$([A-Z_]+|[a-z_]+)$`),
regexp.MustCompile(`^\${([A-Z_]+|[a-z_]+)}$`),
regexp.MustCompile(`^\$(?:\d+|{\d+})$`),
regexp.MustCompile(`^\$(?:[A-Z_]+|[a-z_]+)$`),
regexp.MustCompile(`^\${(?:[A-Z_]+|[a-z_]+)}$`),
// ----------- Interpolated Variables -----------
// Ansible (https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html)
@@ -43,64 +43,71 @@ func CreateGlobalConfig() config.Config {
// GitHub Actions
// https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables
// https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
regexp.MustCompile(`^\$\{\{[ \t]*((env|github|secrets|vars)(\.[A-Za-z]\w+)+[\w "'&./=|]*)[ \t]*}}$`),
regexp.MustCompile(`^\$\{\{[ \t]*(?:(?:env|github|secrets|vars)(?:\.[A-Za-z]\w+)+[\w "'&./=|]*)[ \t]*}}$`),
// NuGet (https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file#using-environment-variables)
regexp.MustCompile(`^%([A-Z_]+|[a-z_]+)%$`),
regexp.MustCompile(`^%(?:[A-Z_]+|[a-z_]+)%$`),
// String formatting.
regexp.MustCompile(`^%[+\-# 0]?[bcdeEfFgGoOpqstTUvxX]$`), // Golang (https://pkg.go.dev/fmt)
regexp.MustCompile(`^\{\d{0,2}}$`), // Python (https://docs.python.org/3/tutorial/inputoutput.html)
// Urban Code Deploy (https://www.ibm.com/support/pages/replace-token-step-replaces-replacement-values-windows-variables)
regexp.MustCompile(`^@([A-Z_]+|[a-z_]+)@$`),
regexp.MustCompile(`^@(?:[A-Z_]+|[a-z_]+)@$`),
// ----------- Miscellaneous -----------
// File paths
regexp.MustCompile(`^/Users/(?i)[a-z0-9]+/[\w .-/]+$`), // MacOS
regexp.MustCompile(`^/(?:bin|etc|home|opt|tmp|usr|var)/[\w ./-]+$`), // Linux
// 11980 Jps -Dapplication.home=D:\develop_tools\jdk\jdk1.8.0_131 -Xms8m
//regexp.MustCompile(`^$`), // Windows
},
Paths: []*regexp.Regexp{
regexp.MustCompile(`gitleaks\.toml`),
// ----------- Documents and media -----------
regexp.MustCompile(`(?i)\.(bmp|gif|jpe?g|svg|tiff?)$`), // Images
regexp.MustCompile(`\.(eot|[ot]tf|woff2?)$`), // Fonts
regexp.MustCompile(`(.*?)(doc|docx|zip|xls|pdf|bin|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe|gltf)$`),
regexp.MustCompile(`(?i)\.(?:bmp|gif|jpe?g|png|svg|tiff?)$`), // Images
regexp.MustCompile(`(?i)\.(?:eot|[ot]tf|woff2?)$`), // Fonts
regexp.MustCompile(`(?i)\.(?:docx?|xlsx?|pdf|bin|socket|vsidx|v2|suo|wsuo|.dll|pdb|exe|gltf|zip)$`),
// ----------- Golang files -----------
regexp.MustCompile(`go\.(mod|sum|work(\.sum)?)$`),
regexp.MustCompile(`(^|/)vendor/modules\.txt$`),
regexp.MustCompile(`(^|/)vendor/(github\.com|golang\.org/x|google\.golang\.org|gopkg\.in|istio\.io|k8s\.io|sigs\.k8s\.io)(/.*)?$`),
regexp.MustCompile(`go\.(?:mod|sum|work(?:\.sum)?)$`),
regexp.MustCompile(`(?:^|/)vendor/modules\.txt$`),
regexp.MustCompile(`(?:^|/)vendor/(?:github\.com|golang\.org/x|google\.golang\.org|gopkg\.in|istio\.io|k8s\.io|sigs\.k8s\.io)(?:/.*)?$`),
// ----------- Java files -----------
// Gradle
regexp.MustCompile(`(^|/)gradlew(\.bat)?$`),
regexp.MustCompile(`(^|/)gradle\.lockfile$`),
regexp.MustCompile(`(^|/)mvnw(\.cmd)?$`),
regexp.MustCompile(`(^|/)\.mvn/wrapper/MavenWrapperDownloader\.java$`),
regexp.MustCompile(`(?:^|/)gradlew(?:\.bat)?$`),
regexp.MustCompile(`(?:^|/)gradle\.lockfile$`),
regexp.MustCompile(`(?:^|/)mvnw(?:\.cmd)?$`),
regexp.MustCompile(`(?:^|/)\.mvn/wrapper/MavenWrapperDownloader\.java$`),
// ----------- JavaScript files -----------
// Dependencies and lock files.
regexp.MustCompile(`(^|/)node_modules(/.*)?$`),
regexp.MustCompile(`(^|/)(npm-shrinkwrap\.json|package-lock\.json|pnpm-lock\.yaml|yarn\.lock)$`),
regexp.MustCompile(`(^|/)bower_components(/.*)?$`),
regexp.MustCompile(`(?:^|/)node_modules(?:/.*)?$`),
regexp.MustCompile(`(?:^|/)(?:deno\.lock|npm-shrinkwrap\.json|package-lock\.json|pnpm-lock\.yaml|yarn\.lock)$`),
regexp.MustCompile(`(?:^|/)bower_components(?:/.*)?$`),
// TODO: Add more common static assets, such as swagger-ui.
regexp.MustCompile(`(^|/)(angular|jquery(-?ui)?|plotly|swagger-?ui)[a-zA-Z0-9.-]*(\.min)?\.js(\.map)?$`),
regexp.MustCompile(`(?:^|/)(?:angular|bootstrap|jquery(?:-?ui)?|plotly|swagger-?ui)[a-zA-Z0-9.-]*(?:\.min)?\.js(?:\.map)?$`),
regexp.MustCompile(`(?:^|/)javascript\.json$`),
// ----------- Python files -----------
// Dependencies and lock files.
regexp.MustCompile(`(^|/)(Pipfile|poetry)\.lock$`),
regexp.MustCompile(`(?:^|/)(?:Pipfile|poetry)\.lock$`),
// Virtual environments
regexp.MustCompile(`(?i)/?(v?env|virtualenv)/lib(64)?(/.*)?$`),
regexp.MustCompile(`(?i)(^|/)(lib(64)?/python[23](\.\d{1,2})+|python/[23](\.\d{1,2})+/lib(64)?)(/.*)?$`),
regexp.MustCompile(`(?i)(?:^|/)(?:v?env|virtualenv)/lib(?:64)?(?:/.*)?$`),
regexp.MustCompile(`(?i)(?:^|/)(?:lib(?:64)?/python[23](?:\.\d{1,2})+|python/[23](?:\.\d{1,2})+/lib(?:64)?)(?:/.*)?$`),
// dist-info directory (https://py-pkgs.org/04-package-structure.html#building-sdists-and-wheels)
regexp.MustCompile(`(?i)(^|/)[a-z0-9_.]+-[0-9.]+\.dist-info(/.+)?$`),
regexp.MustCompile(`(?i)(?:^|/)[a-z0-9_.]+-[0-9.]+\.dist-info(?:/.+)?$`),
// ----------- Ruby files -----------
regexp.MustCompile(`(^|/)vendor/(bundle|ruby)(/.*?)?$`),
regexp.MustCompile(`(?:^|/)vendor/(?:bundle|ruby)(?:/.*?)?$`),
regexp.MustCompile(`\.gem$`), // tar archive
// Misc
regexp.MustCompile(`verification-metadata\.xml`),
regexp.MustCompile(`Database.refactorlog`),
//regexp.MustCompile(`vendor`),
// regexp.MustCompile(`vendor`),
},
StopWords: []string{
"abcdefghijklmnopqrstuvwxyz", // character range
// ----------- Secrets -----------
// Checkmarx client secret. (https://github.com/checkmarx-ts/checkmarx-python-sdk/blob/86560f6e2a3e46d16322101294da10d5d190312d/README.md?plain=1#L56)
"014df517-39d1-4453-b7b3-9930c563627c",
+137 -95
View File
@@ -4,70 +4,79 @@ import (
"testing"
)
func TestConfigAllowlistRegexes(t *testing.T) {
tests := map[string]struct {
invalid []string
valid []string
}{
"general placeholders": {
invalid: []string{
`true`, `True`, `false`, `False`, `null`, `NULL`,
},
var allowlistRegexTests = map[string]struct {
invalid []string
valid []string
}{
"general placeholders": {
invalid: []string{
`true`, `True`, `false`, `False`, `null`, `NULL`,
},
"general placeholders - repeated characters": {
invalid: []string{
`aaaaaaaaaaaaaaaaa`, `BBBBBBBBBBbBBBBBBBbBB`, `********************`,
},
valid: []string{`aaaaaaaaaaaaaaaaaaabaa`, `pas*************d`},
},
"general placeholders - repeated characters": {
invalid: []string{
`aaaaaaaaaaaaaaaaa`, `BBBBBBBBBBbBBBBBBBbBB`, `********************`,
},
"environment variables": {
invalid: []string{`$2`, `$GIT_PASSWORD`, `${GIT_PASSWORD}`, `$password`},
valid: []string{`$yP@R.@=ibxI`, `$2a6WCust9aE`, `${not_complete1`},
valid: []string{`aaaaaaaaaaaaaaaaaaabaa`, `pas*************d`},
},
"environment variables": {
invalid: []string{`$2`, `$GIT_PASSWORD`, `${GIT_PASSWORD}`, `$password`},
valid: []string{`$yP@R.@=ibxI`, `$2a6WCust9aE`, `${not_complete1`},
},
"interpolated variables - ansible": {
invalid: []string{
`{{ x }}`, `{{ password }}`, `{{password}}`, `{{ data.proxy_password }}`,
`{{ dict1 | ansible.builtin.combine(dict2) }}`,
},
"interpolated variables - ansible": {
invalid: []string{
`{{ x }}`, `{{ password }}`, `{{password}}`, `{{ data.proxy_password }}`,
`{{ dict1 | ansible.builtin.combine(dict2) }}`,
},
},
"interpolated variables - github actions": {
invalid: []string{
`${{ env.First_Name }}`,
`${{ env.DAY_OF_WEEK == 'Monday' }}`,
`${{env.JAVA_VERSION}}`,
`${{ github.event.issue.title }}`,
`${{ github.repository == "Gattocrucco/lsqfitgp" }}`,
`${{ github.event.pull_request.number || github.ref }}`,
`${{ github.event_name == 'pull_request' && github.event.action == 'unassigned' }}`,
`${{ secrets.SuperSecret }}`,
`${{ vars.JOB_NAME }}`,
`${{ vars.USE_VARIABLES == 'true' }}`,
},
"interpolated variables - github actions": {
invalid: []string{
`${{ env.First_Name }}`,
`${{ env.DAY_OF_WEEK == 'Monday' }}`,
`${{env.JAVA_VERSION}}`,
`${{ github.event.issue.title }}`,
`${{ github.repository == "Gattocrucco/lsqfitgp" }}`,
`${{ github.event.pull_request.number || github.ref }}`,
`${{ github.event_name == 'pull_request' && github.event.action == 'unassigned' }}`,
`${{ secrets.SuperSecret }}`,
`${{ vars.JOB_NAME }}`,
`${{ vars.USE_VARIABLES == 'true' }}`,
},
},
"interpolated variables - nuget": {
invalid: []string{
`%MY_PASSWORD%`, `%password%`,
},
"interpolated variables - nuget": {
invalid: []string{
`%MY_PASSWORD%`, `%password%`,
},
},
"interpolated variables - string fmt - golang": {
invalid: []string{
`%b`, `%c`, `%d`, `% d`, `%e`, `%E`, `%f`, `%F`, `%g`, `%G`, `%o`, `%O`, `%p`, `%q`, `%-s`, `%s`, `%t`, `%T`, `%U`, `%#U`, `%+v`, `%#v`, `%v`, `%x`, `%X`,
},
"interpolated variables - string fmt - golang": {
invalid: []string{
`%b`, `%c`, `%d`, `% d`, `%e`, `%E`, `%f`, `%F`, `%g`, `%G`, `%o`, `%O`, `%p`, `%q`, `%-s`, `%s`, `%t`, `%T`, `%U`, `%#U`, `%+v`, `%#v`, `%v`, `%x`, `%X`,
},
},
"interpolated variables - string fmt - python": {
invalid: []string{
`{}`, `{0}`, `{10}`,
},
"interpolated variables - string fmt - python": {
invalid: []string{
`{}`, `{0}`, `{10}`,
},
},
"interpolated variables - ucd": {
invalid: []string{`@password@`, `@LDAP_PASS@`},
valid: []string{`@username@mastodon.example`},
},
"miscellaneous - file paths": {
invalid: []string{
// MacOS
`/Users/james/Projects/SwiftCode/build/Release`,
// Linux
`/tmp/screen-exchange`,
},
"interpolated variables - ucd": {
invalid: []string{`@password@`, `@LDAP_PASS@`},
valid: []string{`@username@mastodon.example`},
},
}
valid: []string{},
},
}
func TestConfigAllowlistRegexes(t *testing.T) {
cfg := CreateGlobalConfig()
allowlist := cfg.Allowlist
for name, cases := range tests {
for name, cases := range allowlistRegexTests {
t.Run(name, func(t *testing.T) {
for _, c := range cases.invalid {
if !allowlist.RegexAllowed(c) {
@@ -84,50 +93,67 @@ func TestConfigAllowlistRegexes(t *testing.T) {
}
}
func TestConfigAllowlistPaths(t *testing.T) {
tests := map[string]struct {
invalid []string
valid []string
}{
"javascript - common static assets": {
invalid: []string{
`src/main/static/lib/angular.1.2.16.min.js`,
`src/main/resources/static/jquery-ui-1.12.1/jquery-ui-min.js`,
`src/main/resources/static/js/jquery-ui-1.10.4.min.js`,
`src-static/js/plotly.min.js`,
`swagger/swaggerui/swagger-ui-bundle.js.map`,
`swagger/swaggerui/swagger-ui-es-bundle.js.map`,
`src/main/static/swagger-ui.min.js`,
`swagger/swaggerui/swagger-ui.js`,
},
},
"python": {
invalid: []string{
// lock files
`Pipfile.lock`, `poetry.lock`,
// virtual environments
"env/lib/python3.7/site-packages/urllib3/util/url.py",
"venv/Lib/site-packages/regex-2018.08.29.dist-info/DESCRIPTION.rst",
"venv/lib64/python3.5/site-packages/pynvml.py",
"python/python3/virtualenv/Lib/site-packages/pyphonetics/utils.py",
"virtualenv/lib64/python3.7/base64.py",
// packages
"cde-root/usr/lib64/python2.4/site-packages/Numeric.pth",
"lib/python3.9/site-packages/setuptools/_distutils/msvccompiler.py",
"lib/python3.8/site-packages/botocore/data/alexaforbusiness/2017-11-09/service-2.json",
"code/python/3.7.4/Lib/site-packages/dask/bytes/tests/test_bytes_utils.py",
"python/3.7.4/Lib/site-packages/fsspec/utils.py",
"python/2.7.16.32/Lib/bsddb/test/test_dbenv.py",
"python/lib/python3.8/site-packages/boto3/data/ec2/2016-04-01/resources-1.json",
// distinfo
"libs/PyX-0.15.dist-info/AUTHORS",
},
},
}
func BenchmarkConfigAllowlistRegexes(b *testing.B) {
cfg := CreateGlobalConfig()
allowlist := cfg.Allowlist
for name, cases := range tests {
for n := 0; n < b.N; n++ {
for _, cases := range allowlistRegexTests {
for _, c := range cases.invalid {
allowlist.RegexAllowed(c)
}
for _, c := range cases.valid {
allowlist.RegexAllowed(c)
}
}
}
}
var allowlistPathsTests = map[string]struct {
invalid []string
valid []string
}{
"javascript - common static assets": {
invalid: []string{
`tests/e2e/nuget/wwwroot/lib/bootstrap/dist/js/bootstrap.esm.min.js`,
`src/main/static/lib/angular.1.2.16.min.js`,
`src/main/resources/static/jquery-ui-1.12.1/jquery-ui-min.js`,
`src/main/resources/static/js/jquery-ui-1.10.4.min.js`,
`src-static/js/plotly.min.js`,
`swagger/swaggerui/swagger-ui-bundle.js.map`,
`swagger/swaggerui/swagger-ui-es-bundle.js.map`,
`src/main/static/swagger-ui.min.js`,
`swagger/swaggerui/swagger-ui.js`,
},
},
"python": {
invalid: []string{
// lock files
`Pipfile.lock`, `poetry.lock`,
// virtual environments
"env/lib/python3.7/site-packages/urllib3/util/url.py",
"venv/Lib/site-packages/regex-2018.08.29.dist-info/DESCRIPTION.rst",
"venv/lib64/python3.5/site-packages/pynvml.py",
"python/python3/virtualenv/Lib/site-packages/pyphonetics/utils.py",
"virtualenv/lib64/python3.7/base64.py",
// packages
"cde-root/usr/lib64/python2.4/site-packages/Numeric.pth",
"lib/python3.9/site-packages/setuptools/_distutils/msvccompiler.py",
"lib/python3.8/site-packages/botocore/data/alexaforbusiness/2017-11-09/service-2.json",
"code/python/3.7.4/Lib/site-packages/dask/bytes/tests/test_bytes_utils.py",
"python/3.7.4/Lib/site-packages/fsspec/utils.py",
"python/2.7.16.32/Lib/bsddb/test/test_dbenv.py",
"python/lib/python3.8/site-packages/boto3/data/ec2/2016-04-01/resources-1.json",
// distinfo
"libs/PyX-0.15.dist-info/AUTHORS",
},
},
}
func TestConfigAllowlistPaths(t *testing.T) {
cfg := CreateGlobalConfig()
allowlist := cfg.Allowlist
for name, cases := range allowlistPathsTests {
t.Run(name, func(t *testing.T) {
for _, c := range cases.invalid {
if !allowlist.PathAllowed(c) {
@@ -143,3 +169,19 @@ func TestConfigAllowlistPaths(t *testing.T) {
})
}
}
func BenchmarkConfigAllowlistPaths(b *testing.B) {
cfg := CreateGlobalConfig()
allowlist := cfg.Allowlist
for n := 0; n < b.N; n++ {
for _, cases := range allowlistPathsTests {
for _, c := range cases.invalid {
allowlist.PathAllowed(c)
}
for _, c := range cases.valid {
allowlist.PathAllowed(c)
}
}
}
}
+9 -7
View File
@@ -4,11 +4,10 @@ import (
"os"
"text/template"
"github.com/rs/zerolog/log"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/base"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/rules"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/logging"
)
const (
@@ -148,6 +147,7 @@ func main() {
rules.MailGunSigningKey(),
rules.MapBox(),
rules.MattermostAccessToken(),
rules.Meraki(),
rules.MessageBirdAPIToken(),
rules.MessageBirdClientID(),
rules.NetlifyAccessToken(),
@@ -172,6 +172,7 @@ func main() {
rules.Prefect(),
rules.PrivateAIToken(),
rules.PrivateKey(),
rules.PrivateKeyPKCS12File(),
rules.PulumiAPIToken(),
rules.PyPiUploadToken(),
rules.RapidAPIAccessToken(),
@@ -205,6 +206,8 @@ func main() {
rules.SlackLegacyToken(),
rules.SlackWebHookUrl(),
rules.Snyk(),
rules.Sonar(),
rules.SourceGraph(),
rules.StripeAccessToken(),
rules.SquareAccessToken(),
rules.SquareSpaceAccessToken(),
@@ -236,7 +239,7 @@ func main() {
for _, rule := range configRules {
// check if rule is in ruleLookUp
if _, ok := ruleLookUp[rule.RuleID]; ok {
log.Fatal().Msgf("rule id %s is not unique", rule.RuleID)
logging.Fatal().Msgf("rule id %s is not unique", rule.RuleID)
}
// TODO: eventually change all the signatures to get ride of this
// nasty dereferencing.
@@ -245,18 +248,17 @@ func main() {
tmpl, err := template.ParseFiles(templatePath)
if err != nil {
log.Fatal().Err(err).Msg("Failed to parse template")
logging.Fatal().Err(err).Msg("Failed to parse template")
}
f, err := os.Create(gitleaksConfigPath)
if err != nil {
log.Fatal().Err(err).Msg("Failed to create rules.toml")
logging.Fatal().Err(err).Msg("Failed to create rules.toml")
}
cfg := base.CreateGlobalConfig()
cfg.Rules = ruleLookUp
if err = tmpl.Execute(f, cfg); err != nil {
log.Fatal().Err(err).Msg("could not execute template")
logging.Fatal().Err(err).Msg("could not execute template")
}
}
+1 -2
View File
@@ -1,11 +1,10 @@
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"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// https://developer.1password.com/docs/service-accounts/security/?token-example=encoded
+1 -2
View File
@@ -1,10 +1,9 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func AgeSecretKey() *config.Rule {
+1 -2
View File
@@ -1,11 +1,10 @@
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"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func AWS() *config.Rule {
+2 -3
View File
@@ -2,12 +2,11 @@ package rules
import (
"fmt"
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// References:
+4 -1
View File
@@ -18,5 +18,8 @@ func Beamer() *config.Rule {
// validate
tps := utils.GenerateSampleSecrets("beamer", "b_"+secrets.NewSecret(utils.AlphaNumericExtended("44")))
return utils.Validate(r, tps, nil)
fps := []string{
`│   ├── R21A-A-V010SP13RC181024R16900-CN-B_250K-Release-OTA-97B6C6C59241976086FABDC41472150C.bfu`,
}
return utils.Validate(r, tps, fps)
}
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func Clojars() *config.Rule {
+12 -36
View File
@@ -2,7 +2,10 @@
# If you would like to contribute new rules, please use
# cmd/generate/config/main.go and follow the contributing guidelines
# at https://github.com/gitleaks/gitleaks/blob/master/CONTRIBUTING.md
#
# How the hell does secret scanning work? Read this:
# https://lookingatcomputer.substack.com/p/regex-is-almost-all-you-need
#
# This is the default gitleaks configuration file.
# Rules and allowlists are defined within this file.
# Rules instruct gitleaks on what should be considered a secret.
@@ -24,12 +27,13 @@ paths = [{{ range $i, $path := . }}
]{{ end }}
{{- with .Allowlist.StopWords }}{{println}}stopwords = [{{ range $j, $stopword := . }}
"{{ $stopword }}",{{ end }}
]{{ end }}
]{{ end }}{{println}}
{{ range $i, $rule := .Rules }}[[rules]]
{{- range $i, $rule := .Rules }}{{println}}[[rules]]
id = "{{$rule.RuleID}}"
description = "{{$rule.Description}}"
regex = '''{{$rule.Regex}}'''
{{- with $rule.Regex }}
regex = '''{{ . }}'''{{ end -}}
{{- with $rule.Path }}
path = '''{{ . }}'''{{ end -}}
{{- with $rule.SecretGroup }}
@@ -46,16 +50,8 @@ keywords = [{{ range $j, $keyword := . }}"{{ $keyword }}"{{ end }}]{{end}}{{ end
tags = [
{{ range $j, $tag := . }}"{{ $tag }}",{{ end }}
]{{ end }}
{{- /*
* Use [rules.allowlist] for a while, allow people to catch up with the new syntax.
* TODO: Remove this a few major versions after 8.21.0
* https://github.com/gitleaks/gitleaks/issues/1571
*/}}
{{- if eq (len $rule.Allowlists) 1 }}{{ with index $rule.Allowlists 0}}{{ if or .Regexes .Paths .Commits .StopWords }}
# NOTE: Gitleaks >= v8.21.0 should use [[rules.allowlists] instead.
[rules.allowlist]
{{- with .MatchCondition }}{{println}}condition = "{{ .MatchCondition.String }}"{{ end }}
{{- with $rule.Allowlists }}{{ range $i, $allowlist := . }}{{ if or $allowlist.Regexes $allowlist.Paths $allowlist.Commits $allowlist.StopWords }}{{println}}[[rules.allowlists]]
{{- with .MatchCondition }}{{println}}condition = "{{ .String }}"{{ end }}
{{- with .Commits -}}{{println}}commits = [
{{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
]{{ end }}
@@ -68,25 +64,5 @@ tags = [
]{{ end }}
{{- with .StopWords }}{{println}}stopwords = [{{ range $j, $stopword := . }}
"{{ $stopword }}",{{ end }}
]{{ end }}{{ end }}{{ end }}
{{ else }}
{{ with $rule.Allowlists }}{{ range $i, $allowlist := . }}{{ if or $allowlist.Regexes $allowlist.Paths $allowlist.Commits $allowlist.StopWords }}
[[rules.allowlists]]
{{ with $allowlist.MatchCondition }}condition = "{{ .String }}"
{{ end -}}
{{- with $allowlist.Commits }}commits = [
{{ range $j, $commit := . }}"{{ $commit }}",{{ end }}
]{{ end }}
{{- with $allowlist.Paths }}paths = [
{{ range $j, $path := . }}'''{{ $path }}''',{{ end }}
]{{ end }}
{{- with $allowlist.RegexTarget }}regexTarget = "{{ . }}"
{{ end -}}
{{- with $allowlist.Regexes }}regexes = [{{ range $i, $regex := . }}
'''{{ $regex }}''',{{ end }}
]{{ end }}
{{ with $allowlist.StopWords }}stopwords = [{{ range $j, $stopword := . }}
"{{ $stopword }}",{{ end }}
]{{ end }}{{ end }}{{ end }}
{{ end }}{{ end }}
{{ end -}}
]{{ end }}{{ end }}{{ end }}{{ end }}
{{ end }}
+11 -8
View File
@@ -2,10 +2,10 @@ package rules
import (
"fmt"
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// https://curl.se/docs/manpage.html#-u
@@ -13,18 +13,18 @@ func CurlBasicAuth() *config.Rule {
r := config.Rule{
RuleID: "curl-auth-user",
Description: "Discovered a potential basic authorization token provided in a curl command, which could compromise the curl accessed resource.",
Regex: regexp.MustCompile(`\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})(?:"([^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)`),
Regex: regexp.MustCompile(`\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})("(:[^"]{3,}|[^:"]{3,}:|[^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)`),
Keywords: []string{"curl"},
Entropy: 2,
Allowlists: []config.Allowlist{
{
Regexes: []*regexp.Regexp{
regexp.MustCompile(`[^:]+:(change(it|me)|pass(word)?|pwd|test|token|\*+|x+)`), // common placeholder passwords
regexp.MustCompile(`['"]?<[^>]+>['"]?:['"]?<[^>]+>|<[^:]+:[^>]+>['"]?`), // <placeholder>
regexp.MustCompile(`[^:]+:\[[^]]+]`), // [placeholder]
regexp.MustCompile(`['"]?[^:]+['"]?:['"]?\$(\d|\w+|\{(\d|\w+)})['"]?`), // $1 or $VARIABLE
regexp.MustCompile(`\$\([^)]+\):\$\([^)]+\)`), // $(cat login.txt)
regexp.MustCompile(`['"]?\$?{{[^}]+}}['"]?:['"]?\$?{{[^}]+}}['"]?`), // ${{ secrets.FOO }} or {{ .Values.foo }}
regexp.MustCompile(`[^:]+:(?:change(?:it|me)|pass(?:word)?|pwd|test|token|\*+|x+)`), // common placeholder passwords
regexp.MustCompile(`['"]?<[^>]+>['"]?:['"]?<[^>]+>|<[^:]+:[^>]+>['"]?`), // <placeholder>
regexp.MustCompile(`[^:]+:\[[^]]+]`), // [placeholder]
regexp.MustCompile(`['"]?[^:]+['"]?:['"]?\$(?:\d|\w+|\{(?:\d|\w+)})['"]?`), // $1 or $VARIABLE
regexp.MustCompile(`\$\([^)]+\):\$\([^)]+\)`), // $(cat login.txt)
regexp.MustCompile(`['"]?\$?{{[^}]+}}['"]?:['"]?\$?{{[^}]+}}['"]?`), // ${{ secrets.FOO }} or {{ .Values.foo }}
},
},
},
@@ -38,6 +38,8 @@ func CurlBasicAuth() *config.Rule {
-H 'Content-type: text/plain' \
-d 'world' \
-u developer:yqDVtkqPECriaLRi`, // different line
`curl -u ":d2LkV78zLx!t" https://localhost:9200`, // empty username
`curl -u "d2LkV78zLx!t:" https://localhost:9200`, // empty password
// long
`curl -sw '%{http_code}' -X POST --user 'johns:h0pk1ns~21s' $GItHUB_API_URL/$GIT_COMMIT --data`,
@@ -65,6 +67,7 @@ func CurlBasicAuth() *config.Rule {
`curl -u "${_username}:${_password}"`,
`curl -u "${username}":"${password}"`,
`curl -k -X POST -I -u "SRVC_JENKINS:${APPID}"`,
`curl -u ":" https://localhost:9200`, // empty username and password
// long
`curl -sw '%{http_code}' -X POST --user '$USERNAME:$PASSWORD' $GItHUB_API_URL/$GIT_COMMIT --data`,
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func Doppler() *config.Rule {
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func Duffel() *config.Rule {
+3 -5
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func Dynatrace() *config.Rule {
@@ -16,7 +14,7 @@ func Dynatrace() *config.Rule {
Description: "Detected a Dynatrace API token, potentially risking application performance monitoring and data exposure.",
Regex: regexp.MustCompile(`dt0c01\.(?i)[a-z0-9]{24}\.[a-z0-9]{64}`),
Entropy: 4,
Keywords: []string{"dt0c01"},
Keywords: []string{"dt0c01."},
}
// validate
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func EasyPost() *config.Rule {
+4 -3
View File
@@ -34,14 +34,15 @@ func FacebookAccessToken() *config.Rule {
RuleID: "facebook-access-token",
Description: "Discovered a Facebook Access Token, posing a risk of unauthorized access to Facebook accounts and personal data exposure.",
Regex: utils.GenerateUniqueTokenRegex(`\d{15,16}(\||%)[0-9a-z\-_]{27,40}`, true),
Keywords: []string{"facebook"},
Entropy: 3,
}
// validate
tps := []string{
`{"access_token":"911602140448729|AY-lRJZq9BoDLobvAiP25L7RcMg","token_type":"bearer"}`, // gitleaks:allow
`1308742762612587|rhoK1cbv0DOU_RTX_87O4MkX7AI`, // gitleaks:allow
`1477036645700765|wRPf2v3mt2JfMqCLK8n7oltrEmc`, // gitleaks:allow
`{"facebook access_token":"911602140448729|AY-lRJZq9BoDLobvAiP25L7RcMg","token_type":"bearer"}`, // gitleaks:allow
`facebook 1308742762612587|rhoK1cbv0DOU_RTX_87O4MkX7AI`, // gitleaks:allow
`facebook 1477036645700765|wRPf2v3mt2JfMqCLK8n7oltrEmc`, // gitleaks:allow
}
return utils.Validate(r, tps, nil)
}
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func FlutterwavePublicKey() *config.Rule {
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func FrameIO() *config.Rule {
+1 -2
View File
@@ -1,10 +1,9 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func Freemius() *config.Rule {
+42 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// TODO this one could probably use some work
@@ -36,6 +34,29 @@ func GCPAPIKey() *config.Rule {
Keywords: []string{
"AIza",
},
Allowlists: []config.Allowlist{
{
Regexes: []*regexp.Regexp{
// example keys from https://github.com/firebase/firebase-android-sdk
regexp.MustCompile(`AIzaSyabcdefghijklmnopqrstuvwxyz1234567`),
regexp.MustCompile(`AIzaSyAnLA7NfeLquW1tJFpx_eQCxoX-oo6YyIs`),
regexp.MustCompile(`AIzaSyCkEhVjf3pduRDt6d1yKOMitrUEke8agEM`),
regexp.MustCompile(`AIzaSyDMAScliyLx7F0NPDEJi1QmyCgHIAODrlU`),
regexp.MustCompile(`AIzaSyD3asb-2pEZVqMkmL6M9N6nHZRR_znhrh0`),
regexp.MustCompile(`AIzayDNSXIbFmlXbIE6mCzDLQAqITYefhixbX4A`),
regexp.MustCompile(`AIzaSyAdOS2zB6NCsk1pCdZ4-P6GBdi_UUPwX7c`),
regexp.MustCompile(`AIzaSyASWm6HmTMdYWpgMnjRBjxcQ9CKctWmLd4`),
regexp.MustCompile(`AIzaSyANUvH9H9BsUccjsu2pCmEkOPjjaXeDQgY`),
regexp.MustCompile(`AIzaSyA5_iVawFQ8ABuTZNUdcwERLJv_a_p4wtM`),
regexp.MustCompile(`AIzaSyA4UrcGxgwQFTfaI3no3t7Lt1sjmdnP5sQ`),
regexp.MustCompile(`AIzaSyDSb51JiIcB6OJpwwMicseKRhhrOq1cS7g`),
regexp.MustCompile(`AIzaSyBF2RrAIm4a0mO64EShQfqfd2AFnzAvvuU`),
regexp.MustCompile(`AIzaSyBcE-OOIbhjyR83gm4r2MFCu4MJmprNXsw`),
regexp.MustCompile(`AIzaSyB8qGxt4ec15vitgn44duC5ucxaOi4FmqE`),
regexp.MustCompile(`AIzaSyA8vmApnrHNFE0bApF4hoZ11srVL_n0nvY`),
},
},
},
}
// validate
@@ -49,6 +70,23 @@ func GCPAPIKey() *config.Rule {
`AIzaTesb6Tscfcni8vIpWZqNCXFDFslJtVSvFDqabcd123`, // text boundary end
`apiKey: "AIzaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"`, // not enough entropy
`AIZASYCO2CXRMC9ELSKLHLHRMBSWDEVEDZTLO2O`, // incorrect case
// example keys from https://github.com/firebase/firebase-android-sdk
`AIzaSyabcdefghijklmnopqrstuvwxyz1234567`,
`AIzaSyAnLA7NfeLquW1tJFpx_eQCxoX-oo6YyIs`,
`AIzaSyCkEhVjf3pduRDt6d1yKOMitrUEke8agEM`,
`AIzaSyDMAScliyLx7F0NPDEJi1QmyCgHIAODrlU`,
`AIzaSyD3asb-2pEZVqMkmL6M9N6nHZRR_znhrh0`,
`AIzayDNSXIbFmlXbIE6mCzDLQAqITYefhixbX4A`,
`AIzaSyAdOS2zB6NCsk1pCdZ4-P6GBdi_UUPwX7c`,
`AIzaSyASWm6HmTMdYWpgMnjRBjxcQ9CKctWmLd4`,
`AIzaSyANUvH9H9BsUccjsu2pCmEkOPjjaXeDQgY`,
`AIzaSyA5_iVawFQ8ABuTZNUdcwERLJv_a_p4wtM`,
`AIzaSyA4UrcGxgwQFTfaI3no3t7Lt1sjmdnP5sQ`,
`AIzaSyDSb51JiIcB6OJpwwMicseKRhhrOq1cS7g`,
`AIzaSyBF2RrAIm4a0mO64EShQfqfd2AFnzAvvuU`,
`AIzaSyBcE-OOIbhjyR83gm4r2MFCu4MJmprNXsw`,
`AIzaSyB8qGxt4ec15vitgn44duC5ucxaOi4FmqE`,
`AIzaSyA8vmApnrHNFE0bApF4hoZ11srVL_n0nvY`,
}
return utils.Validate(r, tps, fps)
}
+101 -26
View File
@@ -1,11 +1,10 @@
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"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func GenericCredential() *config.Rule {
@@ -20,11 +19,10 @@ func GenericCredential() *config.Rule {
"credential",
"creds",
"key",
"passwd",
"password",
"passw(?:or)?d",
"secret",
"token",
}, `[\w.=-]{10,150}`, true),
}, `[\w.=-]{10,150}|[a-z0-9][a-z0-9+/]{11,}={0,3}`, true),
Keywords: []string{
"access",
"api",
@@ -39,17 +37,25 @@ func GenericCredential() *config.Rule {
},
Entropy: 3.5,
Allowlists: []config.Allowlist{
{
// NOTE: this is a goofy hack to get around the fact there golang's regex engine does not support positive lookaheads.
// Ideally we would want to ensure the secret contains both numbers and alphabetical characters, not just alphabetical characters.
Regexes: []*regexp.Regexp{
regexp.MustCompile(`^[a-zA-Z_.-]+$`),
},
},
{
Description: "Allowlist for Generic API Keys",
MatchCondition: config.AllowlistMatchOr,
RegexTarget: "match",
Regexes: []*regexp.Regexp{
regexp.MustCompile(`(?i)(` +
regexp.MustCompile(`(?i)(?:` +
// Access
`accessor` +
`access(?:ibility|or)` +
`|access[_.-]?id` +
`|random[_.-]?access` +
// API
`|api[_.-]?(version|id)` + // version/id -> not a secret
`|api[_.-]?(?:id|name|version)` + // id/name/version -> not a secret
`|rapid|capital` + // common words containing "api"
`|[a-z0-9-]*?api[a-z0-9-]*?:jar:` + // Maven META-INF dependencies that contain "api" in the name.
// Auth
@@ -57,26 +63,57 @@ func GenericCredential() *config.Rule {
`|X-MS-Exchange-Organization-Auth` + // email header
`|Authentication-Results` + // email header
// Credentials
`|(credentials?[_.-]?id|withCredentials)` + // Jenkins plugins
`|(?:credentials?[_.-]?id|withCredentials)` + // Jenkins plugins
// Key
`|(bucket|foreign|hot|natural|primary|schema|sequence)[_.-]?key` +
`|key[_.-]?(alias|board|code|ring|selector|size|stone|storetype|word|up|down|left|right)` +
`|key(store|tab)[_.-]?(file|path)` +
`|(?:bucket|foreign|hot|idx|natural|primary|pub(?:lic)?|schema|sequence)[_.-]?key` +
`|key[_.-]?(?:alias|board|code|frame|id|length|mesh|name|pair|press(?:ed)?|ring|selector|signature|size|stone|storetype|word|up|down|left|right)` +
// Azure KeyVault
`|key[_.-]?vault[_.-]?(?:id|name)|keyVaultToStoreSecrets` +
`|key(?:store|tab)[_.-]?(?:file|path)` +
`|issuerkeyhash` + // part of ssl cert
`|(?-i:[DdMm]onkey|[DM]ONKEY)|keying` + // common words containing "key"
// Secret
`|(secret)[_.-]?name` + // name of e.g. env variable
`|(?:secret)[_.-]?(?:length|name|size)` + // name of e.g. env variable
`|UserSecretsId` + // https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-8.0&tabs=linux
// Token
`|(?:csrf)[_.-]?token` +
`|(?:io\.jsonwebtoken[ \t]?:[ \t]?[\w-]+)` + // Maven library coordinats. (e.g., https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt)
// General
`|(api|credentials|token)[_.-]?(endpoint|ur[il])` +
`|public[_.-]?(key|token)` + // public key -> not a secret
`|(key|token)[_.-]?file` +
`|(?:api|credentials|token)[_.-]?(?:endpoint|ur[il])` +
`|public[_.-]?token` +
`|(?:key|token)[_.-]?file` +
// Empty variables capturing the next line (e.g., .env files)
`|(?-i:(?:[A-Z_]+=\n[A-Z_]+=|[a-z_]+=\n[a-z_]+=)(?:\n|\z))` +
`|(?-i:(?:[A-Z.]+=\n[A-Z.]+=|[a-z.]+=\n[a-z.]+=)(?:\n|\z))` +
`)`),
},
StopWords: DefaultStopWords,
StopWords: append(DefaultStopWords,
"6fe4476ee5a1832882e326b506d14126", // https://github.com/yarnpkg/berry/issues/6201
),
},
{
RegexTarget: "line",
Regexes: []*regexp.Regexp{
// Docker build secrets (https://docs.docker.com/build/building/secrets/#using-build-secrets).
regexp.MustCompile(`--mount=type=secret,`),
},
},
{
MatchCondition: config.AllowlistMatchAnd,
RegexTarget: "line",
Regexes: []*regexp.Regexp{
regexp.MustCompile(`LICENSE[^=]*=\s*"[^"]+`),
regexp.MustCompile(`LIC_FILES_CHKSUM[^=]*=\s*"[^"]+`),
regexp.MustCompile(`SRC[^=]*=\s*"[a-zA-Z0-9]+`),
},
Paths: []*regexp.Regexp{
regexp.MustCompile(`\.bb$`),
regexp.MustCompile(`\.bbappend$`),
regexp.MustCompile(`\.bbclass$`),
regexp.MustCompile(`\.inc$`),
},
},
},
}
@@ -92,6 +129,8 @@ func GenericCredential() *config.Rule {
`some_api_token_123 = "`+newPlausibleSecret(`[a-zA-Z0-9]{60}`)+`"`,
// Auth
`"user_auth": "am9obmRvZTpkMDY5NGIxYi1jMTcxLTQ4ODYt+TMyYS0wMmUwOWQ1/mIwNjc="`,
// Credentials
`"credentials" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506"`,
`creds = `+newPlausibleSecret(`[a-zA-Z0-9]{30}`),
@@ -109,13 +148,17 @@ func GenericCredential() *config.Rule {
`todo_secret_do_not_commit = `+newPlausibleSecret(`[a-zA-Z0-9]{30}`),
// Token
utils.GenerateSampleSecret("generic", "CLOJARS_34bf0e88955ff5a1c328d6a7491acc4f48e865a7b8dd4d70a70749037443"), //gitleaks:allow
utils.GenerateSampleSecret("generic", "Zf3D0LXCM3EIMbgJpUNnkRtOfOueHznB"),
` utils.GetEnvOrDefault("api_token", "dafa7817-e246-48f3-91a7-e87653d587b8")`,
// `"env": {
//"API_TOKEN": "Lj2^5O%xi214"`,
)
fps := []string{
// Access
`"accessor":"rA1wk0Y45YCufyfq",`,
`report_access_id: e8e4df51-2054-49b0-ab1c-516ac95c691d`,
`accessibilityYesOptionId = "0736f5ef-7e88-499a-80cc-90c85d2a5180"`,
`_RandomAccessIterator>
_LIBCPP_CONSTEXPR_AFTER_CXX11 `,
// API
`this.ultraPictureBox1.Name = "ultraPictureBox1";`,
@@ -126,8 +169,9 @@ func GenericCredential() *config.Rule {
`[DEBUG] org.slf4j.slf4j-api:jar:1.7.8.:compile (version managed from default)`,
`[DEBUG] org.neo4j.neo4j-graphdb-api:jar:3.5.12:test`,
`apiUrl=apigee.corpint.com`,
`X-API-Name": "NRG0-Hermes-INTERNAL-API",`,
// TODO: Jetbrains IML files (requires line-level allowlist).
//`<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.directory.api:api-asn1-api:1.0.0-M20" level="projcet" />`
// `<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.directory.api:api-asn1-api:1.0.0-M20" level="projcet" />`
// Auth
`author = "james.fake@ymail.com",`,
@@ -147,6 +191,8 @@ func GenericCredential() *config.Rule {
// Key
`keyword: "Befaehigung_P2"`,
`public_key = "9Cnzj4p4WGeKLs1Pt8QuKUpRKfFLfRYC9AIKjbJTWit"`,
`pub const X509_pubkey_st = struct_X509_pubkey_st;`,
`|| pIdxKey->default_rc==0`,
`monkeys-audio:mx64-uwp=fail`,
`primaryKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
`foreignKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
@@ -156,9 +202,8 @@ func GenericCredential() *config.Rule {
`minisat-master-keying:x64-uwp=fail`,
`IceSSL.KeyFile=s_rsa1024_priv.pem`,
`"bucket_key": "SalesResults-1.2"`,
//`<TAR key="REF_ID_923.properties" value="/opts/config/alias/"/>`,
`<key tag="SecurityIdentifier" name="SecurityIdentifier" type="STRING" />`,
//`packageKey":` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
// `packageKey":` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
`schemaKey = 'DOC_Vector_5_32'`,
`sequenceKey = "18"`,
`app.keystore.file=env/cert.p12`,
@@ -166,10 +211,25 @@ func GenericCredential() *config.Rule {
` doc.Security.KeySize = PdfEncryptionKeySize.Key128Bit;`,
`o.keySelector=n,o.haKey=!1,`,
// TODO: Requires line-level allowlists.
//`<add key="SchemaTable" value="G:\SchemaTable.xml" />`,
` "key_name": "prod5zyxlmy-cmk",`,
` "kms_key_id": "555ea4a3-d53a-4412-9c66-3a7cb667b0d6",`,
` "key_vault_name": "web21prqodx24021",`,
` keyVaultToStoreSecrets: cmp2-qat-1208358310`, // e.g., https://github.com/2uasimojo/community-operators-prod/blob/9e51e4c8e0b5caaa3087e8e18e6fb918b2c36643/operators/azure-service-operator/1.0.59040/manifests/azure.microsoft.com_cosmosdbs.yaml#L50
`,apiKey:"6fe4476ee5a1832882e326b506d14126",`,
`const validKeyChars = "0123456789abcdefghijklmnopqrstuvwxyz_-."`,
`const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"`,
`key_length = XSalsa20.key_length`,
`pub const SN_id_Gost28147_89_None_KeyMeshing = "id-Gost28147-89-None-KeyMeshing"`,
`KeyPair = X25519.KeyPair`,
`BlindKeySignatures = Ed25519.BlindKeySignatures`,
`AVEncVideoMaxKeyframeDistance, "2987123a-ba93-4704-b489-ec1e5f25292c"`,
` keyPressed = kVK_Return.u16`,
// `<add key="SchemaTable" value="G:\SchemaTable.xml" />`,
//` { key: '9df21e95-3848-409d-8f94-c675cdfee839', value: 'Americas' },`,
// `<TAR key="REF_ID_923.properties" value="/opts/config/alias/"/>`,
// `secret:
//secretName: app-decryption-secret
//items:
// secretName: app-decryption-secret
// items:
// - key: app-k8s.yml
// path: app-k8s.yml`,
@@ -185,15 +245,30 @@ R5: Regulatory--21`,
// Secret
`LLM_SECRET_NAME = "NEXUS-GPT4-API-KEY"`,
` <UserSecretsId>79a3edd0-2092-40a2-a04d-dcb46d5ca9ed</UserSecretsId>`,
`secret_length = X25519.secret_length`,
`secretSize must be >= XXH3_SECRET_SIZE_MIN`,
`# get build time secret for authentication
#RUN --mount=type=secret,id=jfrog_secret \
# JFROG_SECRET = $(cat /run/secrets/jfrog_secret) && \`,
// Token
` access_token_url='https://github.com/login/oauth/access_token',`,
`publicToken = "9Cnzj4p4WGeKLs1Pt8QuKUpRKfFLfRYC9AIKjbJTWit"`,
`<SourceFile SourceLocation="F:\Extracts\" TokenFile="RTL_INST_CODE.cer">`,
`notes = "Maven - io.jsonwebtoken:jjwt-jackson-0.11.2"`,
`csrf-token=Mj2qykJO5rELyHgezQ69nzUX0i3OH67V7+V4eUrLfpuyOuxmiW9rhROG/Whikle15syazJOkrjJa3U2AbhIvUw==`,
// TODO: `TOKEN_AUDIENCE = "25872395-ed3a-4703-b647-22ec53f3683c"`,
// General
`clientId = "73082700-1f09-405b-80d0-3131bfd6272d"`,
`GITHUB_API_KEY=
DYNATRACE_API_KEY=`,
`snowflake.password=
jdbc.snowflake.url=`,
// Yocto/BitBake
`SRCREV_moby = "43fc912ef59a83054ea7f6706df4d53a7dea4d80"`,
`LIC_FILES_CHKSUM = "file://${WORKDIR}/license.html;md5=5c94767cedb5d6987c902ac850ded2c6"`,
}
return utils.Validate(r, tps, fps)
}
@@ -209,7 +284,7 @@ func newPlausibleSecret(regex string) string {
if !regexp.MustCompile(`[1-9]`).MatchString(secret) {
continue
}
if allowList.ContainsStopWord(secret) {
if ok, _ := allowList.ContainsStopWord(secret); ok {
continue
}
return secret
+3 -5
View File
@@ -1,19 +1,17 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
var githubAllowlist = []config.Allowlist{
{
Paths: []*regexp.Regexp{
// https://github.com/octokit/auth-token.js/?tab=readme-ov-file#createtokenauthtoken-options
regexp.MustCompile(`(^|/)@octokit/auth-token/README\.md$`),
regexp.MustCompile(`(?:^|/)@octokit/auth-token/README\.md$`),
},
},
}
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// overview with all GitLab tokens:
+2 -5
View File
@@ -1,13 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func HarnessApiKey() *config.Rule {
+2 -3
View File
@@ -2,12 +2,11 @@ package rules
import (
"fmt"
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func HashiCorpTerraform() *config.Rule {
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func VaultServiceToken() *config.Rule {
+1
View File
@@ -59,5 +59,6 @@ func JFrogIdentityToken() *config.Rule {
tps = append(tps, utils.GenerateSampleSecrets("artifactory", secrets.NewSecret(utils.AlphaNumeric("64")))...)
tps = append(tps, utils.GenerateSampleSecrets("bintray", secrets.NewSecret(utils.AlphaNumeric("64")))...)
tps = append(tps, utils.GenerateSampleSecrets("xray", secrets.NewSecret(utils.AlphaNumeric("64")))...)
tps = append(tps, fmt.Sprintf("\"artifactory\", \"%s\"", secrets.NewSecret(utils.AlphaNumeric("64"))))
return utils.Validate(r, tps, nil)
}
+1 -1
View File
@@ -3,11 +3,11 @@ package rules
import (
b64 "encoding/base64"
"fmt"
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func JWT() *config.Rule {
+23 -21
View File
@@ -2,11 +2,10 @@ package rules
import (
"fmt"
"regexp"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// KubernetesSecret validates if we detected a kubernetes secret which contains data!
@@ -40,9 +39,13 @@ func KubernetesSecret() *config.Rule {
// variable: ""
// variable: ''
regexp.MustCompile(`[\w.-]+:(?:[ \t]*(?:\||>[-+]?)\s+)?[ \t]*(?:\{\{[ \t\w"|$:=,.-]+}}|""|'')`),
// TODO: Requires multiple allowlists to target match.
// Avoid overreach between directives.
//regexp.MustCompile(`(kind:(.|\s)+\n---\n(.|\s)+\bdata:|data:(.|\s)+\n---\n(.|\s)+\bkind:)`),
},
},
{
// Avoid overreach between directives.
RegexTarget: "match",
Regexes: []*regexp.Regexp{
regexp.MustCompile(`(kind:(?:.|\s)+\n---\n(?:.|\s)+\bdata:|data:(?:.|\s)+\n---\n(?:.|\s)+\bkind:)`),
},
},
},
@@ -244,21 +247,20 @@ metadata:
namespace: kubernetes-dashboard
type: Opaque
`,
// TODO: Requires multiple allowlists.
// "overly-permissive3.yaml": ` kind: Secret
// target:
// name: mysecret
// creationPolicy: Owner
//
//---
//
//kind: ConfigMap
// data:
// conversionStrategy: Default
// decodingStrategy: None
// key: secret/mysecret
// property: foo
// secretKey: foo`,
"overly-permissive3.yaml": ` kind: Secret
target:
name: mysecret
creationPolicy: Owner
---
kind: ConfigMap
data:
conversionStrategy: Default
decodingStrategy: None
key: secret/mysecret
property: foo
secretKey: foo`,
// https://github.com/gitleaks/gitleaks/issues/1644
"wrong-kind.yaml": `apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func LinearAPIToken() *config.Rule {
+29
View File
@@ -0,0 +1,29 @@
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 Meraki() *config.Rule {
// define rule
r := config.Rule{
RuleID: "cisco-meraki-api-key",
Description: "Cisco Meraki is a cloud-managed IT solution that provides networking, security, and device management through an easy-to-use interface.",
Regex: utils.GenerateSemiGenericRegex([]string{`(?-i:[Mm]eraki|MERAKI)`}, `[0-9a-f]{40}`, false),
Entropy: 3,
Keywords: []string{"meraki"},
}
// validate
tps := utils.GenerateSampleSecrets("meraki", secrets.NewSecret(utils.Hex("40")))
fps := []string{
`meraki: aaaaaaaaaa1111111111bbbbbbbbbb2222222222`, // low entropy
`meraki-api-key: acdeFf05b1a6d4c890237bf08c5e6e8d2b4d0f2e`, // invalid case
`meraki: abdefghjk0123456789mnopqrstuvwx12345678`, // invalid character
`meraki_token = 5cb4a5f04cd412fe946667b17f0129ba17aeb2e0c7b5b7264efcebf7d022bfe2R21`, // invalid length
`ReactNativeCameraKit: f15a5a04b0f6dc6073e6db0296e6ef2d8b8d2522`,
}
return utils.Validate(r, tps, fps)
}
+2 -4
View File
@@ -1,11 +1,9 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func NugetConfigPassword() *config.Rule {
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// OpenShift 4 user tokens are prefixed with `sha256~`.
+39 -10
View File
@@ -1,32 +1,61 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func PrivateKey() *config.Rule {
// define 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)?-----`),
Description: "Identified a Private Key, which may compromise cryptographic security and sensitive data encryption.",
Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY(?: BLOCK)?-----[\s\S-]{64,}?KEY(?: BLOCK)?-----`),
Keywords: []string{"-----BEGIN"},
}
// validate
tps := []string{`-----BEGIN PRIVATE KEY-----
anything
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDAC4AWkdwKYSd8
Ks14IReLcYgADhoXk56ZzXI=
-----END PRIVATE KEY-----`,
`-----BEGIN RSA PRIVATE KEY-----
abcdefghijklmnopqrstuvwxyz
MIIEpQIBAAKCAQEAn6/O8li+SX4m98LLYt/PKSzEmQ++ZBD7Loh9P13f4yQ92EF3
yxR5MsXFu9PRsrYQA7/4UTPHiC4y2sAVCBg4C2yyBpUEtMQjyCESi6Y=
-----END RSA PRIVATE KEY-----
`,
`-----BEGIN PRIVATE KEY BLOCK-----
anything
-----END PRIVATE KEY BLOCK-----`,
`-----BEGIN PGP PRIVATE KEY BLOCK-----
lQWGBGSVV4YBDAClvRnxezIRy2Yv7SFlzC0iFiRF/O/jePSw+XYhvcrTaqSYTGic
=8xQN
-----END PGP PRIVATE KEY BLOCK-----`,
} // gitleaks:allow
return utils.Validate(r, tps, nil)
fps := []string{
`-----BEGIN PRIVATE KEY-----
anything
-----END PRIVATE KEY-----`,
`-----BEGIN OPENSSH PRIVATE KEY----------END OPENSSH PRIVATE KEY-----`,
}
return utils.Validate(r, tps, fps)
}
func PrivateKeyPKCS12File() *config.Rule {
// https://en.wikipedia.org/wiki/PKCS_12
r := config.Rule{
RuleID: "pkcs12-file",
Description: "Found a PKCS #12 file, which commonly contain bundled private keys.",
Path: regexp.MustCompile(`(?i)(?:^|\/)[^\/]+\.p(?:12|fx)$`),
}
// validate
tps := map[string]string{
"security/es_certificates/opensearch/es_kibana_client.p12": "",
"cagw_key.P12": "",
"ToDo/ToDo.UWP/ToDo.UWP_TemporaryKey.pfx": "",
}
fps := map[string]string{
"doc/typenum/type.P126.html": "",
"scripts/keeneland/syntest.p1200.sh": "",
}
return utils.ValidateWithPaths(r, tps, fps)
}
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func PyPiUploadToken() *config.Rule {
+5 -2
View File
@@ -2,11 +2,11 @@ package rules
import (
"encoding/base64"
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func SentryAccessToken() *config.Rule {
@@ -43,7 +43,7 @@ func SentryOrgToken() *config.Rule {
r := config.Rule{
RuleID: "sentry-org-token",
Description: "Found a Sentry.io Organization Token, risking unauthorized access to error tracking services and sensitive application data.",
Regex: regexp.MustCompile(`\bsntrys_eyJpYXQiO[a-zA-Z0-9+/]{10,200}(?:LCJyZWdpb25fdXJs|InJlZ2lvbl91cmwi|cmVnaW9uX3VybCI6)[a-zA-Z0-9+/]{10,200}={0,2}_[a-zA-Z0-9+/]{43}\b`),
Regex: regexp.MustCompile(`\bsntrys_eyJpYXQiO[a-zA-Z0-9+/]{10,200}(?:LCJyZWdpb25fdXJs|InJlZ2lvbl91cmwi|cmVnaW9uX3VybCI6)[a-zA-Z0-9+/]{10,200}={0,2}_[a-zA-Z0-9+/]{43}(?:[^a-zA-Z0-9+/]|\z)`),
Entropy: 4.5,
Keywords: []string{"sntrys_eyJpYXQiO"},
}
@@ -52,6 +52,9 @@ func SentryOrgToken() *config.Rule {
tps := utils.GenerateSampleSecrets("sentry",
`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`, // gitleaks:allow
)
tps = append(tps, utils.GenerateSampleSecrets("sentry",
`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`, // gitleaks:allow
)...)
tps = append(tps,
` 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`, // gitleaks:allow
)
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func ShopifySharedSecret() *config.Rule {
+1 -2
View File
@@ -1,11 +1,10 @@
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"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func SidekiqSecret() *config.Rule {
+2 -3
View File
@@ -2,12 +2,11 @@ package rules
import (
"fmt"
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// https://api.slack.com/authentication/token-types#bot
+27
View File
@@ -0,0 +1,27 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
)
func Sonar() *config.Rule {
// define rule
r := config.Rule{
Description: "Uncovered a Sonar API token, potentially compromising software vulnerability scanning and code security.",
RuleID: "sonar-api-token",
Regex: utils.GenerateSemiGenericRegex([]string{"sonar[_.-]?(login|token)"}, utils.AlphaNumericExtended("40"), true),
Keywords: []string{"sonar"},
}
// validate
tps := utils.GenerateSampleSecrets("sonar", "12345678ABCDEFH1234567890ABCDEFH12345678")
tps = append(tps,
`const SONAR_LOGIN = "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
`SONAR_LOGIN := "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
`SONAR.LOGIN ::= "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
`SONAR.LOGIN :::= "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
`SONAR.LOGIN ?= "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
)
return utils.Validate(r, tps, nil)
}
+34
View File
@@ -0,0 +1,34 @@
package rules
import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
)
func SourceGraph() *config.Rule {
// define rule
r := config.Rule{
RuleID: "sourcegraph-access-token",
Description: "Sourcegraph is a code search and navigation engine.",
Regex: utils.GenerateUniqueTokenRegex(`\b(sgp_(?:[a-fA-F0-9]{16}|local)_[a-fA-F0-9]{40}|sgp_[a-fA-F0-9]{40}|[a-fA-F0-9]{40})\b`, true),
Entropy: 3,
Keywords: []string{"sgp_", "sourcegraph"},
}
// validate
tps := []string{
`sgp_AaD80dc6E02eCAE1_d3cba16CC0F18fA14A2EFB61CbDFceEBf9fAD16b`,
`sourcegraph: 6d2FabeB6ADd229Bc199FabA28fD3efb57dF0bD3`,
`sgp_0D697F54cb24238EefB29af05Abf1b505E90950F`,
`sgp_local_d7dfFD43cF2503B1da673EB560aAa3e80f16FA42`,
`sgp_local_bcD1DA18de0d6476Be0f3BD7Ef9Da4f09b479aE5`,
}
fps := []string{
`sgp_5555555dAAAAA7777777CcccCFaaaaaaaaaaaaaa`, // low entropy
`sgp_local_d45b6G86aBb0F2Cee943902dbaDBCFCFDD1dA089`, // invalid case
`sgp_652d9a2e48FC7E!FcDbEA1BC2E2A6CE23cFe7F7D`, // invalid character
`sgp_78Ad84a5B6e8A2fE5B_4085FB0ccaDDd29DB66Fd7FE9bA2C1cdCE8400CD`, // invalid length
`BcAeb6640ad7DAD46AD73687946Ce85047d5C9Bb`,
}
return utils.Validate(r, tps, fps)
}
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func TeamsWebhook() *config.Rule {
+2 -4
View File
@@ -1,12 +1,10 @@
package rules
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func Twilio() *config.Rule {
+37 -30
View File
@@ -6,8 +6,9 @@ package utils
import (
"fmt"
"regexp"
"strings"
"github.com/zricethezav/gitleaks/v8/regexp"
)
const (
@@ -18,17 +19,16 @@ const (
identifierCaseInsensitivePrefix = `[\w.-]{0,50}?(?i:`
identifierCaseInsensitiveSuffix = `)`
identifierPrefix = `[\w.-]{0,50}?(?:`
identifierSuffix = `)(?:[ \t\w.-]{0,20})(?:[\s|']|[\s|"]){0,3}`
identifierSuffix = `)(?:[ \t\w.-]{0,20})[\s'"]{0,3}`
// commonly used assignment operators or function call
//language=regexp
operator = `(?:=|>|:{1,3}=|\|\|:|<=|=>|:|\?=)`
operator = `(?:=|>|:{1,3}=|\|\||:|=>|\?=|,)`
// boundaries for the secret
// \x60 = `
secretPrefixUnique = `\b(`
secretPrefix = `(?:'|\"|\s|=|\x60){0,5}(`
secretSuffix = `)(?:['|\"|\n|\r|\s|\x60|;]|$)`
secretPrefix = `[\x60'"\s=]{0,5}(`
secretSuffix = `)(?:[\x60'"\s;]|\\[nr]|$)`
)
func GenerateSemiGenericRegex(identifiers []string, secretRegex string, isCaseInsensitive bool) *regexp.Regexp {
@@ -92,20 +92,21 @@ func GenerateSampleSecrets(identifier string, secret string) []string {
"ini - unquoted2": "{i}Token = {s}",
// JSON
"json - string": "{\n \"{i}_token\": \"{s}\"\n}",
//TODO: "json - escaped string": "\\{\n \\\"{i}_token\\\": \\\"{s}\\\"\n\\}",
//TODO: "json - string key/value": "{\n \"name\": \"{i}_token\",\n \"value\": \"{s}\"\n}",
// TODO: "json - escaped string": "\\{\n \\\"{i}_token\\\": \\\"{s}\\\"\n\\}",
// TODO: "json - string key/value": "{\n \"name\": \"{i}_token\",\n \"value\": \"{s}\"\n}",
"json - escaped newline in string": `{"config.ini": "{I}_TOKEN={s}\nBACKUP_ENABLED=true"}`,
// XML
//TODO: "xml - element": "<{i}Token>{s}</{i}Token>",
// TODO: "xml - element": "<{i}Token>{s}</{i}Token>",
"xml - element multiline": "<{i}Token>\n {s}\n</{i}Token>",
//TODO: "xml - attribute": "<entry name=\"{i}Token\" value=\"{s}\" />",
//TODO: "xml - key/value elements": "<entry>\n <name=\"{i}Token\" />\n <value=\"{s}\" />\n</entry>",
// TODO: "xml - attribute": "<entry name=\"{i}Token\" value=\"{s}\" />",
// TODO: "xml - key/value elements": "<entry>\n <name=\"{i}Token\" />\n <value=\"{s}\" />\n</entry>",
// YAML
"yaml - singleline - unquoted": "{i}_token: {s}",
"yaml - singleline - single quote": "{i}_token: '{s}'",
"yaml - singleline - double quote": "{i}_token: \"{s}\"",
//TODO: "yaml - multiline - literal": "{i}_token: |\n {s}",
//TODO: "yaml - multiline - folding": "{i}_token: >\n {s}",
//"": "",
// TODO: "yaml - multiline - literal": "{i}_token: |\n {s}",
// TODO: "yaml - multiline - folding": "{i}_token: >\n {s}",
// "": "",
// Programming Languages
"C#": `string {i}Token = "{s}";`,
@@ -113,26 +114,28 @@ func GenerateSampleSecrets(identifier string, secret string) []string {
"go - short": `{i}Token := "{s}"`,
"go - backticks": "{i}Token := `{s}`",
"java": "String {i}Token = \"{s}\";",
//TODO: "java - escaped quotes": `config.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"JDOE35\" {i}Token=\"{s}\""`,
//TODO:"kotlin - type": "var {i}Token: string = \"{s}\"",
// TODO: "java - escaped quotes": `config.put("sasl.jaas.config", "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"JDOE35\" {i}Token=\"{s}\""`,
// TODO:"kotlin - type": "var {i}Token: string = \"{s}\"",
"kotlin - notype": "var {i}Token = \"{s}\"",
"php - string concat": `${i}Token .= "{s}"`,
//TODO: "php - null coalesce": `${i}Token ??= "{s}"`,
// TODO: "php - null coalesce": `${i}Token ??= "{s}"`,
"python - single quote": "{i}Token = '{s}'",
"python - double quote": `{i}Token = "{s}"`,
//"": "",
// "": "",
// Miscellaneous
//TODO: "url - basic auth": `https://{i}:{s}@example.com/`,
//TODO: "url - query parameter": "https://example.com?{i}Token={s}&fooBar=baz",
//TODO: "comment - slash": "//{s} is the password",
//TODO: "comment - slash multiline": "/*{s} is the password",
//TODO: "comment - hashtag": "#{s} is the password",
//TODO: "comment - semicolon": ";{s} is the password",
//TODO: "csv - unquoted": `{i}Token,{s},`,
// TODO: "url - basic auth": `https://{i}:{s}@example.com/`,
// TODO: "url - query parameter": "https://example.com?{i}Token={s}&fooBar=baz",
// TODO: "comment - slash": "//{s} is the password",
// TODO: "comment - slash multiline": "/*{s} is the password",
// TODO: "comment - hashtag": "#{s} is the password",
// TODO: "comment - semicolon": ";{s} is the password",
// TODO: "csv - unquoted": `{i}Token,{s},`,
"misc - comma operator": `System.setProperty("{I}_TOKEN", "{s}")`,
// TODO: "misc - comma suffix": `environmentVariables = {PATH=/usr/local/bin, ENV=/etc/bashrc, {I}_PASSWORD={s}, LC_CTYPE=en_CA.UTF-8},`, // Spotted in `./Library/Logs/gradle-kotlin-dsl-resolver-xxxx.log`
"logstash": " \"{i}Token\" => \"{s}\"",
//TODO: "sql - tabular": "|{s}|",
//TODO: "sql": "",
// TODO: "sql - tabular": "|{s}|",
// TODO: "sql": "",
// Makefile
// See: https://github.com/gitleaks/gitleaks/pull/1191
@@ -141,12 +144,16 @@ func GenerateSampleSecrets(identifier string, secret string) []string {
"make - shell assignment": "{i}_TOKEN ::= \"{s}\"",
"make - evaluated shell assignment": "{i}_TOKEN :::= \"{s}\"",
"make - conditional assignment": "{i}_TOKEN ?= \"{s}\"",
//TODO: "make - append": "{i}_TOKEN += \"{s}\"",
// TODO: "make - append": "{i}_TOKEN += \"{s}\"",
//"": "",
// "": "",
}
replacer := strings.NewReplacer("{i}", identifier, "{s}", secret)
replacer := strings.NewReplacer(
"{i}", identifier,
"{I}", strings.ToUpper(identifier),
"{s}", secret,
)
cases := make([]string, 0, len(samples))
for _, v := range samples {
cases = append(cases, replacer.Replace(v))
+235
View File
@@ -0,0 +1,235 @@
package utils
import (
"testing"
)
func TestGenerateSemiGenericRegex(t *testing.T) {
tests := []struct {
name string
identifiers []string
secretRegex string
isCaseInsensitive []bool
validStrings []string
invalidStrings []string
}{
{
name: "secret is case sensitive, if isCaseInsensitive is false",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{false},
validStrings: []string{"api_key=xxx"},
invalidStrings: []string{"api_key=XXX", "api_key=xXx"},
},
{
name: "secret is case insensitive, if isCaseInsensitive is true",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true},
validStrings: []string{"api_key=xxx", "api_key=XXX", "api_key=xXx"},
invalidStrings: []string{"api_key=x!x"},
},
{
name: "identifier is case insensitive, regardless of isCaseInsensitive",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{"api_key=xxx", "ApI_KeY=xxx", "aPi_kEy=xxx", "API_KEY=xxx"},
invalidStrings: []string{"api!key=xxx"},
},
{
name: "identifier can be case sensitive",
identifiers: []string{"(?-i:[Aa]pi_?[Kk]ey|API_?KEY)"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{"apikey=xxx", "ApiKey=xxx", "Apikey=xxx", "APIKEY=xxx", "api_key=xxx"},
invalidStrings: []string{"ApIKeY=xxx", "aPikEy=xxx"},
},
{
name: "identifier can be part of a longer word",
identifiers: []string{"key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{"mykey=xxx", "keys=xxx", "key1=xxx", "keystore=xxx", "monkey=xxx"},
invalidStrings: []string{},
},
{
name: "identifier may be followed by specific characters",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{
"api_key-----=xxx",
"api_key.....=xxx",
"api_key_____=xxx",
"'''api_key'''=xxx",
`"""api_key"""=xxx`,
"api_key =xxx",
"api_key\t\t\t\t\t=xxx",
"api_key\n\n\n=xxx", // potentially invalid?,
"api_key\r\n=xxx",
// "api_key|||=xxx",
},
invalidStrings: []string{
"api_key&=xxx",
"$api_key$=xxx",
"%api_key%=xxx",
"api_key[0]=xxx",
"api_key/*REMOVE*/=xxx",
},
},
{
name: "identifier and secret must be separated by specific operators",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{
"api_key=xxx",
"api_key: xxx",
"<api_key>xxx",
"api_key:=xxx",
"api_key:::=xxx",
// "api_key||:=xxx", // this isn't anything
// "api_key <= xxx",
"api_key => xxx",
"api_key ?= xxx",
"api_key, xxx",
},
invalidStrings: []string{
"api_keyxxx",
"api_key\txxx", // potentially valid in a tab-separated file
"api_key; xxx",
"api_key<xxx>",
"api_key&xxx",
"api_key = true ? 'xxx' : 'yyy'",
},
},
{
name: "secret is limited by specific boundaries",
identifiers: []string{"api_key"},
secretRegex: `[a-z]{3}`,
isCaseInsensitive: []bool{true, false},
validStrings: []string{
"api_key= xxx ",
"api_key=xxx\n",
"api_key=xxx\r\n",
"api_key=\n\n\n\n\nxxx", // potentially invalid (e.g. .env.example)
"api_key=\r\n\r\nxxx",
"api_key=\t\t\t\txxx\t",
"api_key======xxx;",
"api_key='''xxx'''",
`api_key="""xxx"""`,
"api_key=```xxx```",
`api_key="xxx'`, // could try to match only same opening and closing quotes, might not be worth the complexity
`api_key="don't do it!"`,
`api_key="xxx;notpartofthematch"`,
},
invalidStrings: []string{
"api_key=_xxx",
"api_key=xxx_",
"api_key=$xxx",
"api_key=%xxx%",
"api_key=[xxx]",
"api_key=(xxx)",
"api_key=<xxx>",
"api_key={xxx}",
"<api_key>xxx</api_key>", // potentially valid
"example.com?api_key=xxx&other=yyy", // potentially valid
},
},
// Note: these test cases do not necessarily prescribe the expected behavior of the function,
// but rather document the current behavior, to ensure that future changes are intentional.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
for _, isCaseInsensitive := range tt.isCaseInsensitive {
regex := GenerateSemiGenericRegex(tt.identifiers, tt.secretRegex, isCaseInsensitive)
for _, validString := range tt.validStrings {
if !regex.MatchString(validString) {
t.Errorf("Expected match, but got none, \nfor GenerateSemiGenericRegex(%v, /%v/, caseInsensitive=%v).MatchString(`%v`)\n%v",
tt.identifiers, tt.secretRegex, isCaseInsensitive, validString, regex)
}
}
for _, invalidString := range tt.invalidStrings {
if regex.MatchString(invalidString) {
t.Errorf("Expected no match, but got one, \nfor GenerateSemiGenericRegex(%v, /%v/, caseInsensitive=%v).MatchString(`%v`)\n%v",
tt.identifiers, tt.secretRegex, isCaseInsensitive, invalidString, regex)
}
}
}
})
}
}
func TestGenerateUniqueTokenRegex(t *testing.T) {
tests := []struct {
name string
secretRegex string
isCaseInsensitive bool
validStrings []string
invalidStrings []string
}{
{
name: "case sensitive secret",
secretRegex: `[a-c]{3}`,
isCaseInsensitive: false,
validStrings: []string{"abc"},
invalidStrings: []string{"ABC", "Abc"},
},
{
name: "case insensitive secret",
secretRegex: `[a-c]{3}`,
isCaseInsensitive: true,
validStrings: []string{"abc", "ABC", "Abc"},
invalidStrings: []string{"123"},
},
{
name: "allowed boundaries",
secretRegex: `[a-c]{3}`,
isCaseInsensitive: false,
validStrings: []string{
"abc",
" abc ",
"\nabc\n",
"\r\nabc\r\n",
"\tabc\t",
"'abc'",
`"abc"`,
"```abc```",
"my abc's",
".com?abc",
},
invalidStrings: []string{
"abcabc",
"_abc_",
".com?abc&def", // potentially valid
"/*abc*/",
"<abc>",
"<str>abc</str>", // potentially valid
"{{{abc}}}",
"abc, d",
},
},
// Note: these test cases do not necessarily prescribe the expected behavior of the function,
// but rather document the current behavior, to ensure that future changes are intentional.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
regex := GenerateUniqueTokenRegex(tt.secretRegex, tt.isCaseInsensitive)
for _, validString := range tt.validStrings {
if !regex.MatchString(validString) {
t.Errorf("Expected match, but got none, \nfor GenerateUniqueTokenRegex(/%v/, caseInsensitive=%v).MatchString(`%v`)\n%v",
tt.secretRegex, tt.isCaseInsensitive, validString, regex)
}
}
for _, invalidString := range tt.invalidStrings {
if regex.MatchString(invalidString) {
t.Errorf("Expected no match, but got one, \nfor GenerateUniqueTokenRegex(/%v/, caseInsensitive=%v).MatchString(`%v`)\n%v",
tt.secretRegex, tt.isCaseInsensitive, invalidString, regex)
}
}
})
}
}
+5 -6
View File
@@ -7,11 +7,10 @@ package utils
import (
"strings"
"github.com/rs/zerolog/log"
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/base"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/detect"
"github.com/zricethezav/gitleaks/v8/logging"
)
func Validate(rule config.Rule, truePositives []string, falsePositives []string) *config.Rule {
@@ -19,7 +18,7 @@ func Validate(rule config.Rule, truePositives []string, falsePositives []string)
d := createSingleRuleDetector(r)
for _, tp := range truePositives {
if len(d.DetectString(tp)) < 1 {
log.Fatal().
logging.Fatal().
Str("rule", r.RuleID).
Str("value", tp).
Str("regex", r.Regex.String()).
@@ -29,7 +28,7 @@ func Validate(rule config.Rule, truePositives []string, falsePositives []string)
for _, fp := range falsePositives {
findings := d.DetectString(fp)
if len(findings) != 0 {
log.Fatal().
logging.Fatal().
Str("rule", r.RuleID).
Str("value", fp).
Str("regex", r.Regex.String()).
@@ -45,7 +44,7 @@ func ValidateWithPaths(rule config.Rule, truePositives map[string]string, falseP
for path, tp := range truePositives {
f := detect.Fragment{Raw: tp, FilePath: path}
if len(d.Detect(f)) != 1 {
log.Fatal().
logging.Fatal().
Str("rule", r.RuleID).
Str("value", tp).
Str("regex", r.Regex.String()).
@@ -56,7 +55,7 @@ func ValidateWithPaths(rule config.Rule, truePositives map[string]string, falseP
for path, fp := range falsePositives {
f := detect.Fragment{Raw: fp, FilePath: path}
if len(d.Detect(f)) != 0 {
log.Fatal().
logging.Fatal().
Str("rule", r.RuleID).
Str("value", fp).
Str("regex", r.Regex.String()).
+31 -41
View File
@@ -3,15 +3,18 @@ package cmd
import (
"time"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/zricethezav/gitleaks/v8/cmd/scm"
"github.com/zricethezav/gitleaks/v8/detect"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/sources"
)
func init() {
rootCmd.AddCommand(gitCmd)
gitCmd.Flags().String("platform", "", "the target platform used to generate links (github, gitlab)")
gitCmd.Flags().Bool("staged", false, "scan staged commits (good for pre-commit)")
gitCmd.Flags().Bool("pre-commit", false, "scan using git diff")
gitCmd.Flags().String("log-opts", "", "git log options")
@@ -25,10 +28,8 @@ var gitCmd = &cobra.Command{
}
func runGit(cmd *cobra.Command, args []string) {
var (
findings []report.Finding
err error
)
// start timer
start := time.Now()
// grab source
source := "."
@@ -39,58 +40,47 @@ func runGit(cmd *cobra.Command, args []string) {
}
}
initConfig(source)
// setup config (aka, the thing that defines rules)
initConfig(source)
cfg := Config(cmd)
// start timer
start := time.Now()
// grab source
// create detector
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")
}
// parse flags
exitCode := mustGetIntFlag(cmd, "exit-code")
logOpts := mustGetStringFlag(cmd, "log-opts")
staged := mustGetBoolFlag(cmd, "staged")
preCommit := mustGetBoolFlag(cmd, "pre-commit")
var (
gitCmd *sources.GitCmd
logOpts string
preCommit bool
staged bool
findings []report.Finding
err error
gitCmd *sources.GitCmd
scmPlatform scm.Platform
remote *detect.RemoteInfo
)
logOpts, err = cmd.Flags().GetString("log-opts")
if err != nil {
log.Fatal().Err(err).Msg("could not call GetString() for log-opts")
}
staged, err = cmd.Flags().GetBool("staged")
if err != nil {
log.Fatal().Err(err).Msg("could not call GetBool() for staged")
}
preCommit, err = cmd.Flags().GetBool("pre-commit")
if err != nil {
log.Fatal().Err(err).Msg("could not call GetBool() for pre-commit")
}
if preCommit || staged {
gitCmd, err = sources.NewGitDiffCmd(source, staged)
if err != nil {
log.Fatal().Err(err).Msg("could not create Git diff cmd")
if gitCmd, err = sources.NewGitDiffCmd(source, staged); err != nil {
logging.Fatal().Err(err).Msg("could not create Git diff cmd")
}
// Remote info + links are irrelevant for staged changes.
remote = &detect.RemoteInfo{Platform: scm.NoPlatform}
} else {
gitCmd, err = sources.NewGitLogCmd(source, logOpts)
if err != nil {
log.Fatal().Err(err).Msg("could not create Git log cmd")
if gitCmd, err = sources.NewGitLogCmd(source, logOpts); err != nil {
logging.Fatal().Err(err).Msg("could not create Git log cmd")
}
if scmPlatform, err = scm.PlatformFromString(mustGetStringFlag(cmd, "platform")); err != nil {
logging.Fatal().Err(err).Send()
}
remote = detect.NewRemoteInfo(scmPlatform, source)
}
findings, err = detector.DetectGit(gitCmd)
findings, err = detector.DetectGit(gitCmd, remote)
if err != nil {
// don't exit on error, just log it
log.Error().Err(err).Msg("failed to scan Git repository")
logging.Error().Err(err).Msg("failed to scan Git repository")
}
findingSummaryAndExit(detector, findings, exitCode, start, err)
+29 -16
View File
@@ -3,9 +3,11 @@ package cmd
import (
"time"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/zricethezav/gitleaks/v8/cmd/scm"
"github.com/zricethezav/gitleaks/v8/detect"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/sources"
)
@@ -25,27 +27,38 @@ var protectCmd = &cobra.Command{
}
func runProtect(cmd *cobra.Command, args []string) {
source, err := cmd.Flags().GetString("source")
if err != nil {
log.Fatal().Err(err).Msg("could not get source")
}
initConfig(source)
// start timer
start := time.Now()
source := mustGetStringFlag(cmd, "source")
// setup config (aka, the thing that defines rules)
initConfig(source)
cfg := Config(cmd)
exitCode, _ := cmd.Flags().GetInt("exit-code")
staged, _ := cmd.Flags().GetBool("staged")
start := time.Now()
// create detector
detector := Detector(cmd, cfg, source)
// start git scan
var findings []report.Finding
gitCmd, err := sources.NewGitDiffCmd(source, staged)
if err != nil {
log.Fatal().Err(err).Msg("")
}
findings, err = detector.DetectGit(gitCmd)
// parse flags
exitCode := mustGetIntFlag(cmd, "exit-code")
staged := mustGetBoolFlag(cmd, "staged")
// start git scan
var (
findings []report.Finding
err error
gitCmd *sources.GitCmd
remote *detect.RemoteInfo
)
if gitCmd, err = sources.NewGitDiffCmd(source, staged); err != nil {
logging.Fatal().Err(err).Msg("could not create Git diff cmd")
}
remote = &detect.RemoteInfo{Platform: scm.NoPlatform}
if findings, err = detector.DetectGit(gitCmd, remote); err != nil {
// don't exit on error, just log it
logging.Error().Err(err).Msg("failed to scan Git repository")
}
findingSummaryAndExit(detector, findings, exitCode, start, err)
}
+136 -61
View File
@@ -15,6 +15,8 @@ import (
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/detect"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/regexp"
"github.com/zricethezav/gitleaks/v8/report"
)
@@ -40,12 +42,19 @@ var rootCmd = &cobra.Command{
Version: Version,
}
const (
BYTE = 1.0
KILOBYTE = BYTE * 1000
MEGABYTE = KILOBYTE * 1000
GIGABYTE = MEGABYTE * 1000
)
func init() {
cobra.OnInitialize(initLog)
rootCmd.PersistentFlags().StringP("config", "c", "", configDescription)
rootCmd.PersistentFlags().Int("exit-code", 1, "exit code when leaks have been encountered")
rootCmd.PersistentFlags().StringP("report-path", "r", "", "report file")
rootCmd.PersistentFlags().StringP("report-format", "f", "json", "output format (json, jsonextra, csv, junit, sarif, template)")
rootCmd.PersistentFlags().StringP("report-format", "f", "", "output format (json, csv, junit, sarif, template)")
rootCmd.PersistentFlags().StringP("report-template", "", "", "template file used to generate the report (implies --report-format=template)")
rootCmd.PersistentFlags().StringP("baseline-path", "b", "", "path to baseline with issues that can be ignored")
rootCmd.PersistentFlags().StringP("log-level", "l", "info", "log level (trace, debug, info, warn, error, fatal)")
@@ -59,81 +68,87 @@ func init() {
rootCmd.PersistentFlags().StringSlice("enable-rule", []string{}, "only enable specific rules by id")
rootCmd.PersistentFlags().StringP("gitleaks-ignore-path", "i", ".", "path to .gitleaksignore file or folder containing one")
rootCmd.PersistentFlags().Int("max-decode-depth", 0, "allow recursive decoding up to this depth (default \"0\", no decoding is done)")
err := viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
if err != nil {
log.Fatal().Msgf("err binding config %s", err.Error())
logging.Fatal().Msgf("err binding config %s", err.Error())
}
}
var logLevel = zerolog.InfoLevel
func initLog() {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
ll, err := rootCmd.Flags().GetString("log-level")
if err != nil {
log.Fatal().Msg(err.Error())
logging.Fatal().Msg(err.Error())
}
switch strings.ToLower(ll) {
case "trace":
zerolog.SetGlobalLevel(zerolog.TraceLevel)
logLevel = zerolog.TraceLevel
case "debug":
zerolog.SetGlobalLevel(zerolog.DebugLevel)
logLevel = zerolog.DebugLevel
case "info":
zerolog.SetGlobalLevel(zerolog.InfoLevel)
logLevel = zerolog.InfoLevel
case "warn":
zerolog.SetGlobalLevel(zerolog.WarnLevel)
logLevel = zerolog.WarnLevel
case "err", "error":
zerolog.SetGlobalLevel(zerolog.ErrorLevel)
logLevel = zerolog.ErrorLevel
case "fatal":
zerolog.SetGlobalLevel(zerolog.FatalLevel)
logLevel = zerolog.FatalLevel
default:
zerolog.SetGlobalLevel(zerolog.InfoLevel)
logging.Warn().Msgf("unknown log level: %s", ll)
}
logging.Logger = logging.Logger.Level(logLevel)
}
func initConfig(source string) {
hideBanner, err := rootCmd.Flags().GetBool("no-banner")
if err != nil {
log.Fatal().Msg(err.Error())
logging.Fatal().Msg(err.Error())
}
if !hideBanner {
_, _ = fmt.Fprint(os.Stderr, banner)
}
logging.Debug().Msgf("using %s regex engine", regexp.Version)
cfgPath, err := rootCmd.Flags().GetString("config")
if err != nil {
log.Fatal().Msg(err.Error())
logging.Fatal().Msg(err.Error())
}
if cfgPath != "" {
viper.SetConfigFile(cfgPath)
log.Debug().Msgf("using gitleaks config %s from `--config`", cfgPath)
logging.Debug().Msgf("using gitleaks config %s from `--config`", cfgPath)
} else if os.Getenv("GITLEAKS_CONFIG") != "" {
envPath := os.Getenv("GITLEAKS_CONFIG")
viper.SetConfigFile(envPath)
log.Debug().Msgf("using gitleaks config from GITLEAKS_CONFIG env var: %s", envPath)
logging.Debug().Msgf("using gitleaks config from GITLEAKS_CONFIG env var: %s", envPath)
} else {
fileInfo, err := os.Stat(source)
if err != nil {
log.Fatal().Msg(err.Error())
logging.Fatal().Msg(err.Error())
}
if !fileInfo.IsDir() {
log.Debug().Msgf("unable to load gitleaks config from %s since --source=%s is a file, using default config",
logging.Debug().Msgf("unable to load gitleaks config from %s since --source=%s is a file, using default config",
filepath.Join(source, ".gitleaks.toml"), source)
viper.SetConfigType("toml")
if err = viper.ReadConfig(strings.NewReader(config.DefaultConfig)); err != nil {
log.Fatal().Msgf("err reading toml %s", err.Error())
logging.Fatal().Msgf("err reading toml %s", err.Error())
}
return
}
if _, err := os.Stat(filepath.Join(source, ".gitleaks.toml")); os.IsNotExist(err) {
log.Debug().Msgf("no gitleaks config found in path %s, using default gitleaks config", filepath.Join(source, ".gitleaks.toml"))
logging.Debug().Msgf("no gitleaks config found in path %s, using default gitleaks config", filepath.Join(source, ".gitleaks.toml"))
viper.SetConfigType("toml")
if err = viper.ReadConfig(strings.NewReader(config.DefaultConfig)); err != nil {
log.Fatal().Msgf("err reading default config toml %s", err.Error())
logging.Fatal().Msgf("err reading default config toml %s", err.Error())
}
return
} else {
log.Debug().Msgf("using existing gitleaks config %s from `(--source)/.gitleaks.toml`", filepath.Join(source, ".gitleaks.toml"))
logging.Debug().Msgf("using existing gitleaks config %s from `(--source)/.gitleaks.toml`", filepath.Join(source, ".gitleaks.toml"))
}
viper.AddConfigPath(source)
@@ -141,7 +156,7 @@ func initConfig(source string) {
viper.SetConfigType("toml")
}
if err := viper.ReadInConfig(); err != nil {
log.Fatal().Msgf("unable to load gitleaks config, err: %s", err)
logging.Fatal().Msgf("unable to load gitleaks config, err: %s", err)
}
}
@@ -151,18 +166,18 @@ func Execute() {
// exit code 126: Command invoked cannot execute
os.Exit(126)
}
log.Fatal().Msg(err.Error())
logging.Fatal().Msg(err.Error())
}
}
func Config(cmd *cobra.Command) config.Config {
var vc config.ViperConfig
if err := viper.Unmarshal(&vc); err != nil {
log.Fatal().Err(err).Msg("Failed to load config")
logging.Fatal().Err(err).Msg("Failed to load config")
}
cfg, err := vc.Translate()
if err != nil {
log.Fatal().Err(err).Msg("Failed to load config")
logging.Fatal().Err(err).Msg("Failed to load config")
}
cfg.Path, _ = cmd.Flags().GetString("config")
@@ -176,23 +191,23 @@ func Detector(cmd *cobra.Command, cfg config.Config, source string) *detect.Dete
detector := detect.NewDetector(cfg)
if detector.MaxDecodeDepth, err = cmd.Flags().GetInt("max-decode-depth"); err != nil {
log.Fatal().Err(err).Msg("")
logging.Fatal().Err(err).Msg("")
}
// set color flag at first
if detector.NoColor, err = cmd.Flags().GetBool("no-color"); err != nil {
log.Fatal().Err(err).Msg("")
logging.Fatal().Err(err).Msg("")
}
// also init logger again without color
if detector.NoColor {
log.Logger = log.Output(zerolog.ConsoleWriter{
logging.Logger = log.Output(zerolog.ConsoleWriter{
Out: os.Stderr,
NoColor: detector.NoColor,
})
}).Level(logLevel)
}
detector.Config.Path, err = cmd.Flags().GetString("config")
if err != nil {
log.Fatal().Err(err).Msg("")
logging.Fatal().Err(err).Msg("")
}
// if config path is not set, then use the {source}/.gitleaks.toml path.
@@ -202,40 +217,40 @@ func Detector(cmd *cobra.Command, cfg config.Config, source string) *detect.Dete
}
// set verbose flag
if detector.Verbose, err = cmd.Flags().GetBool("verbose"); err != nil {
log.Fatal().Err(err).Msg("")
logging.Fatal().Err(err).Msg("")
}
// set redact flag
if detector.Redact, err = cmd.Flags().GetUint("redact"); err != nil {
log.Fatal().Err(err).Msg("")
logging.Fatal().Err(err).Msg("")
}
if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil {
log.Fatal().Err(err).Msg("")
logging.Fatal().Err(err).Msg("")
}
// set ignore gitleaks:allow flag
if detector.IgnoreGitleaksAllow, err = cmd.Flags().GetBool("ignore-gitleaks-allow"); err != nil {
log.Fatal().Err(err).Msg("")
logging.Fatal().Err(err).Msg("")
}
gitleaksIgnorePath, err := cmd.Flags().GetString("gitleaks-ignore-path")
if err != nil {
log.Fatal().Err(err).Msg("could not get .gitleaksignore path")
logging.Fatal().Err(err).Msg("could not get .gitleaksignore path")
}
if fileExists(gitleaksIgnorePath) {
if err = detector.AddGitleaksIgnore(gitleaksIgnorePath); err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
logging.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
}
}
if fileExists(filepath.Join(gitleaksIgnorePath, ".gitleaksignore")) {
if err = detector.AddGitleaksIgnore(filepath.Join(gitleaksIgnorePath, ".gitleaksignore")); err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
logging.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
}
}
if fileExists(filepath.Join(source, ".gitleaksignore")) {
if err = detector.AddGitleaksIgnore(filepath.Join(source, ".gitleaksignore")); err != nil {
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
logging.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
}
}
@@ -244,32 +259,32 @@ func Detector(cmd *cobra.Command, cfg config.Config, source string) *detect.Dete
if baselinePath != "" {
err = detector.AddBaseline(baselinePath, source)
if err != nil {
log.Error().Msgf("Could not load baseline. The path must point of a gitleaks report generated using the default format: %s", err)
logging.Error().Msgf("Could not load baseline. The path must point of a gitleaks report generated using the default format: %s", err)
}
}
// If set, only apply rules that are defined in the flag
rules, _ := cmd.Flags().GetStringSlice("enable-rule")
if len(rules) > 0 {
log.Info().Msg("Overriding enabled rules: " + strings.Join(rules, ", "))
logging.Info().Msg("Overriding enabled rules: " + strings.Join(rules, ", "))
ruleOverride := make(map[string]config.Rule)
for _, ruleName := range rules {
if r, ok := cfg.Rules[ruleName]; ok {
ruleOverride[ruleName] = r
} else {
log.Fatal().Msgf("Requested rule %s not found in rules", ruleName)
logging.Fatal().Msgf("Requested rule %s not found in rules", ruleName)
}
}
detector.Config.Rules = ruleOverride
}
// Validate report settings.
reportPath := mustGetStringFlag("report-path")
reportPath := mustGetStringFlag(cmd, "report-path")
if reportPath != "" {
if reportPath != report.StdoutReportPath {
// Ensure the path is writable.
if f, err := os.Create(reportPath); err != nil {
log.Fatal().Err(err).Msgf("Report path is not writable: %s", reportPath)
logging.Fatal().Err(err).Msgf("Report path is not writable: %s", reportPath)
} else {
_ = f.Close()
_ = os.Remove(reportPath)
@@ -279,9 +294,23 @@ func Detector(cmd *cobra.Command, cfg config.Config, source string) *detect.Dete
// Build report writer.
var (
reporter report.Reporter
reportFormat = mustGetStringFlag("report-format")
reportTemplate = mustGetStringFlag("report-template")
reportFormat = mustGetStringFlag(cmd, "report-format")
reportTemplate = mustGetStringFlag(cmd, "report-template")
)
if reportFormat == "" {
ext := strings.ToLower(filepath.Ext(reportPath))
switch ext {
case ".csv":
reportFormat = "csv"
case ".json":
reportFormat = "json"
case ".sarif":
reportFormat = "sarif"
default:
logging.Fatal().Msgf("Unknown report format: %s", reportFormat)
}
logging.Debug().Msgf("No report format specified, inferred %q from %q", reportFormat, ext)
}
switch strings.TrimSpace(strings.ToLower(reportFormat)) {
case "csv":
reporter = &report.CsvReporter{}
@@ -295,15 +324,15 @@ func Detector(cmd *cobra.Command, cfg config.Config, source string) *detect.Dete
}
case "template":
if reporter, err = report.NewTemplateReporter(reportTemplate); err != nil {
log.Fatal().Err(err).Msg("Invalid report template")
logging.Fatal().Err(err).Msg("Invalid report template")
}
default:
log.Fatal().Msgf("unknown report format %s", reportFormat)
logging.Fatal().Msgf("unknown report format %s", reportFormat)
}
// Sanity check.
if reportTemplate != "" && reportFormat != "template" {
log.Fatal().Msgf("Report format must be 'template' if --report-template is specified")
logging.Fatal().Msgf("Report format must be 'template' if --report-template is specified")
}
detector.ReportPath = reportPath
@@ -313,33 +342,55 @@ func Detector(cmd *cobra.Command, cfg config.Config, source string) *detect.Dete
return detector
}
func mustGetStringFlag(name string) string {
reportPath, err := rootCmd.Flags().GetString(name)
if err != nil {
log.Fatal().Msg(err.Error())
func bytesConvert(bytes uint64) string {
unit := ""
value := float32(bytes)
switch {
case bytes >= GIGABYTE:
unit = "GB"
value = value / GIGABYTE
case bytes >= MEGABYTE:
unit = "MB"
value = value / MEGABYTE
case bytes >= KILOBYTE:
unit = "KB"
value = value / KILOBYTE
case bytes >= BYTE:
unit = "bytes"
case bytes == 0:
return "0"
}
return reportPath
stringValue := strings.TrimSuffix(
fmt.Sprintf("%.2f", value), ".00",
)
return fmt.Sprintf("%s %s", stringValue, unit)
}
func findingSummaryAndExit(detector *detect.Detector, findings []report.Finding, exitCode int, start time.Time, err error) {
totalBytes := detector.TotalBytes.Load()
bytesMsg := fmt.Sprintf("scanned ~%d bytes (%s)", totalBytes, bytesConvert(totalBytes))
if err == nil {
log.Info().Msgf("scan completed in %s", FormatDuration(time.Since(start)))
logging.Info().Msgf("%s in %s", bytesMsg, FormatDuration(time.Since(start)))
if len(findings) != 0 {
log.Warn().Msgf("leaks found: %d", len(findings))
logging.Warn().Msgf("leaks found: %d", len(findings))
} else {
log.Info().Msg("no leaks found")
logging.Info().Msg("no leaks found")
}
} else {
log.Warn().Msgf("partial scan completed in %s", FormatDuration(time.Since(start)))
logging.Warn().Msg(bytesMsg)
logging.Warn().Msgf("partial scan completed in %s", FormatDuration(time.Since(start)))
if len(findings) != 0 {
log.Warn().Msgf("%d leaks found in partial scan", len(findings))
logging.Warn().Msgf("%d leaks found in partial scan", len(findings))
} else {
log.Warn().Msg("no leaks found in partial scan")
logging.Warn().Msg("no leaks found in partial scan")
}
}
// write report if desired
if detector.Reporter != nil && len(findings) > 0 {
if detector.Reporter != nil {
var (
file io.WriteCloser
reportErr error
@@ -364,7 +415,7 @@ func findingSummaryAndExit(detector *detect.Detector, findings []report.Finding,
ReportEnd:
if reportErr != nil {
log.Fatal().Err(reportErr).Msg("failed to write report")
logging.Fatal().Err(reportErr).Msg("failed to write report")
}
}
@@ -400,3 +451,27 @@ func FormatDuration(d time.Duration) string {
}
return d.Round(scale / 100).String()
}
func mustGetBoolFlag(cmd *cobra.Command, name string) bool {
value, err := cmd.Flags().GetBool(name)
if err != nil {
logging.Fatal().Err(err).Msgf("could not get flag: %s", name)
}
return value
}
func mustGetIntFlag(cmd *cobra.Command, name string) int {
value, err := cmd.Flags().GetInt(name)
if err != nil {
logging.Fatal().Err(err).Msgf("could not get flag: %s", name)
}
return value
}
func mustGetStringFlag(cmd *cobra.Command, name string) string {
value, err := cmd.Flags().GetString(name)
if err != nil {
logging.Fatal().Err(err).Msgf("could not get flag: %s", name)
}
return value
}
+40
View File
@@ -0,0 +1,40 @@
package scm
import (
"fmt"
"strings"
)
type Platform int
const (
UnknownPlatform Platform = iota
NoPlatform // Explicitly disable the feature
GitHubPlatform
GitLabPlatform
// TODO: Add others.
)
func (p Platform) String() string {
return [...]string{
"unknown",
"none",
"github",
"gitlab",
}[p]
}
func PlatformFromString(s string) (Platform, error) {
switch strings.ToLower(s) {
case "", "unknown":
return UnknownPlatform, nil
case "none":
return NoPlatform, nil
case "github":
return GitHubPlatform, nil
case "gitlab":
return GitLabPlatform, nil
default:
return UnknownPlatform, fmt.Errorf("invalid scm platform value: %s", s)
}
}
+12 -19
View File
@@ -4,10 +4,9 @@ import (
"os"
"time"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/logging"
)
func init() {
@@ -20,31 +19,25 @@ var stdInCmd = &cobra.Command{
Run: runStdIn,
}
func runStdIn(cmd *cobra.Command, args []string) {
initConfig(".")
var (
findings []report.Finding
err error
)
// setup config (aka, the thing that defines rules)
cfg := Config(cmd)
func runStdIn(cmd *cobra.Command, _ []string) {
// start timer
start := time.Now()
// setup config (aka, the thing that defines rules)
initConfig(".")
cfg := Config(cmd)
// create detector
detector := Detector(cmd, cfg, "")
// set exit code
exitCode, err := cmd.Flags().GetInt("exit-code")
if err != nil {
log.Fatal().Err(err).Msg("could not get exit code")
}
// parse flag(s)
exitCode := mustGetIntFlag(cmd, "exit-code")
findings, err = detector.DetectReader(os.Stdin, 10)
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("failed scan input from stdin")
logging.Fatal().Err(err).Msg("failed scan input from stdin")
}
findingSummaryAndExit(detector, findings, exitCode, start, err)
+10 -8
View File
@@ -2,10 +2,11 @@ package config
import (
"fmt"
"regexp"
"strings"
"golang.org/x/exp/maps"
"github.com/zricethezav/gitleaks/v8/regexp"
)
type AllowlistMatchCondition int
@@ -56,16 +57,17 @@ type Allowlist struct {
}
// CommitAllowed returns true if the commit is allowed to be ignored.
func (a *Allowlist) CommitAllowed(c string) bool {
func (a *Allowlist) CommitAllowed(c string) (bool, string) {
if c == "" {
return false
return false, ""
}
for _, commit := range a.Commits {
if commit == c {
return true
return true, c
}
}
return false
return false, ""
}
// PathAllowed returns true if the path is allowed to be ignored.
@@ -78,14 +80,14 @@ func (a *Allowlist) RegexAllowed(secret string) bool {
return anyRegexMatch(secret, a.Regexes)
}
func (a *Allowlist) ContainsStopWord(s string) bool {
func (a *Allowlist) ContainsStopWord(s string) (bool, string) {
s = strings.ToLower(s)
for _, stopWord := range a.StopWords {
if strings.Contains(s, strings.ToLower(stopWord)) {
return true
return true, stopWord
}
}
return false
return false, ""
}
func (a *Allowlist) Validate() error {
+4 -2
View File
@@ -2,12 +2,13 @@ package config
import (
"errors"
"regexp"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/assert"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func TestCommitAllowed(t *testing.T) {
@@ -39,7 +40,8 @@ func TestCommitAllowed(t *testing.T) {
},
}
for _, tt := range tests {
assert.Equal(t, tt.commitAllowed, tt.allowlist.CommitAllowed(tt.commit))
isAllowed, _ := tt.allowlist.CommitAllowed(tt.commit)
assert.Equal(t, tt.commitAllowed, isAllowed)
}
}
+45 -15
View File
@@ -3,12 +3,13 @@ package config
import (
_ "embed"
"fmt"
"regexp"
"sort"
"strings"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/regexp"
)
//go:embed gitleaks.toml
@@ -76,9 +77,10 @@ type Config struct {
// Extend is a struct that allows users to define how they want their
// configuration extended by other configuration files.
type Extend struct {
Path string
URL string
UseDefault bool
Path string
URL string
UseDefault bool
DisabledRules []string
}
func (vc *ViperConfig) Translate() (Config, error) {
@@ -204,7 +206,7 @@ func (vc *ViperConfig) Translate() (Config, error) {
if maxExtendDepth != extendDepth {
// disallow both usedefault and path from being set
if c.Extend.Path != "" && c.Extend.UseDefault {
log.Fatal().Msg("unable to load config due to extend.path and extend.useDefault being set")
logging.Fatal().Msg("unable to load config due to extend.path and extend.useDefault being set")
}
if c.Extend.UseDefault {
c.extendDefault()
@@ -215,7 +217,7 @@ func (vc *ViperConfig) Translate() (Config, error) {
// Validate the rules after everything has been assembled (including extended configs).
if extendDepth == 0 {
for _, rule := range rulesMap {
for _, rule := range c.Rules {
if err := rule.Validate(); err != nil {
return Config{}, err
}
@@ -239,20 +241,20 @@ func (c *Config) extendDefault() {
extendDepth++
viper.SetConfigType("toml")
if err := viper.ReadConfig(strings.NewReader(DefaultConfig)); err != nil {
log.Fatal().Msgf("failed to load extended config, err: %s", err)
logging.Fatal().Msgf("failed to load extended config, err: %s", err)
return
}
defaultViperConfig := ViperConfig{}
if err := viper.Unmarshal(&defaultViperConfig); err != nil {
log.Fatal().Msgf("failed to load extended config, err: %s", err)
logging.Fatal().Msgf("failed to load extended config, err: %s", err)
return
}
cfg, err := defaultViperConfig.Translate()
if err != nil {
log.Fatal().Msgf("failed to load extended config, err: %s", err)
logging.Fatal().Msgf("failed to load extended config, err: %s", err)
return
}
log.Debug().Msg("extending config with default config")
logging.Debug().Msg("extending config with default config")
c.extend(cfg)
}
@@ -261,20 +263,20 @@ func (c *Config) extendPath() {
extendDepth++
viper.SetConfigFile(c.Extend.Path)
if err := viper.ReadInConfig(); err != nil {
log.Fatal().Msgf("failed to load extended config, err: %s", err)
logging.Fatal().Msgf("failed to load extended config, err: %s", err)
return
}
extensionViperConfig := ViperConfig{}
if err := viper.Unmarshal(&extensionViperConfig); err != nil {
log.Fatal().Msgf("failed to load extended config, err: %s", err)
logging.Fatal().Msgf("failed to load extended config, err: %s", err)
return
}
cfg, err := extensionViperConfig.Translate()
if err != nil {
log.Fatal().Msgf("failed to load extended config, err: %s", err)
logging.Fatal().Msgf("failed to load extended config, err: %s", err)
return
}
log.Debug().Msgf("extending config with %s", c.Extend.Path)
logging.Debug().Msgf("extending config with %s", c.Extend.Path)
c.extend(cfg)
}
@@ -283,7 +285,35 @@ func (c *Config) extendURL() {
}
func (c *Config) extend(extensionConfig Config) {
// Get config name for helpful log messages.
var configName string
if c.Extend.Path != "" {
configName = c.Extend.Path
} else {
configName = "default"
}
// Convert |Config.DisabledRules| into a map for ease of access.
disabledRuleIDs := map[string]struct{}{}
for _, id := range c.Extend.DisabledRules {
if _, ok := extensionConfig.Rules[id]; !ok {
logging.Warn().
Str("rule-id", id).
Str("config", configName).
Msg("Disabled rule doesn't exist in extended config.")
}
disabledRuleIDs[id] = struct{}{}
}
for ruleID, baseRule := range extensionConfig.Rules {
// Skip the rule.
if _, ok := disabledRuleIDs[ruleID]; ok {
logging.Debug().
Str("rule-id", ruleID).
Str("config", configName).
Msg("Ignoring rule from extended config.")
continue
}
currentRule, ok := c.Rules[ruleID]
if !ok {
// Rule doesn't exist, add it to the config.
+27 -13
View File
@@ -2,14 +2,14 @@ package config
import (
"fmt"
"regexp"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zricethezav/gitleaks/v8/regexp"
)
const configPath = "../testdata/config/"
@@ -39,8 +39,7 @@ func TestTranslate(t *testing.T) {
Regexes: []*regexp.Regexp{regexp.MustCompile("123")},
},
},
},
},
}},
},
},
{
@@ -73,8 +72,7 @@ func TestTranslate(t *testing.T) {
Regexes: []*regexp.Regexp{regexp.MustCompile("AKIALALEMEL33243OLIA")},
},
},
},
},
}},
},
},
{
@@ -92,8 +90,7 @@ func TestTranslate(t *testing.T) {
Commits: []string{"allowthiscommit"},
},
},
},
},
}},
},
},
{
@@ -111,8 +108,7 @@ func TestTranslate(t *testing.T) {
Paths: []*regexp.Regexp{regexp.MustCompile(".go")},
},
},
},
},
}},
},
},
{
@@ -122,12 +118,11 @@ func TestTranslate(t *testing.T) {
RuleID: "discord-api-key",
Description: "Discord API key",
Regex: regexp.MustCompile(`(?i)(discord[a-z0-9_ .\-,]{0,25})(=|>|:=|\|\|:|<=|=>|:).{0,5}['\"]([a-h0-9]{64})['\"]`),
Keywords: []string{},
Entropy: 3.5,
SecretGroup: 3,
Keywords: []string{},
Tags: []string{},
},
},
}},
},
},
{
@@ -350,6 +345,25 @@ func TestTranslate(t *testing.T) {
},
},
},
{
cfgName: "extend_disabled",
cfg: Config{
Rules: map[string]Rule{
"aws-secret-key": {
RuleID: "aws-secret-key",
Regex: regexp.MustCompile(`(?i)aws_(.{0,20})?=?.[\'\"0-9a-zA-Z\/+]{40}`),
Tags: []string{"key", "AWS"},
Keywords: []string{},
},
"pypi-upload-token": {
RuleID: "pypi-upload-token",
Regex: regexp.MustCompile(`pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,1000}`),
Tags: []string{},
Keywords: []string{},
},
},
},
},
}
for _, tt := range tests {
+264 -191
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -2,8 +2,9 @@ package config
import (
"fmt"
"regexp"
"strings"
"github.com/zricethezav/gitleaks/v8/regexp"
)
// Rules contain information that define details on how to detect secrets
+1 -1
View File
@@ -1,7 +1,7 @@
package config
import (
"regexp"
"github.com/zricethezav/gitleaks/v8/regexp"
)
func anyRegexMatch(f string, res []*regexp.Regexp) bool {
+1 -1
View File
@@ -133,7 +133,7 @@ func TestIgnoreIssuesInBaseline(t *testing.T) {
require.NoError(t, err)
d.baseline = test.baseline
for _, finding := range test.findings {
d.addFinding(finding)
d.AddFinding(finding)
}
assert.Len(t, d.findings, test.expectCount)
}
+24 -2
View File
@@ -7,7 +7,7 @@ import (
"regexp"
"unicode"
"github.com/rs/zerolog/log"
"github.com/zricethezav/gitleaks/v8/logging"
)
var b64LikelyChars [128]byte
@@ -227,7 +227,7 @@ func (d *Decoder) findEncodedSegments(data string, parentSegments []EncodedSegme
}
}
log.Debug().Msgf("segment found: %#v", segment)
logging.Debug().Msgf("segment found: %#v", segment)
segments = append(segments, segment)
}
@@ -279,3 +279,25 @@ func segmentWithDecodedOverlap(encodedSegments []EncodedSegment, start, end int)
return nil
}
func (s EncodedSegment) lineStartIndex(currentRaw string) int {
for i := s.decodedStart; i > -1; i-- {
c := currentRaw[i]
if c == '\n' {
return i
}
}
return 0
}
func (s EncodedSegment) lineEndIndex(currentRaw string, matchLen int) int {
for i := s.decodedStart; i < s.decodedStart+matchLen; i++ {
c := currentRaw[i]
if c == '\n' {
return i
}
}
return len(currentRaw) - 1
}
+171 -111
View File
@@ -5,17 +5,19 @@ import (
"context"
"fmt"
"os"
"regexp"
"runtime"
"strings"
"sync"
"sync/atomic"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/regexp"
"github.com/zricethezav/gitleaks/v8/report"
ahocorasick "github.com/BobuSumisu/aho-corasick"
"github.com/fatih/semgroup"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"golang.org/x/exp/maps"
)
@@ -25,7 +27,10 @@ const (
chunkSize = 100 * 1_000 // 100kb
)
var newLineRegexp = regexp.MustCompile("\n")
var (
newLineRegexp = regexp.MustCompile("\n")
isWindows = runtime.GOOS == "windows"
)
// Detector is the main detector struct
type Detector struct {
@@ -79,7 +84,7 @@ type Detector struct {
baselinePath string
// gitleaksIgnore
gitleaksIgnore map[string]bool
gitleaksIgnore map[string]struct{}
// Sema (https://github.com/fatih/semgroup) controls the concurrency
Sema *semgroup.Group
@@ -87,6 +92,8 @@ type Detector struct {
// report-related settings.
ReportPath string
Reporter report.Reporter
TotalBytes atomic.Uint64
}
// Fragment contains the data to be scanned
@@ -94,9 +101,15 @@ type Fragment struct {
// Raw is the raw content of the fragment
Raw string
// FilePath is the path to the file if applicable
Bytes []byte
// FilePath is the path to the file, if applicable.
// The path separator MUST be normalized to `/`.
FilePath string
SymlinkFile string
// WindowsFilePath is the path with the original separator.
// This provides a backwards-compatible solution to https://github.com/gitleaks/gitleaks/issues/1565.
WindowsFilePath string `json:"-"` // TODO: remove this in v9.
// CommitSHA is the SHA of the commit if applicable
CommitSHA string
@@ -110,7 +123,7 @@ type Fragment struct {
func NewDetector(cfg config.Config) *Detector {
return &Detector{
commitMap: make(map[string]bool),
gitleaksIgnore: make(map[string]bool),
gitleaksIgnore: make(map[string]struct{}),
findingMutex: &sync.Mutex{},
findings: make([]report.Finding, 0),
Config: cfg,
@@ -139,27 +152,43 @@ func NewDetectorDefaultConfig() (*Detector, error) {
}
func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error {
log.Debug().Msgf("found .gitleaksignore file: %s", gitleaksIgnorePath)
logging.Debug().Msgf("found .gitleaksignore file: %s", gitleaksIgnorePath)
file, err := os.Open(gitleaksIgnorePath)
if err != nil {
return err
}
// https://github.com/securego/gosec/issues/512
defer func() {
// https://github.com/securego/gosec/issues/512
if err := file.Close(); err != nil {
log.Warn().Msgf("Error closing .gitleaksignore file: %s\n", err)
logging.Warn().Msgf("Error closing .gitleaksignore file: %s\n", err)
}
}()
scanner := bufio.NewScanner(file)
scanner := bufio.NewScanner(file)
replacer := strings.NewReplacer("\\", "/")
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
// Skip lines that start with a comment
if line != "" && !strings.HasPrefix(line, "#") {
d.gitleaksIgnore[line] = true
if line == "" || strings.HasPrefix(line, "#") {
continue
}
// Normalize the path.
// TODO: Make this a breaking change in v9.
s := strings.Split(line, ":")
switch len(s) {
case 3:
// Global fingerprint.
// `file:rule-id:start-line`
s[0] = replacer.Replace(s[0])
case 4:
// Commit fingerprint.
// `commit:file:rule-id:start-line`
s[1] = replacer.Replace(s[1])
default:
logging.Warn().Str("fingerprint", line).Msg("Invalid .gitleaksignore entry")
}
d.gitleaksIgnore[strings.Join(s, ":")] = struct{}{}
}
return nil
}
@@ -178,12 +207,21 @@ func (d *Detector) DetectString(content string) []report.Finding {
// Detect scans the given fragment and returns a list of findings
func (d *Detector) Detect(fragment Fragment) []report.Finding {
if fragment.Bytes == nil {
d.TotalBytes.Add(uint64(len(fragment.Raw)))
}
d.TotalBytes.Add(uint64(len(fragment.Bytes)))
var findings []report.Finding
// check if filepath is allowed
if fragment.FilePath != "" && (d.Config.Allowlist.PathAllowed(fragment.FilePath) ||
fragment.FilePath == d.Config.Path || (d.baselinePath != "" && fragment.FilePath == d.baselinePath)) {
return findings
if fragment.FilePath != "" {
// is the path our config or baseline file?
if fragment.FilePath == d.Config.Path || (d.baselinePath != "" && fragment.FilePath == d.baselinePath) ||
// is the path excluded by the global allowlist?
(d.Config.Allowlist.PathAllowed(fragment.FilePath) || (fragment.WindowsFilePath != "" && d.Config.Allowlist.PathAllowed(fragment.WindowsFilePath))) {
return findings
}
}
// add newline indices for location calculation in detectRule
@@ -246,11 +284,10 @@ func (d *Detector) detectRule(fragment Fragment, currentRaw string, r config.Rul
var (
findings []report.Finding
logger = func() zerolog.Logger {
l := log.With().Str("rule-id", r.RuleID)
l := logging.With().Str("rule-id", r.RuleID).Str("path", fragment.FilePath)
if fragment.CommitSHA != "" {
l = l.Str("commit", fragment.CommitSHA)
}
l = l.Str("path", fragment.FilePath)
return l.Logger()
}()
)
@@ -258,9 +295,9 @@ func (d *Detector) detectRule(fragment Fragment, currentRaw string, r config.Rul
// check if filepath or commit is allowed for this rule
for _, a := range r.Allowlists {
var (
isAllowed bool
commitAllowed = a.CommitAllowed(fragment.CommitSHA)
pathAllowed = a.PathAllowed(fragment.FilePath)
isAllowed bool
commitAllowed, commit = a.CommitAllowed(fragment.CommitSHA)
pathAllowed = a.PathAllowed(fragment.FilePath) || (fragment.WindowsFilePath != "" && a.PathAllowed(fragment.WindowsFilePath))
)
if a.MatchCondition == config.AllowlistMatchAnd {
// Determine applicable checks.
@@ -285,34 +322,39 @@ func (d *Detector) detectRule(fragment Fragment, currentRaw string, r config.Rul
isAllowed = commitAllowed || pathAllowed
}
if isAllowed {
logger.Trace().
Str("condition", a.MatchCondition.String()).
Bool("commit-allowed", commitAllowed).
Bool("path-allowed", commitAllowed).
Msg("Skipping fragment due to rule allowlist")
event := logger.Trace().Str("condition", a.MatchCondition.String())
if commitAllowed {
event.Str("allowed-commit", commit)
}
if pathAllowed {
event.Bool("allowed-path", pathAllowed)
}
event.Msg("skipping file: rule allowlist")
return findings
}
}
if r.Path != nil && r.Regex == nil && len(encodedSegments) == 0 {
// Path _only_ rule
if r.Path.MatchString(fragment.FilePath) {
finding := report.Finding{
Description: r.Description,
File: fragment.FilePath,
SymlinkFile: fragment.SymlinkFile,
RuleID: r.RuleID,
Match: fmt.Sprintf("file detected: %s", fragment.FilePath),
Tags: r.Tags,
if r.Path != nil {
if r.Regex == nil && len(encodedSegments) == 0 {
// Path _only_ rule
if r.Path.MatchString(fragment.FilePath) || (fragment.WindowsFilePath != "" && r.Path.MatchString(fragment.WindowsFilePath)) {
finding := report.Finding{
RuleID: r.RuleID,
Description: r.Description,
File: fragment.FilePath,
SymlinkFile: fragment.SymlinkFile,
Match: fmt.Sprintf("file detected: %s", fragment.FilePath),
Tags: r.Tags,
}
return append(findings, finding)
}
} else {
// if path is set _and_ a regex is set, then we need to check both
// so if the path does not match, then we should return early and not
// consider the regex
if !(r.Path.MatchString(fragment.FilePath) || (fragment.WindowsFilePath != "" && r.Path.MatchString(fragment.WindowsFilePath))) {
return findings
}
return append(findings, finding)
}
} else if r.Path != nil {
// if path is set _and_ a regex is set, then we need to check both
// so if the path does not match, then we should return early and not
// consider the regex
if !r.Path.MatchString(fragment.FilePath) {
return findings
}
}
@@ -325,7 +367,10 @@ func (d *Detector) detectRule(fragment Fragment, currentRaw string, r config.Rul
if d.MaxTargetMegaBytes > 0 {
rawLength := len(currentRaw) / 1000000
if rawLength > d.MaxTargetMegaBytes {
log.Debug().Msgf("skipping file: %s scan due to size: %d", fragment.FilePath, rawLength)
logger.Debug().
Int("size", rawLength).
Int("max-size", d.MaxTargetMegaBytes).
Msg("skipping fragment: size")
return findings
}
}
@@ -339,6 +384,7 @@ MatchLoop:
// For any meta data from decoding
var metaTags []string
currentLine := ""
// Check if the decoded portions of the segment overlap with the match
// to see if its potentially a new match
@@ -346,6 +392,7 @@ MatchLoop:
if segment := segmentWithDecodedOverlap(encodedSegments, matchIndex[0], matchIndex[1]); segment != nil {
matchIndex = segment.adjustMatchIndex(matchIndex)
metaTags = append(metaTags, segment.tags()...)
currentLine = currentRaw[segment.lineStartIndex(currentRaw):segment.lineEndIndex(currentRaw, matchIndex[1]-matchIndex[0])]
} else {
// This item has already been added to a finding
continue
@@ -367,28 +414,31 @@ MatchLoop:
}
finding := report.Finding{
Description: r.Description,
File: fragment.FilePath,
SymlinkFile: fragment.SymlinkFile,
RuleID: r.RuleID,
Description: r.Description,
StartLine: loc.startLine,
EndLine: loc.endLine,
StartColumn: loc.startColumn,
EndColumn: loc.endColumn,
Secret: secret,
Match: secret,
Tags: append(r.Tags, metaTags...),
Line: fragment.Raw[loc.startLineIndex:loc.endLineIndex],
Match: secret,
Secret: secret,
File: fragment.FilePath,
SymlinkFile: fragment.SymlinkFile,
Tags: append(r.Tags, metaTags...),
}
if !d.IgnoreGitleaksAllow &&
strings.Contains(fragment.Raw[loc.startLineIndex:loc.endLineIndex], gitleaksAllowSignature) {
if !d.IgnoreGitleaksAllow && strings.Contains(finding.Line, gitleaksAllowSignature) {
logger.Trace().
Str("finding", finding.Secret).
Msg("Skipping finding due to 'gitleaks:allow' signature")
Msg("skipping finding: 'gitleaks:allow' signature")
continue
}
if currentLine == "" {
currentLine = finding.Line
}
// Set the value of |secret|, if the pattern contains at least one capture group.
// (The first element is the full match, hence we check >= 2.)
groups := r.Regex.FindStringSubmatch(finding.Secret)
@@ -401,21 +451,28 @@ MatchLoop:
finding.Secret = groups[r.SecretGroup]
} else {
// If |secretGroup| is not set, we will use the first suitable capture group.
if len(groups) == 2 {
// Use the only group.
finding.Secret = groups[1]
} else {
// Use the first non-empty group.
for _, s := range groups[1:] {
if len(s) > 0 {
finding.Secret = s
break
}
for _, s := range groups[1:] {
if len(s) > 0 {
finding.Secret = s
break
}
}
}
}
// check entropy
entropy := shannonEntropy(finding.Secret)
finding.Entropy = float32(entropy)
if r.Entropy != 0.0 {
// entropy is too low, skip this finding
if entropy <= r.Entropy {
logger.Trace().
Str("finding", finding.Secret).
Float32("entropy", finding.Entropy).
Msg("skipping finding: low entropy")
continue
}
}
// check if the regexTarget is defined in the allowlist "regexes" entry
// or if the secret is in the list of stopwords
globalAllowlistTarget := finding.Secret
@@ -423,17 +480,18 @@ MatchLoop:
case "match":
globalAllowlistTarget = finding.Match
case "line":
globalAllowlistTarget = finding.Line
globalAllowlistTarget = currentLine
}
if d.Config.Allowlist.RegexAllowed(globalAllowlistTarget) {
logger.Trace().
Str("finding", globalAllowlistTarget).
Msg("Skipping finding due to global allowlist regex")
Msg("skipping finding: global allowlist regex")
continue
} else if d.Config.Allowlist.ContainsStopWord(finding.Secret) {
} else if ok, word := d.Config.Allowlist.ContainsStopWord(finding.Secret); ok {
logger.Trace().
Str("finding", finding.Secret).
Msg("Skipping finding due to global allowlist stopword")
Str("allowed-stopword", word).
Msg("skipping finding: global allowlist stopword")
continue
}
@@ -444,23 +502,28 @@ MatchLoop:
case "match":
allowlistTarget = finding.Match
case "line":
allowlistTarget = finding.Line
allowlistTarget = currentLine
}
var (
isAllowed bool
regexAllowed = a.RegexAllowed(allowlistTarget)
containsStopword = a.ContainsStopWord(finding.Secret)
isAllowed bool
commitAllowed bool
commit string
pathAllowed bool
regexAllowed = a.RegexAllowed(allowlistTarget)
containsStopword, word = a.ContainsStopWord(finding.Secret)
)
// check if the secret is in the list of stopwords
if a.MatchCondition == config.AllowlistMatchAnd {
// Determine applicable checks.
var allowlistChecks []bool
if len(a.Commits) > 0 {
allowlistChecks = append(allowlistChecks, a.CommitAllowed(fragment.CommitSHA))
commitAllowed, commit = a.CommitAllowed(fragment.CommitSHA)
allowlistChecks = append(allowlistChecks, commitAllowed)
}
if len(a.Paths) > 0 {
allowlistChecks = append(allowlistChecks, a.PathAllowed(fragment.FilePath))
pathAllowed = a.PathAllowed(fragment.FilePath) || (fragment.WindowsFilePath != "" && a.PathAllowed(fragment.WindowsFilePath))
allowlistChecks = append(allowlistChecks, pathAllowed)
}
if len(a.Regexes) > 0 {
allowlistChecks = append(allowlistChecks, regexAllowed)
@@ -476,38 +539,25 @@ MatchLoop:
}
if isAllowed {
logger.Trace().
event := logger.Trace().
Str("finding", finding.Secret).
Str("condition", a.MatchCondition.String()).
Bool("regex-allowed", regexAllowed).
Bool("contains-stopword", containsStopword).
Msg("Skipping finding due to rule allowlist")
Str("condition", a.MatchCondition.String())
if commitAllowed {
event.Str("allowed-commit", commit)
}
if pathAllowed {
event.Bool("allowed-path", pathAllowed)
}
if regexAllowed {
event.Bool("allowed-regex", regexAllowed)
}
if containsStopword {
event.Str("allowed-stopword", word)
}
event.Msg("skipping finding: rule allowlist")
continue MatchLoop
}
}
// check entropy
entropy := shannonEntropy(finding.Secret)
finding.Entropy = float32(entropy)
if r.Entropy != 0.0 {
if entropy <= r.Entropy {
// entropy is too low, skip this finding
continue
}
// NOTE: this is a goofy hack to get around the fact there golang's regex engine
// does not support positive lookaheads. Ideally we would want to add a
// restriction on generic rules regex that requires the secret match group
// contains both numbers and alphabetical characters, not just alphabetical characters.
// What this bit of code does is check if the ruleid is prepended with "generic" and enforces the
// secret contains both digits and alphabetical characters.
// TODO: this should be replaced with stop words
if strings.HasPrefix(r.RuleID, "generic") {
if !containsDigit(finding.Secret) {
continue
}
}
}
findings = append(findings, finding)
}
return findings
@@ -524,8 +574,8 @@ func allTrue(bools []bool) bool {
return allMatch
}
// addFinding synchronously adds a finding to the findings slice
func (d *Detector) addFinding(finding report.Finding) {
// AddFinding synchronously adds a finding to the findings slice
func (d *Detector) AddFinding(finding report.Finding) {
globalFingerprint := fmt.Sprintf("%s:%s:%d", finding.File, finding.RuleID, finding.StartLine)
if finding.Commit != "" {
finding.Fingerprint = fmt.Sprintf("%s:%s:%s:%d", finding.Commit, finding.File, finding.RuleID, finding.StartLine)
@@ -534,21 +584,26 @@ func (d *Detector) addFinding(finding report.Finding) {
}
// check if we should ignore this finding
logger := logging.With().Str("finding", finding.Secret).Logger()
if _, ok := d.gitleaksIgnore[globalFingerprint]; ok {
log.Debug().Msgf("ignoring finding with global Fingerprint %s",
finding.Fingerprint)
logger.Debug().
Str("fingerprint", globalFingerprint).
Msg("skipping finding: global fingerprint")
return
} else if finding.Commit != "" {
// Awkward nested if because I'm not sure how to chain these two conditions.
if _, ok := d.gitleaksIgnore[finding.Fingerprint]; ok {
log.Debug().Msgf("ignoring finding with Fingerprint %s",
finding.Fingerprint)
logger.Debug().
Str("fingerprint", finding.Fingerprint).
Msgf("skipping finding: fingerprint")
return
}
}
if d.baseline != nil && !IsNew(finding, d.baseline) {
log.Debug().Msgf("baseline duplicate -- ignoring finding with Fingerprint %s", finding.Fingerprint)
logger.Debug().
Str("fingerprint", finding.Fingerprint).
Msgf("skipping finding: baseline")
return
}
@@ -560,7 +615,12 @@ func (d *Detector) addFinding(finding report.Finding) {
d.findingMutex.Unlock()
}
// addCommit synchronously adds a commit to the commit slice
// Findings returns the findings added to the detector
func (d *Detector) Findings() []report.Finding {
return d.findings
}
// AddCommit synchronously adds a commit to the commit slice
func (d *Detector) addCommit(commit string) {
d.commitMap[commit] = true
}
+457 -72
View File
@@ -4,16 +4,21 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"runtime"
"strings"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/rs/zerolog"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
"github.com/zricethezav/gitleaks/v8/cmd/scm"
"github.com/zricethezav/gitleaks/v8/config"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/regexp"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/sources"
)
@@ -42,6 +47,9 @@ c21hbGwtc2VjcmV0
secret=ZGVjb2RlZC1zZWNyZXQtdmFsdWU=
# The above encoded again
c2VjcmV0PVpHVmpiMlJsWkMxelpXTnlaWFF0ZG1Gc2RXVT0=
# Confirm you can ignore on the decoded value
password="bFJxQkstejVrZjQtcGxlYXNlLWlnbm9yZS1tZS1YLVhJSk0yUGRkdw=="
`
func TestDetect(t *testing.T) {
@@ -464,6 +472,20 @@ func TestDetect(t *testing.T) {
EndColumn: 49,
Entropy: 3.3037016,
},
{ // This just confirms that with no allowlist the pattern is detected (i.e. the regex is good)
Description: "Make sure this would be detected with no allowlist",
Secret: "lRqBK-z5kf4-please-ignore-me-X-XIJM2Pddw",
Match: "password=\"lRqBK-z5kf4-please-ignore-me-X-XIJM2Pddw\"",
File: "tmp.go",
Line: "\npassword=\"bFJxQkstejVrZjQtcGxlYXNlLWlnbm9yZS1tZS1YLVhJSk0yUGRkdw==\"",
RuleID: "decoded-password-dont-ignore",
Tags: []string{"decode-ignore", "decoded:base64", "decode-depth:1"},
StartLine: 23,
EndLine: 23,
StartColumn: 2,
EndColumn: 68,
Entropy: 4.5841837,
},
},
},
}
@@ -495,6 +517,12 @@ func TestDetect(t *testing.T) {
// TestFromGit tests the FromGit function
func TestFromGit(t *testing.T) {
// TODO: Fix this test on windows.
if runtime.GOOS == "windows" {
t.Skipf("TODO: this fails on Windows: [git] fatal: bad object refs/remotes/origin/main?")
return
}
tests := []struct {
cfgName string
source string
@@ -503,9 +531,10 @@ func TestFromGit(t *testing.T) {
}{
{
source: filepath.Join(repoBasePath, "small"),
cfgName: "simple",
cfgName: "simple", // the remote url is `git@github.com:gitleaks/test.git`
expectedFindings: []report.Finding{
{
RuleID: "aws-access-key",
Description: "AWS Access Key",
StartLine: 20,
EndLine: 20,
@@ -514,18 +543,19 @@ func TestFromGit(t *testing.T) {
Line: "\n awsToken := \"AKIALALEMEL33243OLIA\"",
Secret: "AKIALALEMEL33243OLIA",
Match: "AKIALALEMEL33243OLIA",
Entropy: 3.0841837,
File: "main.go",
Date: "2021-11-02T23:37:53Z",
Commit: "1b6da43b82b22e4eaa10bcf8ee591e91abbfc587",
Author: "Zachary Rice",
Email: "zricer@protonmail.com",
Message: "Accidentally add a secret",
RuleID: "aws-access-key",
Tags: []string{"key", "AWS"},
Entropy: 3.0841837,
Fingerprint: "1b6da43b82b22e4eaa10bcf8ee591e91abbfc587:main.go:aws-access-key:20",
Link: "https://github.com/gitleaks/test/blob/1b6da43b82b22e4eaa10bcf8ee591e91abbfc587/main.go#L20",
},
{
RuleID: "aws-access-key",
Description: "AWS Access Key",
StartLine: 9,
EndLine: 9,
@@ -540,10 +570,10 @@ func TestFromGit(t *testing.T) {
Author: "Zach Rice",
Email: "zricer@protonmail.com",
Message: "adding foo package with secret",
RuleID: "aws-access-key",
Tags: []string{"key", "AWS"},
Entropy: 3.0841837,
Fingerprint: "491504d5a31946ce75e22554cc34203d8e5ff3ca:foo/foo.go:aws-access-key:9",
Link: "https://github.com/gitleaks/test/blob/491504d5a31946ce75e22554cc34203d8e5ff3ca/foo/foo.go#L9",
},
},
},
@@ -553,6 +583,7 @@ func TestFromGit(t *testing.T) {
cfgName: "simple",
expectedFindings: []report.Finding{
{
RuleID: "aws-access-key",
Description: "AWS Access Key",
StartLine: 9,
EndLine: 9,
@@ -567,10 +598,10 @@ func TestFromGit(t *testing.T) {
Author: "Zach Rice",
Email: "zricer@protonmail.com",
Message: "adding foo package with secret",
RuleID: "aws-access-key",
Tags: []string{"key", "AWS"},
Entropy: 3.0841837,
Fingerprint: "491504d5a31946ce75e22554cc34203d8e5ff3ca:foo/foo.go:aws-access-key:9",
Link: "https://github.com/gitleaks/test/blob/491504d5a31946ce75e22554cc34203d8e5ff3ca/foo/foo.go#L9",
},
},
},
@@ -580,43 +611,47 @@ func TestFromGit(t *testing.T) {
defer moveDotGit(t, ".git", "dotGit")
for _, tt := range tests {
t.Run(strings.Join([]string{tt.cfgName, tt.source, tt.logOpts}, "/"), func(t *testing.T) {
viper.AddConfigPath(configPath)
viper.SetConfigName("simple")
viper.SetConfigType("toml")
err := viper.ReadInConfig()
require.NoError(t, err)
viper.AddConfigPath(configPath)
viper.SetConfigName("simple")
viper.SetConfigType("toml")
err := viper.ReadInConfig()
require.NoError(t, err)
var vc config.ViperConfig
err = viper.Unmarshal(&vc)
require.NoError(t, err)
cfg, err := vc.Translate()
require.NoError(t, err)
detector := NewDetector(cfg)
var vc config.ViperConfig
err = viper.Unmarshal(&vc)
require.NoError(t, err)
cfg, err := vc.Translate()
require.NoError(t, err)
detector := NewDetector(cfg)
var ignorePath string
info, err := os.Stat(tt.source)
require.NoError(t, err)
var ignorePath string
info, err := os.Stat(tt.source)
require.NoError(t, err)
if info.IsDir() {
ignorePath = filepath.Join(tt.source, ".gitleaksignore")
} else {
ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
}
err = detector.AddGitleaksIgnore(ignorePath)
require.NoError(t, err)
if info.IsDir() {
ignorePath = filepath.Join(tt.source, ".gitleaksignore")
} else {
ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
}
err = detector.AddGitleaksIgnore(ignorePath)
require.NoError(t, err)
gitCmd, err := sources.NewGitLogCmd(tt.source, tt.logOpts)
require.NoError(t, err)
gitCmd, err := sources.NewGitLogCmd(tt.source, tt.logOpts)
require.NoError(t, err)
findings, err := detector.DetectGit(gitCmd)
require.NoError(t, err)
remote := NewRemoteInfo(scm.UnknownPlatform, tt.source)
findings, err := detector.DetectGit(gitCmd, remote)
require.NoError(t, err)
for _, f := range findings {
f.Match = "" // remove lines cause copying and pasting them has some wack formatting
}
assert.ElementsMatch(t, tt.expectedFindings, findings)
for _, f := range findings {
f.Match = "" // remove lines cause copying and pasting them has some wack formatting
}
assert.ElementsMatch(t, tt.expectedFindings, findings)
})
}
}
func TestFromGitStaged(t *testing.T) {
tests := []struct {
cfgName string
@@ -629,6 +664,7 @@ func TestFromGitStaged(t *testing.T) {
cfgName: "simple",
expectedFindings: []report.Finding{
{
RuleID: "aws-access-key",
Description: "AWS Access Key",
StartLine: 7,
EndLine: 7,
@@ -649,8 +685,8 @@ func TestFromGitStaged(t *testing.T) {
"key",
"AWS",
},
RuleID: "aws-access-key",
Fingerprint: "api/api.go:aws-access-key:7",
Link: "",
},
},
},
@@ -658,7 +694,6 @@ func TestFromGitStaged(t *testing.T) {
moveDotGit(t, "dotGit", ".git")
defer moveDotGit(t, ".git", "dotGit")
for _, tt := range tests {
viper.AddConfigPath(configPath)
@@ -677,7 +712,8 @@ func TestFromGitStaged(t *testing.T) {
require.NoError(t, err)
gitCmd, err := sources.NewGitDiffCmd(tt.source, true)
require.NoError(t, err)
findings, err := detector.DetectGit(gitCmd)
remote := NewRemoteInfo(scm.UnknownPlatform, tt.source)
findings, err := detector.DetectGit(gitCmd, remote)
require.NoError(t, err)
for _, f := range findings {
@@ -699,17 +735,17 @@ func TestFromFiles(t *testing.T) {
cfgName: "simple",
expectedFindings: []report.Finding{
{
RuleID: "aws-access-key",
Description: "AWS Access Key",
StartLine: 20,
EndLine: 20,
StartColumn: 16,
EndColumn: 35,
Line: "\n\tawsToken := \"AKIALALEMEL33243OLIA\"",
Match: "AKIALALEMEL33243OLIA",
Secret: "AKIALALEMEL33243OLIA",
Line: "\n\tawsToken := \"AKIALALEMEL33243OLIA\"",
File: "../testdata/repos/nogit/main.go",
SymlinkFile: "",
RuleID: "aws-access-key",
Tags: []string{"key", "AWS"},
Entropy: 3.0841837,
Fingerprint: "../testdata/repos/nogit/main.go:aws-access-key:20",
@@ -721,16 +757,16 @@ func TestFromFiles(t *testing.T) {
cfgName: "simple",
expectedFindings: []report.Finding{
{
RuleID: "aws-access-key",
Description: "AWS Access Key",
StartLine: 20,
EndLine: 20,
StartColumn: 16,
EndColumn: 35,
Line: "\n\tawsToken := \"AKIALALEMEL33243OLIA\"",
Match: "AKIALALEMEL33243OLIA",
Secret: "AKIALALEMEL33243OLIA",
Line: "\n\tawsToken := \"AKIALALEMEL33243OLIA\"",
File: "../testdata/repos/nogit/main.go",
RuleID: "aws-access-key",
Tags: []string{"key", "AWS"},
Entropy: 3.0841837,
Fingerprint: "../testdata/repos/nogit/main.go:aws-access-key:20",
@@ -747,16 +783,16 @@ func TestFromFiles(t *testing.T) {
cfgName: "generic",
expectedFindings: []report.Finding{
{
RuleID: "generic-api-key",
Description: "Generic API Key",
StartLine: 4,
EndLine: 4,
StartColumn: 5,
EndColumn: 35,
Line: "\nDB_PASSWORD=8ae31cacf141669ddfb5da",
Match: "PASSWORD=8ae31cacf141669ddfb5da",
Secret: "8ae31cacf141669ddfb5da",
Line: "\nDB_PASSWORD=8ae31cacf141669ddfb5da",
File: "../testdata/repos/nogit/.env.prod",
RuleID: "generic-api-key",
Tags: []string{},
Entropy: 3.5383105,
Fingerprint: "../testdata/repos/nogit/.env.prod:generic-api-key:4",
@@ -766,39 +802,64 @@ func TestFromFiles(t *testing.T) {
}
for _, tt := range tests {
viper.AddConfigPath(configPath)
viper.SetConfigName(tt.cfgName)
viper.SetConfigType("toml")
err := viper.ReadInConfig()
require.NoError(t, err)
t.Run(tt.cfgName+" - "+tt.source, func(t *testing.T) {
viper.AddConfigPath(configPath)
viper.SetConfigName(tt.cfgName)
viper.SetConfigType("toml")
err := viper.ReadInConfig()
require.NoError(t, err)
var vc config.ViperConfig
err = viper.Unmarshal(&vc)
require.NoError(t, err)
cfg, _ := vc.Translate()
detector := NewDetector(cfg)
var vc config.ViperConfig
err = viper.Unmarshal(&vc)
require.NoError(t, err)
var ignorePath string
info, err := os.Stat(tt.source)
require.NoError(t, err)
cfg, _ := vc.Translate()
detector := NewDetector(cfg)
if info.IsDir() {
ignorePath = filepath.Join(tt.source, ".gitleaksignore")
} else {
ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
}
err = detector.AddGitleaksIgnore(ignorePath)
require.NoError(t, err)
detector.FollowSymlinks = true
paths, err := sources.DirectoryTargets(tt.source, detector.Sema, true, cfg.Allowlist.PathAllowed)
require.NoError(t, err)
findings, err := detector.DetectFiles(paths)
require.NoError(t, err)
assert.ElementsMatch(t, tt.expectedFindings, findings)
info, err := os.Stat(tt.source)
require.NoError(t, err)
var ignorePath string
if info.IsDir() {
ignorePath = filepath.Join(tt.source, ".gitleaksignore")
} else {
ignorePath = filepath.Join(filepath.Dir(tt.source), ".gitleaksignore")
}
err = detector.AddGitleaksIgnore(ignorePath)
require.NoError(t, err)
detector.FollowSymlinks = true
paths, err := sources.DirectoryTargets(tt.source, detector.Sema, true, cfg.Allowlist.PathAllowed)
require.NoError(t, err)
findings, err := detector.DetectFiles(paths)
require.NoError(t, err)
// TODO: Temporary mitigation.
// https://github.com/gitleaks/gitleaks/issues/1641
normalizedFindings := make([]report.Finding, len(findings))
for i, f := range findings {
if strings.HasSuffix(f.Line, "\r") {
f.Line = strings.ReplaceAll(f.Line, "\r", "")
}
if strings.HasSuffix(f.Match, "\r") {
f.EndColumn = f.EndColumn - 1
f.Match = strings.ReplaceAll(f.Match, "\r", "")
}
normalizedFindings[i] = f
}
assert.ElementsMatch(t, tt.expectedFindings, normalizedFindings)
})
}
}
func TestDetectWithSymlinks(t *testing.T) {
// TODO: Fix this test on windows.
if runtime.GOOS == "windows" {
t.Skipf("TODO: this returns no results on windows, I'm not sure why.")
return
}
tests := []struct {
cfgName string
source string
@@ -809,6 +870,7 @@ func TestDetectWithSymlinks(t *testing.T) {
cfgName: "simple",
expectedFindings: []report.Finding{
{
RuleID: "apkey",
Description: "Asymmetric Private Key",
StartLine: 1,
EndLine: 1,
@@ -819,7 +881,6 @@ func TestDetectWithSymlinks(t *testing.T) {
Line: "-----BEGIN OPENSSH PRIVATE KEY-----",
File: "../testdata/repos/symlinks/source_file/id_ed25519",
SymlinkFile: "../testdata/repos/symlinks/file_symlink/symlinked_id_ed25519",
RuleID: "apkey",
Tags: []string{"key", "AsymmetricPrivateKey"},
Entropy: 3.587164,
Fingerprint: "../testdata/repos/symlinks/source_file/id_ed25519:apkey:1",
@@ -838,11 +899,13 @@ func TestDetectWithSymlinks(t *testing.T) {
var vc config.ViperConfig
err = viper.Unmarshal(&vc)
require.NoError(t, err)
cfg, _ := vc.Translate()
detector := NewDetector(cfg)
detector.FollowSymlinks = true
paths, err := sources.DirectoryTargets(tt.source, detector.Sema, true, cfg.Allowlist.PathAllowed)
require.NoError(t, err)
findings, err := detector.DetectFiles(paths)
require.NoError(t, err)
assert.ElementsMatch(t, tt.expectedFindings, findings)
@@ -1107,3 +1170,325 @@ func moveDotGit(t *testing.T, from, to string) {
require.NoError(t, err)
}
}
// region Windows-specific tests[]
func TestNormalizeGitleaksIgnorePaths(t *testing.T) {
d, err := NewDetectorDefaultConfig()
require.NoError(t, err)
err = d.AddGitleaksIgnore("../testdata/gitleaksignore/.windowspaths")
require.NoError(t, err)
assert.Len(t, d.gitleaksIgnore, 3)
expected := map[string]struct{}{
"foo/bar/gitleaks-false-positive.yaml:aws-access-token:4": {},
"foo/bar/gitleaks-false-positive.yaml:aws-access-token:5": {},
"b55d88dc151f7022901cda41a03d43e0e508f2b7:test_data/test_local_repo_three_leaks.json:aws-access-token:73": {},
}
assert.ElementsMatch(t, maps.Keys(d.gitleaksIgnore), maps.Keys(expected))
}
func TestWindowsFileSeparator_RulePath(t *testing.T) {
logging.Logger = logging.Logger.Level(zerolog.TraceLevel)
unixRule := config.Rule{
RuleID: "test-rule",
Path: regexp.MustCompile(`(^|/)\.m2/settings\.xml`),
}
windowsRule := config.Rule{
RuleID: "test-rule",
Path: regexp.MustCompile(`(^|\\)\.m2\\settings\.xml`),
}
expected := []report.Finding{
{
RuleID: "test-rule",
Match: "file detected: .m2/settings.xml",
File: ".m2/settings.xml",
},
}
tests := map[string]struct {
fragment Fragment
rule config.Rule
expected []report.Finding
}{
// unix rule
"unix rule - unix path separator": {
fragment: Fragment{
FilePath: `.m2/settings.xml`,
},
rule: unixRule,
expected: expected,
},
"unix rule - windows path separator": {
fragment: Fragment{
FilePath: `.m2/settings.xml`,
WindowsFilePath: `.m2\settings.xml`,
},
rule: unixRule,
expected: expected,
},
"unix regex+path rule - windows path separator": {
fragment: Fragment{
Raw: `<password>s3cr3t</password>`,
FilePath: `.m2/settings.xml`,
},
rule: config.Rule{
RuleID: "test-rule",
Regex: regexp.MustCompile(`<password>(.+?)</password>`),
Path: regexp.MustCompile(`(^|/)\.m2/settings\.xml`),
},
expected: []report.Finding{
{
RuleID: "test-rule",
StartColumn: 1,
EndColumn: 27,
Line: "<password>s3cr3t</password>",
Match: "<password>s3cr3t</password>",
Secret: "s3cr3t",
Entropy: 2.251629114151001,
File: ".m2/settings.xml",
},
},
},
// windows rule
"windows rule - unix path separator": {
fragment: Fragment{
FilePath: `.m2/settings.xml`,
},
rule: windowsRule,
// This never worked, and continues not to work.
// Paths should be normalized to use Unix file separators.
expected: nil,
},
"windows rule - windows path separator": {
fragment: Fragment{
FilePath: `.m2/settings.xml`,
WindowsFilePath: `.m2\settings.xml`,
},
rule: windowsRule,
expected: expected,
},
"windows regex+path rule - windows path separator": {
fragment: Fragment{
Raw: `<password>s3cr3t</password>`,
FilePath: `.m2/settings.xml`,
WindowsFilePath: `.m2\settings.xml`,
},
rule: config.Rule{
RuleID: "test-rule",
Regex: regexp.MustCompile(`<password>(.+?)</password>`),
Path: regexp.MustCompile(`(^|\\)\.m2\\settings\.xml`),
},
expected: []report.Finding{
{
RuleID: "test-rule",
StartColumn: 1,
EndColumn: 27,
Line: "<password>s3cr3t</password>",
Match: "<password>s3cr3t</password>",
Secret: "s3cr3t",
Entropy: 2.251629114151001,
File: ".m2/settings.xml",
},
}},
}
d, err := NewDetectorDefaultConfig()
require.NoError(t, err)
for name, test := range tests {
t.Run(name, func(t *testing.T) {
actual := d.detectRule(test.fragment, test.fragment.Raw, test.rule, []EncodedSegment{})
if diff := cmp.Diff(test.expected, actual); diff != "" {
t.Errorf("diff: (-want +got)\n%s", diff)
}
})
}
}
func TestWindowsFileSeparator_RuleAllowlistPaths(t *testing.T) {
tests := map[string]struct {
fragment Fragment
rule config.Rule
expected []report.Finding
}{
// unix
"unix path separator - unix rule - OR allowlist path-only": {
fragment: Fragment{
Raw: `value: "s3cr3t"`,
FilePath: `ignoreme/unix.txt`,
},
rule: config.Rule{
RuleID: "unix-rule",
Regex: regexp.MustCompile(`s3cr3t`),
Allowlists: []config.Allowlist{
{
Paths: []*regexp.Regexp{regexp.MustCompile(`(^|/)ignoreme(/.*)?$`)},
},
},
},
expected: nil,
},
"unix path separator - windows rule - OR allowlist path-only": {
fragment: Fragment{
Raw: `value: "s3cr3t"`,
FilePath: `ignoreme/unix.txt`,
},
rule: config.Rule{
RuleID: "windows-rule",
Regex: regexp.MustCompile(`s3cr3t`),
Allowlists: []config.Allowlist{
{
Paths: []*regexp.Regexp{regexp.MustCompile(`(^|\\)ignoreme(\\.*)?$`)},
},
},
},
// Windows separators in regex don't work for unix.
expected: []report.Finding{
{
RuleID: "windows-rule",
StartColumn: 9,
EndColumn: 14,
Line: `value: "s3cr3t"`,
Match: `s3cr3t`,
Secret: `s3cr3t`,
File: "ignoreme/unix.txt",
Entropy: 2.251629114151001,
},
},
},
"unix path separator - unix rule - AND allowlist path+stopwords": {
fragment: Fragment{
Raw: `value: "f4k3s3cr3t"`,
FilePath: `ignoreme/unix.txt`,
},
rule: config.Rule{
RuleID: "unix-rule",
Regex: regexp.MustCompile(`value: "[^"]+"`),
Allowlists: []config.Allowlist{
{
MatchCondition: config.AllowlistMatchAnd,
Paths: []*regexp.Regexp{regexp.MustCompile(`(^|/)ignoreme(/.*)?$`)},
StopWords: []string{"f4k3"},
},
},
},
expected: nil,
},
"unix path separator - windows rule - AND allowlist path+stopwords": {
fragment: Fragment{
Raw: `value: "f4k3s3cr3t"`,
FilePath: `ignoreme/unix.txt`,
},
rule: config.Rule{
RuleID: "windows-rule",
Regex: regexp.MustCompile(`value: "[^"]+"`),
Allowlists: []config.Allowlist{
{
MatchCondition: config.AllowlistMatchAnd,
Paths: []*regexp.Regexp{regexp.MustCompile(`(^|\\)ignoreme(\\.*)?$`)},
StopWords: []string{"f4k3"},
},
},
},
expected: []report.Finding{
{
RuleID: "windows-rule",
StartColumn: 1,
EndColumn: 19,
Line: `value: "f4k3s3cr3t"`,
Match: `value: "f4k3s3cr3t"`,
Secret: `value: "f4k3s3cr3t"`,
File: "ignoreme/unix.txt",
Entropy: 3.892407178878784,
},
},
},
// windows
"windows path separator - unix rule - OR allowlist path-only": {
fragment: Fragment{
Raw: `value: "s3cr3t"`,
FilePath: `ignoreme/windows.txt`,
WindowsFilePath: `ignoreme\windows.txt`,
},
rule: config.Rule{
RuleID: "unix-rule",
Regex: regexp.MustCompile(`s3cr3t`),
Allowlists: []config.Allowlist{
{
Paths: []*regexp.Regexp{regexp.MustCompile(`(^|/)ignoreme(/.*)?$`)},
},
},
},
expected: nil,
},
"windows path separator - windows rule - OR allowlist path-only": {
fragment: Fragment{
Raw: `value: "s3cr3t"`,
FilePath: `ignoreme/windows.txt`,
WindowsFilePath: `ignoreme\windows.txt`,
},
rule: config.Rule{
RuleID: "windows-rule",
Regex: regexp.MustCompile(`s3cr3t`),
Allowlists: []config.Allowlist{
{
Paths: []*regexp.Regexp{regexp.MustCompile(`(^|\\)ignoreme(\\.*)?$`)},
},
},
},
expected: nil,
},
"windows path separator - unix rule - AND allowlist path+stopwords": {
fragment: Fragment{
Raw: `value: "f4k3s3cr3t"`,
FilePath: `ignoreme/unix.txt`,
WindowsFilePath: `ignoreme\windows.txt`,
},
rule: config.Rule{
RuleID: "unix-rule",
Regex: regexp.MustCompile(`value: "[^"]+"`),
Allowlists: []config.Allowlist{
{
MatchCondition: config.AllowlistMatchAnd,
Paths: []*regexp.Regexp{regexp.MustCompile(`(^|/)ignoreme(/.*)?$`)},
StopWords: []string{"f4k3"},
},
},
},
expected: nil,
},
"windows path separator - windows rule - AND allowlist path+stopwords": {
fragment: Fragment{
Raw: `value: "f4k3s3cr3t"`,
FilePath: `ignoreme/unix.txt`,
WindowsFilePath: `ignoreme\windows.txt`,
},
rule: config.Rule{
RuleID: "windows-rule",
Regex: regexp.MustCompile(`value: "[^"]+"`),
Allowlists: []config.Allowlist{
{
MatchCondition: config.AllowlistMatchAnd,
Paths: []*regexp.Regexp{regexp.MustCompile(`(^|\\)ignoreme(\\.*)?$`)},
StopWords: []string{"f4k3"},
},
},
},
expected: nil,
},
}
d, err := NewDetectorDefaultConfig()
require.NoError(t, err)
for name, test := range tests {
t.Run(name, func(t *testing.T) {
actual := d.detectRule(test.fragment, test.fragment.Raw, test.rule, []EncodedSegment{})
if diff := cmp.Diff(test.expected, actual); diff != "" {
t.Errorf("diff: (-want +got)\n%s", diff)
}
})
}
}
//endregion
+108 -60
View File
@@ -1,14 +1,16 @@
package detect
import (
"bufio"
"bytes"
"io"
"os"
"path/filepath"
"strings"
"github.com/h2non/filetype"
"github.com/rs/zerolog/log"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/sources"
)
@@ -18,7 +20,7 @@ const maxPeekSize = 25 * 1_000 // 10kb
func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Finding, error) {
for pa := range paths {
d.Sema.Go(func() error {
logger := log.With().Str("path", pa.Path).Logger()
logger := logging.With().Str("path", pa.Path).Logger()
logger.Trace().Msg("Scanning path")
f, err := os.Open(pa.Path)
@@ -49,82 +51,58 @@ func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Findin
}
}
// Buffer to hold file chunks
buf := make([]byte, chunkSize)
totalLines := 0
var (
// Buffer to hold file chunks
reader = bufio.NewReaderSize(f, chunkSize)
buf = make([]byte, chunkSize)
totalLines = 0
)
for {
n, err := f.Read(buf)
n, err := reader.Read(buf)
// "Callers should always process the n > 0 bytes returned before considering the error err."
// https://pkg.go.dev/io#Reader
if n > 0 {
// TODO: optimization could be introduced here
if mimetype, err := filetype.Match(buf[:n]); err != nil {
return nil
} else if mimetype.MIME.Type == "application" {
return nil // skip binary files
// Only check the filetype at the start of file.
if totalLines == 0 {
// TODO: could other optimizations be introduced here?
if mimetype, err := filetype.Match(buf[:n]); err != nil {
return nil
} else if mimetype.MIME.Type == "application" {
return nil // skip binary files
}
}
// If the chunk doesn't end in a newline, peek |maxPeekSize| until we find one.
// This hopefully avoids splitting
// See: https://github.com/gitleaks/gitleaks/issues/1651
var (
peekBuf = bytes.NewBuffer(buf[:n])
tempBuf = make([]byte, 1)
newlineCount = 0 // Tracks consecutive newlines
)
for {
data := peekBuf.Bytes()
if len(data) == 0 {
break
}
// Check if the last character is a newline.
lastChar := data[len(data)-1]
if lastChar == '\n' || lastChar == '\r' {
newlineCount++
// Stop if two consecutive newlines are found
if newlineCount >= 2 {
break
}
} else {
newlineCount = 0 // Reset if a non-newline character is found
}
// Stop growing the buffer if it reaches maxSize
if (peekBuf.Len() - n) >= maxPeekSize {
break
}
// Read additional data into a temporary buffer
m, readErr := f.Read(tempBuf)
if m > 0 {
peekBuf.Write(tempBuf[:m])
}
// Stop if EOF is reached
if readErr != nil {
if readErr == io.EOF {
break
}
return readErr
}
// Try to split chunks across large areas of whitespace, if possible.
peekBuf := bytes.NewBuffer(buf[:n])
if readErr := readUntilSafeBoundary(reader, n, maxPeekSize, peekBuf); readErr != nil {
return readErr
}
// Count the number of newlines in this chunk
chunk := string(peekBuf.Bytes())
chunk := peekBuf.String()
linesInChunk := strings.Count(chunk, "\n")
totalLines += linesInChunk
fragment := Fragment{
Raw: chunk,
FilePath: pa.Path,
Raw: chunk,
Bytes: peekBuf.Bytes(),
}
if pa.Symlink != "" {
fragment.SymlinkFile = pa.Symlink
}
if isWindows {
fragment.FilePath = filepath.ToSlash(pa.Path)
fragment.SymlinkFile = filepath.ToSlash(fragment.SymlinkFile)
fragment.WindowsFilePath = pa.Path
} else {
fragment.FilePath = pa.Path
}
for _, finding := range d.Detect(fragment) {
// need to add 1 since line counting starts at 1
finding.StartLine += (totalLines - linesInChunk) + 1
finding.EndLine += (totalLines - linesInChunk) + 1
d.addFinding(finding)
d.AddFinding(finding)
}
}
@@ -144,3 +122,73 @@ func (d *Detector) DetectFiles(paths <-chan sources.ScanTarget) ([]report.Findin
return d.findings, nil
}
// readUntilSafeBoundary consumes |f| until it finds two consecutive `\n` characters, up to |maxPeekSize|.
// This hopefully avoids splitting. (https://github.com/gitleaks/gitleaks/issues/1651)
func readUntilSafeBoundary(r *bufio.Reader, n int, maxPeekSize int, peekBuf *bytes.Buffer) error {
if peekBuf.Len() == 0 {
return nil
}
// Does the buffer end in consecutive newlines?
var (
data = peekBuf.Bytes()
lastChar = data[len(data)-1]
newlineCount = 0 // Tracks consecutive newlines
)
if isWhitespace(lastChar) {
for i := len(data) - 1; i >= 0; i-- {
lastChar = data[i]
if lastChar == '\n' {
newlineCount++
// Stop if two consecutive newlines are found
if newlineCount >= 2 {
return nil
}
} else if lastChar == '\r' || lastChar == ' ' || lastChar == '\t' {
// The presence of other whitespace characters (`\r`, ` `, `\t`) shouldn't reset the count.
// (Intentionally do nothing.)
} else {
break
}
}
}
// If not, read ahead until we (hopefully) find some.
newlineCount = 0
for {
data = peekBuf.Bytes()
// Check if the last character is a newline.
lastChar = data[len(data)-1]
if lastChar == '\n' {
newlineCount++
// Stop if two consecutive newlines are found
if newlineCount >= 2 {
break
}
} else if lastChar == '\r' || lastChar == ' ' || lastChar == '\t' {
// The presence of other whitespace characters (`\r`, ` `, `\t`) shouldn't reset the count.
// (Intentionally do nothing.)
} else {
newlineCount = 0 // Reset if a non-newline character is found
}
// Stop growing the buffer if it reaches maxSize
if (peekBuf.Len() - n) >= maxPeekSize {
break
}
// Read additional data into a temporary buffer
b, err := r.ReadByte()
if err != nil {
if err == io.EOF {
break
}
return err
}
peekBuf.WriteByte(b)
}
return nil
}
+72
View File
@@ -0,0 +1,72 @@
package detect
import (
"bufio"
"bytes"
"io"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func Test_readUntilSafeBoundary(t *testing.T) {
// Arrange
cases := []struct {
name string
r io.Reader
expected string
}{
// Current split is fine, exit early.
{
name: "safe original split - LF",
r: strings.NewReader("abc\n\ndefghijklmnop\n\nqrstuvwxyz"),
expected: "abc\n\n",
},
{
name: "safe original split - CRLF",
r: strings.NewReader("a\r\n\r\nbcdefghijklmnop\n"),
expected: "a\r\n\r\n",
},
// Current split is bad, look for a better one.
{
name: "safe split - LF",
r: strings.NewReader("abcdefg\nhijklmnop\n\nqrstuvwxyz"),
expected: "abcdefg\nhijklmnop\n\n",
},
{
name: "safe split - CRLF",
r: strings.NewReader("abcdefg\r\nhijklmnop\r\n\r\nqrstuvwxyz"),
expected: "abcdefg\r\nhijklmnop\r\n\r\n",
},
{
name: "safe split - blank line",
r: strings.NewReader("abcdefg\nhijklmnop\n\t \t\nqrstuvwxyz"),
expected: "abcdefg\nhijklmnop\n\t \t\n",
},
// Current split is bad, exhaust options.
{
name: "no safe split",
r: strings.NewReader("abcdefg\nhijklmnopqrstuvwxyz"),
expected: "abcdefg\nhijklmnopqrstuvwx",
},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
buf := make([]byte, 5)
n, err := c.r.Read(buf)
require.NoError(t, err)
// Act
reader := bufio.NewReader(c.r)
peekBuf := bytes.NewBuffer(buf[:n])
err = readUntilSafeBoundary(reader, n, 20, peekBuf)
require.NoError(t, err)
// Assert
t.Logf(peekBuf.String())
require.Equal(t, c.expected, string(peekBuf.Bytes()))
})
}
}
+113 -9
View File
@@ -1,16 +1,28 @@
package detect
import (
"bytes"
"errors"
"fmt"
"net/url"
"os/exec"
"regexp"
"strings"
"github.com/gitleaks/go-gitdiff/gitdiff"
"github.com/rs/zerolog/log"
"github.com/zricethezav/gitleaks/v8/cmd/scm"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/zricethezav/gitleaks/v8/sources"
)
func (d *Detector) DetectGit(gitCmd *sources.GitCmd) ([]report.Finding, error) {
defer gitCmd.Wait()
diffFilesCh := gitCmd.DiffFilesCh()
errCh := gitCmd.ErrCh()
func (d *Detector) DetectGit(cmd *sources.GitCmd, remote *RemoteInfo) ([]report.Finding, error) {
defer cmd.Wait()
var (
diffFilesCh = cmd.DiffFilesCh()
errCh = cmd.ErrCh()
)
// loop to range over both DiffFiles (stdout) and ErrCh (stderr)
for diffFilesCh != nil || errCh != nil {
@@ -30,7 +42,8 @@ func (d *Detector) DetectGit(gitCmd *sources.GitCmd) ([]report.Finding, error) {
commitSHA := ""
if gitdiffFile.PatchHeader != nil {
commitSHA = gitdiffFile.PatchHeader.SHA
if d.Config.Allowlist.CommitAllowed(gitdiffFile.PatchHeader.SHA) {
if ok, c := d.Config.Allowlist.CommitAllowed(gitdiffFile.PatchHeader.SHA); ok {
logging.Trace().Str("allowed-commit", c).Msg("skipping commit: global allowlist")
continue
}
}
@@ -49,7 +62,7 @@ func (d *Detector) DetectGit(gitCmd *sources.GitCmd) ([]report.Finding, error) {
}
for _, finding := range d.Detect(fragment) {
d.addFinding(augmentGitFinding(finding, textFragment, gitdiffFile))
d.AddFinding(augmentGitFinding(remote, finding, textFragment, gitdiffFile))
}
}
return nil
@@ -67,7 +80,98 @@ func (d *Detector) DetectGit(gitCmd *sources.GitCmd) ([]report.Finding, error) {
if err := d.Sema.Wait(); err != nil {
return d.findings, err
}
log.Info().Msgf("%d commits scanned.", len(d.commitMap))
log.Debug().Msg("Note: this number might be smaller than expected due to commits with no additions")
logging.Info().Msgf("%d commits scanned.", len(d.commitMap))
logging.Debug().Msg("Note: this number might be smaller than expected due to commits with no additions")
return d.findings, nil
}
type RemoteInfo struct {
Platform scm.Platform
Url string
}
func NewRemoteInfo(platform scm.Platform, source string) *RemoteInfo {
if platform == scm.NoPlatform {
return &RemoteInfo{Platform: platform}
}
remoteUrl, err := getRemoteUrl(source)
if err != nil {
if strings.Contains(err.Error(), "No remote configured") {
logging.Debug().Msg("skipping finding links: repository has no configured remote.")
platform = scm.NoPlatform
} else {
logging.Error().Err(err).Msg("skipping finding links: unable to parse remote URL")
}
goto End
}
if platform == scm.UnknownPlatform {
platform = platformFromHost(remoteUrl)
if platform == scm.UnknownPlatform {
logging.Info().
Str("host", remoteUrl.Hostname()).
Msg("Unknown SCM platform. Use --platform to include links in findings.")
} else {
logging.Debug().
Str("host", remoteUrl.Hostname()).
Str("platform", platform.String()).
Msg("SCM platform parsed from host")
}
}
End:
var rUrl string
if remoteUrl != nil {
rUrl = remoteUrl.String()
}
return &RemoteInfo{
Platform: platform,
Url: rUrl,
}
}
var sshUrlpat = regexp.MustCompile(`^git@([a-zA-Z0-9.-]+):([\w/.-]+?)(?:\.git)?$`)
func getRemoteUrl(source string) (*url.URL, error) {
// This will return the first remote — typically, "origin".
cmd := exec.Command("git", "ls-remote", "--quiet", "--get-url")
if source != "." {
cmd.Dir = source
}
stdout, err := cmd.Output()
if err != nil {
var exitError *exec.ExitError
if errors.As(err, &exitError) {
return nil, fmt.Errorf("command failed (%d): %w, stderr: %s", exitError.ExitCode(), err, string(bytes.TrimSpace(exitError.Stderr)))
}
return nil, err
}
remoteUrl := string(bytes.TrimSpace(stdout))
if matches := sshUrlpat.FindStringSubmatch(remoteUrl); matches != nil {
remoteUrl = fmt.Sprintf("https://%s/%s", matches[1], matches[2])
}
remoteUrl = strings.TrimSuffix(remoteUrl, ".git")
parsedUrl, err := url.Parse(remoteUrl)
if err != nil {
return nil, fmt.Errorf("unable to parse remote URL: %w", err)
}
// Remove any user info.
parsedUrl.User = nil
return parsedUrl, nil
}
func platformFromHost(u *url.URL) scm.Platform {
switch strings.ToLower(u.Hostname()) {
case "github.com":
return scm.GitHubPlatform
case "gitlab.com":
return scm.GitLabPlatform
default:
return scm.UnknownPlatform
}
}
+91 -7
View File
@@ -2,6 +2,8 @@ package detect
import (
"bufio"
"bytes"
"errors"
"io"
"github.com/zricethezav/gitleaks/v8/report"
@@ -10,18 +12,23 @@ import (
// DetectReader accepts an io.Reader and a buffer size for the reader in KB
func (d *Detector) DetectReader(r io.Reader, bufSize int) ([]report.Finding, error) {
reader := bufio.NewReader(r)
buf := make([]byte, 0, 1000*bufSize)
buf := make([]byte, 1000*bufSize)
findings := []report.Finding{}
for {
n, err := reader.Read(buf[:cap(buf)])
n, err := reader.Read(buf)
// "Callers should always process the n > 0 bytes returned before considering the error err."
// https://pkg.go.dev/io#Reader
if n > 0 {
buf = buf[:n]
// Try to split chunks across large areas of whitespace, if possible.
peekBuf := bytes.NewBuffer(buf[:n])
if readErr := readUntilSafeBoundary(reader, n, maxPeekSize, peekBuf); readErr != nil {
return findings, readErr
}
fragment := Fragment{
Raw: string(buf),
Raw: peekBuf.String(),
}
for _, finding := range d.Detect(fragment) {
findings = append(findings, finding)
@@ -32,12 +39,89 @@ func (d *Detector) DetectReader(r io.Reader, bufSize int) ([]report.Finding, err
}
if err != nil {
if err != io.EOF {
return findings, err
if err == io.EOF {
break
}
break
return findings, err
}
}
return findings, nil
}
// StreamDetectReader streams the detection results from the provided io.Reader.
// It reads data using the specified buffer size (in KB) and processes each chunk through
// the existing detection logic. Findings are sent down the returned findings channel as soon as
// they are detected, while a separate error channel signals a terminal error (or nil upon successful completion).
// The function returns two channels:
// - findingsCh: a receive-only channel that emits report.Finding objects as they are found.
// - errCh: a receive-only channel that emits a single final error (or nil if no error occurred)
// once the stream ends.
//
// Recommended Usage:
//
// Since there will only ever be a single value on the errCh, it is recommended to consume the findingsCh
// first. Once findingsCh is closed, the consumer should then read from errCh to determine
// if the stream completed successfully or if an error occurred.
//
// This design avoids the need for a select loop, keeping client code simple.
//
// Example:
//
// // Assume detector is an instance of *Detector and myReader implements io.Reader.
// findingsCh, errCh := detector.StreamDetectReader(myReader, 64) // using 64 KB buffer size
//
// // Process findings as they arrive.
// for finding := range findingsCh {
// fmt.Printf("Found secret: %+v\n", finding)
// }
//
// // After the findings channel is closed, check the final error.
// if err := <-errCh; err != nil {
// log.Fatalf("StreamDetectReader encountered an error: %v", err)
// } else {
// fmt.Println("Scanning completed successfully.")
// }
func (d *Detector) StreamDetectReader(r io.Reader, bufSize int) (<-chan report.Finding, <-chan error) {
findingsCh := make(chan report.Finding, 1)
errCh := make(chan error, 1)
go func() {
defer close(findingsCh)
defer close(errCh)
reader := bufio.NewReader(r)
buf := make([]byte, 1000*bufSize)
for {
n, err := reader.Read(buf)
if n > 0 {
peekBuf := bytes.NewBuffer(buf[:n])
if readErr := readUntilSafeBoundary(reader, n, maxPeekSize, peekBuf); readErr != nil {
errCh <- readErr
return
}
fragment := Fragment{Raw: peekBuf.String()}
for _, finding := range d.Detect(fragment) {
findingsCh <- finding
if d.Verbose {
printFinding(finding, d.NoColor)
}
}
}
if err != nil {
if errors.Is(err, io.EOF) {
errCh <- nil
return
}
errCh <- err
return
}
}
}()
return findingsCh, errCh
}
+103 -1
View File
@@ -1,23 +1,38 @@
package detect
import (
"github.com/stretchr/testify/require"
"bytes"
"errors"
"io"
"strings"
"testing"
"testing/iotest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/zricethezav/gitleaks/v8/report"
)
const secret = "AKIAIRYLJVKMPEGZMPJS"
type mockReader struct {
data []byte
read bool
errToReturn error
}
func (r *mockReader) Read(p []byte) (n int, err error) {
if r.read {
return 0, io.EOF
}
// Copy data to the provided buffer.
n = copy(p, r.data)
r.read = true
if r.errToReturn != nil {
return n, r.errToReturn
}
// Return io.EOF along with the bytes.
return n, io.EOF
@@ -59,3 +74,90 @@ func TestDetectReader(t *testing.T) {
})
}
}
func TestStreamDetectReader(t *testing.T) {
tests := []struct {
name string
reader io.Reader
bufSize int
expectedCount int
expectError bool
}{
{
name: "Single secret streaming",
bufSize: 10,
expectedCount: 1,
reader: strings.NewReader(secret),
expectError: false,
},
{
name: "Empty reader",
bufSize: 10,
expectedCount: 0,
reader: strings.NewReader(""),
expectError: false,
},
{
name: "Reader returns error",
bufSize: 10,
expectedCount: 0,
reader: iotest.ErrReader(errors.New("simulated read error")),
expectError: true,
},
{
name: "Multiple secrets with larger buffer",
bufSize: 20,
expectedCount: 2,
reader: strings.NewReader(secret + "\n" + secret),
expectError: false,
},
{
name: "Mock reader with EOF",
bufSize: 10,
expectedCount: 1,
reader: &mockReader{data: []byte(secret)},
expectError: false,
},
{
name: "Secret split across boundary",
bufSize: 1, // 1KB buffer forces multiple reads
expectedCount: 1,
reader: io.MultiReader(
strings.NewReader(secret[:len(secret)/2]),
strings.NewReader(secret[len(secret)/2:])),
expectError: false,
},
{
name: "Reader returns error after first read",
bufSize: 1,
expectedCount: 0,
reader: &mockReader{
data: append(bytes.Repeat([]byte("blah"), 1000), []byte(secret)...),
errToReturn: errors.New("simulated read error"),
},
expectError: true,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
detector, err := NewDetectorDefaultConfig()
require.NoError(t, err)
findingsCh, errCh := detector.StreamDetectReader(test.reader, test.bufSize)
var findings []report.Finding
for f := range findingsCh {
findings = append(findings, f)
}
finalErr := <-errCh
if test.expectError {
require.Error(t, finalErr)
} else {
require.NoError(t, finalErr)
}
assert.Equal(t, test.expectedCount, len(findings))
})
}
}
+60 -15
View File
@@ -4,20 +4,21 @@ import (
// "encoding/json"
"fmt"
"math"
"path/filepath"
"strings"
"time"
"github.com/charmbracelet/lipgloss"
"github.com/zricethezav/gitleaks/v8/cmd/scm"
"github.com/zricethezav/gitleaks/v8/logging"
"github.com/zricethezav/gitleaks/v8/report"
"github.com/charmbracelet/lipgloss"
"github.com/gitleaks/go-gitdiff/gitdiff"
"github.com/rs/zerolog/log"
)
// augmentGitFinding updates the start and end line numbers of a finding to include the
// delta from the git diff
func augmentGitFinding(finding report.Finding, textFragment *gitdiff.TextFragment, f *gitdiff.File) report.Finding {
func augmentGitFinding(remote *RemoteInfo, finding report.Finding, textFragment *gitdiff.TextFragment, f *gitdiff.File) report.Finding {
if !strings.HasPrefix(finding.Match, "file detected") {
finding.StartLine += int(textFragment.NewPosition)
finding.EndLine += int(textFragment.NewPosition)
@@ -25,16 +26,64 @@ func augmentGitFinding(finding report.Finding, textFragment *gitdiff.TextFragmen
if f.PatchHeader != nil {
finding.Commit = f.PatchHeader.SHA
finding.Message = f.PatchHeader.Message()
if f.PatchHeader.Author != nil {
finding.Author = f.PatchHeader.Author.Name
finding.Email = f.PatchHeader.Author.Email
}
finding.Date = f.PatchHeader.AuthorDate.UTC().Format(time.RFC3339)
finding.Message = f.PatchHeader.Message()
// Results from `git diff` shouldn't have a link.
if finding.Commit != "" {
finding.Link = createScmLink(remote.Platform, remote.Url, finding)
}
}
return finding
}
var linkCleaner = strings.NewReplacer(
" ", "%20",
"%", "%25",
)
func createScmLink(scmPlatform scm.Platform, remoteUrl string, finding report.Finding) string {
if scmPlatform == scm.UnknownPlatform || scmPlatform == scm.NoPlatform {
return ""
}
// Clean the path.
var (
filePath = linkCleaner.Replace(finding.File)
ext = strings.ToLower(filepath.Ext(filePath))
)
switch scmPlatform {
case scm.GitHubPlatform:
link := fmt.Sprintf("%s/blob/%s/%s", remoteUrl, finding.Commit, filePath)
if ext == ".ipynb" || ext == ".md" {
link += "?plain=1"
}
if finding.StartLine != 0 {
link += fmt.Sprintf("#L%d", finding.StartLine)
}
if finding.EndLine != finding.StartLine {
link += fmt.Sprintf("-L%d", finding.EndLine)
}
return link
case scm.GitLabPlatform:
link := fmt.Sprintf("%s/blob/%s/%s", remoteUrl, finding.Commit, filePath)
if finding.StartLine != 0 {
link += fmt.Sprintf("#L%d", finding.StartLine)
}
if finding.EndLine != finding.StartLine {
link += fmt.Sprintf("-%d", finding.EndLine)
}
return link
default:
// This should never happen.
return ""
}
}
// shannonEntropy calculates the entropy of data using the formula defined here:
// https://en.wiktionary.org/wiki/Shannon_entropy
// Another way to think about what this is doing is calculating the number of bits
@@ -74,7 +123,7 @@ func filter(findings []report.Finding, redact uint) []report.Finding {
genericMatch := strings.Replace(f.Match, f.Secret, "REDACTED", -1)
betterMatch := strings.Replace(fPrime.Match, fPrime.Secret, "REDACTED", -1)
log.Trace().Msgf("skipping %s finding (%s), %s rule takes precedence (%s)", f.RuleID, genericMatch, fPrime.RuleID, betterMatch)
logging.Trace().Msgf("skipping %s finding (%s), %s rule takes precedence (%s)", f.RuleID, genericMatch, fPrime.RuleID, betterMatch)
include = false
break
}
@@ -177,16 +226,12 @@ func printFinding(f report.Finding, noColor bool) {
fmt.Printf("%-12s %s\n", "Email:", f.Email)
fmt.Printf("%-12s %s\n", "Date:", f.Date)
fmt.Printf("%-12s %s\n", "Fingerprint:", f.Fingerprint)
if f.Link != "" {
fmt.Printf("%-12s %s\n", "Link:", f.Link)
}
fmt.Println("")
}
func containsDigit(s string) bool {
for _, c := range s {
switch c {
case '1', '2', '3', '4', '5', '6', '7', '8', '9':
return true
}
}
return false
func isWhitespace(ch byte) bool {
return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'
}
+101
View File
@@ -0,0 +1,101 @@
package detect
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zricethezav/gitleaks/v8/cmd/scm"
"github.com/zricethezav/gitleaks/v8/report"
)
func Test_createScmLink(t *testing.T) {
tests := map[string]struct {
platform scm.Platform
url string
finding report.Finding
want string
}{
// None
"no platform": {
platform: scm.NoPlatform,
want: "",
},
// GitHub
"github - single line": {
platform: scm.GitHubPlatform,
url: "https://github.com/gitleaks/test",
finding: report.Finding{
Commit: "20553ad96a4a080c94a54d677db97eed8ce2560d",
File: "metrics/% of sales/.env",
StartLine: 25,
EndLine: 25,
},
want: "https://github.com/gitleaks/test/blob/20553ad96a4a080c94a54d677db97eed8ce2560d/metrics/%25%20of%20sales/.env#L25",
},
"github - multi line": {
platform: scm.GitHubPlatform,
url: "https://github.com/gitleaks/test",
finding: report.Finding{
Commit: "7bad9f7654cf9701b62400281748c0e8efd97666",
File: "config.json",
StartLine: 235,
EndLine: 238,
},
want: "https://github.com/gitleaks/test/blob/7bad9f7654cf9701b62400281748c0e8efd97666/config.json#L235-L238",
},
"github - markdown": {
platform: scm.GitHubPlatform,
url: "https://github.com/gitleaks/test",
finding: report.Finding{
Commit: "1fc8961d172f39ffb671766e472aa76f8d713e87",
File: "docs/guides/ecosystem/discordjs.MD",
StartLine: 34,
EndLine: 34,
},
want: "https://github.com/gitleaks/test/blob/1fc8961d172f39ffb671766e472aa76f8d713e87/docs/guides/ecosystem/discordjs.MD?plain=1#L34",
},
"github - jupyter notebook": {
platform: scm.GitHubPlatform,
url: "https://github.com/gitleaks/test",
finding: report.Finding{
Commit: "8f56bd2369595bcadbb007e88ba294630fb05c7b",
File: "Cloud/IPYNB/Overlapping Recommendation algorithm _OCuLaR_.ipynb",
StartLine: 293,
EndLine: 293,
},
want: "https://github.com/gitleaks/test/blob/8f56bd2369595bcadbb007e88ba294630fb05c7b/Cloud/IPYNB/Overlapping%20Recommendation%20algorithm%20_OCuLaR_.ipynb?plain=1#L293",
},
// GitLab
"gitlab - single line": {
platform: scm.GitLabPlatform,
url: "https://gitlab.com/example-org/example-group/gitleaks",
finding: report.Finding{
Commit: "213ffd1c9bfa906eb4c7731771132c58a4ca0139",
File: ".gitlab-ci.yml",
StartLine: 41,
EndLine: 41,
},
want: "https://gitlab.com/example-org/example-group/gitleaks/blob/213ffd1c9bfa906eb4c7731771132c58a4ca0139/.gitlab-ci.yml#L41",
},
"gitlab - multi line": {
platform: scm.GitLabPlatform,
url: "https://gitlab.com/example-org/example-group/gitleaks",
finding: report.Finding{
Commit: "63410f74e23a4e51e1f60b9feb073b5d325af878",
File: ".vscode/launchSettings.json",
StartLine: 6,
EndLine: 8,
},
want: "https://gitlab.com/example-org/example-group/gitleaks/blob/63410f74e23a4e51e1f60b9feb073b5d325af878/.vscode/launchSettings.json#L6-8",
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
actual := createScmLink(tt.platform, tt.url, tt.finding)
assert.Equal(t, tt.want, actual)
})
}
}
+37 -28
View File
@@ -1,59 +1,68 @@
module github.com/zricethezav/gitleaks/v8
go 1.23
go 1.23.0
toolchain go1.23.4
require (
github.com/BobuSumisu/aho-corasick v1.0.3
github.com/Masterminds/sprig v2.22.0+incompatible
github.com/Masterminds/sprig/v3 v3.3.0
github.com/charmbracelet/lipgloss v0.5.0
github.com/fatih/semgroup v1.2.0
github.com/gitleaks/go-gitdiff v0.9.1
github.com/google/go-cmp v0.6.0
github.com/h2non/filetype v1.1.3
github.com/rs/zerolog v1.26.1
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.9.1
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa
)
require (
dario.cat/mergo v1.0.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 // indirect
github.com/muesli/termenv v0.15.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/tetratelabs/wazero v1.9.0 // indirect
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb
github.com/magiconair/properties v1.8.5 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/spf13/afero v1.12.0 // indirect
github.com/spf13/cast v1.7.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/wasilibs/go-re2 v1.9.0
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/text v0.22.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+87 -611
View File
@@ -1,662 +1,138 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg=
cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8=
cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/BobuSumisu/aho-corasick v1.0.3 h1:uuf+JHwU9CHP2Vx+wAy6jcksJThhJS9ehR8a+4nPE9g=
github.com/BobuSumisu/aho-corasick v1.0.3/go.mod h1:hm4jLcvZKI2vRF2WDU1N4p/jpWtpOzp3nLmi9AzX/XE=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs=
github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/charmbracelet/lipgloss v0.5.0 h1:lulQHuVeodSgDez+3rGiuxlPVXSnhth442DATR2/8t8=
github.com/charmbracelet/lipgloss v0.5.0/go.mod h1:EZLha/HbzEt7cYqdFPovlqy5FZPj0xFhg5SaqxScmgs=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/semgroup v1.2.0 h1:h/OLXwEM+3NNyAdZEpMiH1OzfplU09i2qXPVThGZvyg=
github.com/fatih/semgroup v1.2.0/go.mod h1:1KAD4iIYfXjE4U13B48VM4z9QUwV5Tt8O4rS879kgm8=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/gitleaks/go-gitdiff v0.9.1 h1:ni6z6/3i9ODT685OLCTf+s/ERlWUNWQF4x1pvoNICw0=
github.com/gitleaks/go-gitdiff v0.9.1/go.mod h1:pKz0X4YzCKZs30BL+weqBIG7mx0jl4tF1uXV9ZyNvrA=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb h1:w1g9wNDIE/pHSTmAaUhv4TZQuPBS6GV3mMz5hkgziIU=
github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68 h1:y1p/ycavWjGT9FnmSjdbWUlLGvcxrY0Rw3ATltrxOhk=
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ=
github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
github.com/muesli/termenv v0.15.1 h1:UzuTb/+hhlBugQz28rpzey4ZuKcZ03MeKsoG7IJZIxs=
github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4ANqrZs2sQ=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ=
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc=
github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.8.1 h1:Kq1fyeebqsBfbjZj4EL7gj2IO0mMaiyjYUWcUsl2O44=
github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
github.com/wasilibs/go-re2 v1.9.0 h1:kjAd8qbNvV4Ve2Uf+zrpTCrDHtqH4dlsRXktywo73JQ=
github.com/wasilibs/go-re2 v1.9.0/go.mod h1:0sRtscWgpUdNA137bmr1IUgrRX0Su4dcn9AEe61y+yI=
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 h1:OvLBa8SqJnZ6P+mjlzc2K7PM22rRUPE1x32G9DTPrC4=
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52/go.mod h1:jMeV4Vpbi8osrE/pKUxRZkVaA0EX7NZN0A9/oRzgpgY=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4=
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU=
google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94=
google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
+50
View File
@@ -0,0 +1,50 @@
package logging
import (
"os"
"github.com/rs/zerolog"
)
var Logger zerolog.Logger
func init() {
// send all logs to stdout
Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).
Level(zerolog.InfoLevel).
With().Timestamp().Logger()
}
func With() zerolog.Context {
return Logger.With()
}
func Trace() *zerolog.Event {
return Logger.Trace()
}
func Debug() *zerolog.Event {
return Logger.Debug()
}
func Info() *zerolog.Event {
return Logger.Info()
}
func Warn() *zerolog.Event {
return Logger.Warn()
}
func Error() *zerolog.Event {
return Logger.Error()
}
func Err(err error) *zerolog.Event {
return Logger.Err(err)
}
func Fatal() *zerolog.Event {
return Logger.Fatal()
}
func Panic() *zerolog.Event {
return Logger.Panic()
}
+2 -6
View File
@@ -4,15 +4,11 @@ import (
"os"
"os/signal"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/zricethezav/gitleaks/v8/cmd"
"github.com/zricethezav/gitleaks/v8/logging"
)
func main() {
// send all logs to stdout
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
// this block sets up a go routine to listen for an interrupt signal
// which will immediately exit gitleaks
stopChan := make(chan os.Signal, 1)
@@ -24,5 +20,5 @@ func main() {
func listenForInterrupt(stopScan chan os.Signal) {
<-stopScan
log.Fatal().Msg("Interrupt signal received. Exiting...")
logging.Fatal().Msg("Interrupt signal received. Exiting...")
}
+15
View File
@@ -0,0 +1,15 @@
//go:build !gore2regex
package regexp
import (
re "regexp"
)
const Version = "stdlib"
type Regexp = re.Regexp
func MustCompile(str string) *re.Regexp {
return re.MustCompile(str)
}
+15
View File
@@ -0,0 +1,15 @@
//go:build gore2regex
package regexp
import (
re "github.com/wasilibs/go-re2"
)
const Version = "github.com/wasilibs/go-re2"
type Regexp = re.Regexp
func MustCompile(str string) *re.Regexp {
return re.MustCompile(str)
}
+19 -7
View File
@@ -17,8 +17,11 @@ func (r *CsvReporter) Write(w io.WriteCloser, findings []Finding) error {
return nil
}
cw := csv.NewWriter(w)
err := cw.Write([]string{"RuleID",
var (
cw = csv.NewWriter(w)
err error
)
columns := []string{"RuleID",
"Commit",
"File",
"SymlinkFile",
@@ -34,12 +37,17 @@ func (r *CsvReporter) Write(w io.WriteCloser, findings []Finding) error {
"Email",
"Fingerprint",
"Tags",
})
if err != nil {
}
// A miserable attempt at "omitempty" so tests don't yell at me.
if findings[0].Link != "" {
columns = append(columns, "Link")
}
if err = cw.Write(columns); err != nil {
return err
}
for _, f := range findings {
err = cw.Write([]string{f.RuleID,
row := []string{f.RuleID,
f.Commit,
f.File,
f.SymlinkFile,
@@ -55,8 +63,12 @@ func (r *CsvReporter) Write(w io.WriteCloser, findings []Finding) error {
f.Email,
f.Fingerprint,
strings.Join(f.Tags, " "),
})
if err != nil {
}
if findings[0].Link != "" {
row = append(row, f.Link)
}
if err = cw.Write(row); err != nil {
return err
}
}
+5 -1
View File
@@ -53,6 +53,7 @@ func TestWriteCSV(t *testing.T) {
t.Run(test.testReportName, func(t *testing.T) {
tmpfile, err := os.Create(filepath.Join(t.TempDir(), test.testReportName+".csv"))
require.NoError(t, err)
defer tmpfile.Close()
err = reporter.Write(tmpfile, test.findings)
require.NoError(t, err)
@@ -67,7 +68,10 @@ func TestWriteCSV(t *testing.T) {
want, err := os.ReadFile(test.expected)
require.NoError(t, err)
assert.Equal(t, string(want), string(got))
wantStr := lineEndingReplacer.Replace(string(want))
gotStr := lineEndingReplacer.Replace(string(got))
assert.Equal(t, wantStr, gotStr)
})
}
}
+4 -3
View File
@@ -8,7 +8,10 @@ import (
// Finding contains information about strings that
// have been captured by a tree-sitter query.
type Finding struct {
// Rule is the name of the rule that was matched
RuleID string
Description string
StartLine int
EndLine int
StartColumn int
@@ -26,6 +29,7 @@ type Finding struct {
File string
SymlinkFile string
Commit string
Link string `json:",omitempty"`
// Entropy is the shannon entropy of Value
Entropy float32
@@ -36,9 +40,6 @@ type Finding struct {
Message string
Tags []string
// Rule is the name of the rule that was matched
RuleID string
// unique identifier
Fingerprint string
}
+8 -1
View File
@@ -53,18 +53,25 @@ func TestWriteJSON(t *testing.T) {
t.Run(test.testReportName, func(t *testing.T) {
tmpfile, err := os.Create(filepath.Join(t.TempDir(), test.testReportName+".json"))
require.NoError(t, err)
defer tmpfile.Close()
err = reporter.Write(tmpfile, test.findings)
require.NoError(t, err)
assert.FileExists(t, tmpfile.Name())
got, err := os.ReadFile(tmpfile.Name())
require.NoError(t, err)
if test.wantEmpty {
assert.Empty(t, got)
return
}
want, err := os.ReadFile(test.expected)
require.NoError(t, err)
assert.Equal(t, string(want), string(got))
wantStr := lineEndingReplacer.Replace(string(want))
gotStr := lineEndingReplacer.Replace(string(got))
assert.Equal(t, wantStr, gotStr)
})
}
}
+5 -1
View File
@@ -69,6 +69,7 @@ func TestWriteJunit(t *testing.T) {
for _, test := range tests {
tmpfile, err := os.Create(filepath.Join(t.TempDir(), test.testReportName+".xml"))
require.NoError(t, err)
defer tmpfile.Close()
err = reporter.Write(tmpfile, test.findings)
require.NoError(t, err)
@@ -83,6 +84,9 @@ func TestWriteJunit(t *testing.T) {
want, err := os.ReadFile(test.expected)
require.NoError(t, err)
assert.Equal(t, string(want), string(got))
wantStr := lineEndingReplacer.Replace(string(want))
gotStr := lineEndingReplacer.Replace(string(got))
assert.Equal(t, wantStr, gotStr)
}
}
+8 -1
View File
@@ -2,6 +2,7 @@ package report
import (
"bytes"
"strings"
"testing"
"github.com/stretchr/testify/assert"
@@ -9,7 +10,6 @@ import (
)
const expectPath = "../testdata/expected/"
const configPath = "../testdata/config/"
const templatePath = "../testdata/report/"
func TestWriteStdout(t *testing.T) {
@@ -40,3 +40,10 @@ type testWriter struct {
func (t testWriter) Close() error {
return nil
}
// lineEndingReplacer normalizes CRLF to LF so tests pass on Windows.
var lineEndingReplacer = strings.NewReplacer(
"\\r\\n", "\\n",
"\r", "",
"\\r", "",
)
+5 -1
View File
@@ -49,6 +49,7 @@ func TestWriteSarif(t *testing.T) {
t.Run(test.cfgName, func(t *testing.T) {
tmpfile, err := os.Create(filepath.Join(t.TempDir(), test.testReportName+".json"))
require.NoError(t, err)
defer tmpfile.Close()
reporter := SarifReporter{
OrderedRules: []config.Rule{
@@ -76,7 +77,10 @@ func TestWriteSarif(t *testing.T) {
want, err := os.ReadFile(test.expected)
require.NoError(t, err)
assert.Equal(t, string(want), string(got))
wantStr := lineEndingReplacer.Replace(string(want))
gotStr := lineEndingReplacer.Replace(string(got))
assert.Equal(t, wantStr, gotStr)
})
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"os"
"text/template"
"github.com/Masterminds/sprig"
"github.com/Masterminds/sprig/v3"
)
type TemplateReporter struct {
+5 -1
View File
@@ -74,6 +74,7 @@ func TestWriteTemplate(t *testing.T) {
tmpfile, err := os.Create(filepath.Join(t.TempDir(), test.testReportName+filepath.Ext(test.expected)))
require.NoError(t, err)
defer tmpfile.Close()
err = reporter.Write(tmpfile, test.findings)
require.NoError(t, err)
@@ -88,7 +89,10 @@ func TestWriteTemplate(t *testing.T) {
want, err := os.ReadFile(test.expected)
require.NoError(t, err)
assert.Equal(t, string(want), string(got))
wantStr := lineEndingReplacer.Replace(string(want))
gotStr := lineEndingReplacer.Replace(string(got))
assert.Equal(t, wantStr, gotStr)
})
}
}
+25
View File
@@ -0,0 +1,25 @@
# Report Templates
Gitleaks has a neat little feature that lets you format the output of your findings via templates. This means Gitleaks can inject finding data into an html file for a web ui. Use the following command then open `index.html` after a scan.
```
--report-path=index.html --report-format=template --report-template=report_templates/basic.tmpl
```
Below lies "vibe coding" slop.
## Basic (Light)
<img width="1425" alt="Screenshot 2025-03-02 at 8 09 39 PM" src="https://github.com/user-attachments/assets/fdd75f95-067b-467b-95c0-3cae581fb069" />
## Basic (Dark)
<img width="1422" alt="Screenshot 2025-03-02 at 8 20 36 PM" src="https://github.com/user-attachments/assets/00d5c57d-6c96-41cf-9ecf-d4abcec9aa17" />
## Windows 98
<img width="1436" alt="Screenshot 2025-03-02 at 8 21 31 PM" src="https://github.com/user-attachments/assets/016a0b6c-c92f-45df-b7de-0b6e87a59b38" />
## Windows XP
<img width="1436" alt="Screenshot 2025-03-02 at 8 22 14 PM" src="https://github.com/user-attachments/assets/20979621-6e75-4d8e-8bb2-5aee367613e6" />
## l33t
<img width="1429" alt="Screenshot 2025-03-02 at 8 23 09 PM" src="https://github.com/user-attachments/assets/18f8d73f-50ba-4199-8bd8-a33f0b28841c" />
## myspace
<img width="1428" alt="Screenshot 2025-03-02 at 8 23 43 PM" src="https://github.com/user-attachments/assets/9135f187-d7ff-4f5a-b94c-8149ccd8efaa" />
+760
View File
@@ -0,0 +1,760 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gitleaks Security Findings Report</title>
<style>
:root {
--primary-color: #2563eb;
--primary-color-rgb: 37, 99, 235;
--primary-dark: #1d4ed8;
--primary-light: #3b82f6;
--secondary-color: #f3f4f6;
--surface-color: #ffffff;
--border-color: #e5e7eb;
--text-color: #374151;
--text-light: #6b7280;
--text-inverse: #ffffff;
--error-color: #ef4444;
--warning-color: #f59e0b;
--success-color: #10b981;
--highlight-color: rgba(255, 255, 0, 0.2);
--highlight-secret: rgba(239, 68, 68, 0.2);
--shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
--radius: 0;
--font-mono: 'Fira Code', 'IBM Plex Mono', 'Source Code Pro', monospace;
--font-main: 'IBM Plex Sans', 'Roboto Mono', monospace;
}
body.dark-mode {
--primary-color: #1e40af;
--primary-dark: #1e3a8a;
--primary-light: #3b82f6;
--secondary-color: #1f2937;
--surface-color: #111827;
--border-color: #374151;
--text-color: #f3f4f6;
--text-light: #9ca3af;
--text-inverse: #111827;
--highlight-color: rgba(255, 255, 0, 0.3);
--highlight-secret: rgba(255, 99, 99, 0.3);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
font-family: var(--font-main);
font-size: 16px;
line-height: 1.5;
color: var(--text-color);
background-color: var(--surface-color);
}
.app-container {
display: flex;
flex-direction: column;
height: 100%;
max-width: 100%;
overflow: hidden;
}
.app-header {
height: 60px;
background-color: var(--primary-color);
color: var(--text-inverse);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 1.5rem;
flex-shrink: 0;
box-shadow: var(--shadow);
z-index: 10;
}
.logo h1 {
font-size: 1.5rem;
font-weight: 600;
}
.header-actions {
display: flex;
align-items: center;
gap: 0.5rem;
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.5rem 1rem;
border-radius: var(--radius);
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
transition: background-color 0.2s, color 0.2s;
border: none;
font-family: var(--font-main);
}
.btn-primary {
background-color: var(--primary-color);
color: var(--text-inverse);
}
.btn-primary:hover {
background-color: var(--primary-dark);
}
.btn-sm {
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
}
.app-main {
flex: 1;
overflow: auto;
padding: 1.5rem;
}
.report-info {
margin-bottom: 1.5rem;
padding: 1rem;
background-color: var(--secondary-color);
border-radius: var(--radius);
border: 1px solid var(--border-color);
}
.report-date {
font-size: 0.875rem;
color: var(--text-light);
}
.report-stats {
display: flex;
gap: 1.5rem;
margin-top: 1rem;
flex-wrap: wrap;
}
.stat-item {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.stat-value {
font-size: 1.25rem;
font-weight: 600;
}
.stat-label {
font-size: 0.875rem;
color: var(--text-light);
}
.table-wrapper {
overflow-x: auto;
border: 1px solid var(--border-color);
border-radius: var(--radius);
}
.findings-table {
width: 100%;
border-collapse: collapse;
font-size: 0.875rem;
}
.findings-table th {
background-color: var(--secondary-color);
padding: 0.75rem;
text-align: left;
font-weight: 500;
position: sticky;
top: 0;
z-index: 1;
}
/* Ensure table cells don't expand too much */
.findings-table td {
padding: 0.75rem;
border-top: 1px solid var(--border-color);
vertical-align: top;
max-width: 300px; /* Limit width of all cells */
overflow-wrap: break-word;
}
.findings-table tr:hover td {
background-color: var(--secondary-color);
}
.findings-table th:nth-child(1) { width: 12%; } /* Rule */
.findings-table th:nth-child(2) { width: 20%; } /* File */
.findings-table th:nth-child(3) { width: 25%; } /* Description */
.findings-table th:nth-child(4) { width: 20%; } /* Secret */
.findings-table th:nth-child(5) { width: 23%; } /* Metadata */
.findings-table td {
padding: 0.75rem;
border-top: 1px solid var(--border-color);
vertical-align: top;
}
.findings-table tr:hover td {
background-color: var(--secondary-color);
}
.secret-container {
position: relative;
}
.match-toggle {
display: inline-block;
margin-top: 0.5rem;
padding: 0.25rem 0.5rem;
background-color: var(--secondary-color);
border: 1px solid var(--border-color);
border-radius: var(--radius);
font-size: 0.75rem;
cursor: pointer;
color: var(--primary-color);
}
.match-toggle:hover {
background-color: var(--primary-color);
color: var(--text-inverse);
}
.hidden {
display: none !important;
}
.secret-match {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: var(--highlight-secret);
padding: 0.5rem;
border-radius: var(--radius);
overflow-x: auto;
}
.tag-list {
display: flex;
gap: 0.25rem;
flex-wrap: wrap;
}
.tag {
display: inline-block;
padding: 0.125rem 0.375rem;
background-color: var(--primary-light);
color: var(--text-inverse);
border-radius: 2px;
font-size: 0.75rem;
}
.meta-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 0.5rem;
margin-top: 0.5rem;
font-size: 0.75rem;
color: var(--text-light);
}
.meta-item {
display: flex;
align-items: center;
gap: 0.25rem;
}
.meta-label {
font-weight: 500;
}
.meta-value {
font-family: var(--font-mono);
word-break: break-all;
}
.code-preview {
position: relative;
font-family: var(--font-mono);
font-size: 0.875rem;
background-color: var(--secondary-color);
padding: 0.5rem;
border-radius: var(--radius);
overflow-x: auto;
margin-top: 0.5rem;
white-space: pre-wrap;
word-break: break-all;
}
.filters {
display: flex;
gap: 1rem;
margin-bottom: 1rem;
flex-wrap: wrap;
}
.filter-group {
display: flex;
align-items: center;
gap: 0.5rem;
}
.filter-label {
font-size: 0.875rem;
font-weight: 500;
}
.filter-input {
padding: 0.375rem 0.75rem;
border: 1px solid var(--border-color);
border-radius: var(--radius);
font-size: 0.875rem;
font-family: var(--font-main);
}
.app-footer {
height: 40px;
padding: 0 1.5rem;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1px solid var(--border-color);
font-size: 0.75rem;
color: var(--text-light);
flex-shrink: 0;
}
@media (max-width: 768px) {
.app-header {
padding: 0 1rem;
}
.app-main {
padding: 1rem;
}
.report-stats {
flex-direction: column;
gap: 0.75rem;
}
.filters {
flex-direction: column;
gap: 0.75rem;
}
.app-footer {
flex-direction: column;
height: auto;
padding: 0.75rem 1rem;
gap: 0.5rem;
justify-content: center;
text-align: center;
}
}
.description-toggle {
cursor: pointer;
color: var(--primary-color);
font-size: 0.875rem;
margin-left: 0.5rem;
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: var(--secondary-color);
vertical-align: middle;
}
.description-toggle:hover {
background-color: var(--primary-light);
color: var(--text-inverse);
}
.description-expanded {
white-space: normal;
}
.description-collapsed {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 250px;
display: inline-block;
}
.commit-link {
color: var(--primary-color);
text-decoration: none;
}
.commit-link:hover {
text-decoration: underline;
}
/* File path styling */
.file-path-container {
max-width: 100%;
}
.file-path {
display: inline-block;
max-width: 100%;
word-wrap: break-word;
word-break: break-all;
}
.match-content {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: var(--secondary-color);
padding: 0.5rem;
border-radius: var(--radius);
margin-top: 0.5rem;
max-height: 300px;
overflow-y: auto;
}
.dark-mode-toggle {
background: none;
border: none;
color: var(--text-inverse);
cursor: pointer;
font-size: 1rem;
}
</style>
</head>
<body>
<div class="app-container">
<header class="app-header">
<div class="logo">
<h1>Gitleaks Security Findings</h1>
</div>
<div class="header-actions">
<button class="dark-mode-toggle" id="darkModeToggle">🌓</button>
</div>
</header>
<main class="app-main">
<div class="report-info">
<h2>Security Scan Report</h2>
<p class="report-date">Generated on {{now | date "Jan 02, 2006 15:04:05 MST"}}</p>
<div class="report-stats">
<div class="stat-item">
<span class="stat-value">{{len .}}</span>
<span class="stat-label">Total Findings</span>
</div>
<div class="stat-item">
<span class="stat-value" id="filesCount">-</span>
<span class="stat-label">Files Affected</span>
</div>
<div class="stat-item">
<span class="stat-value" id="rulesCount">-</span>
<span class="stat-label">Unique Rules Triggered</span>
</div>
<div class="stat-item" id="scanModeContainer">
<span class="stat-value" id="scanMode">-</span>
<span class="stat-label">Scan Mode</span>
</div>
</div>
</div>
<div class="filters">
<div class="filter-group">
<label class="filter-label" for="filterRule">Filter by Rule:</label>
<select class="filter-input" id="filterRule">
<option value="all">All Rules</option>
<!-- Rule options will be populated by JavaScript -->
</select>
</div>
<div class="filter-group">
<label class="filter-label" for="filterFile">Filter by File:</label>
<input type="text" class="filter-input" id="filterFile" placeholder="Enter filename...">
</div>
<div class="filter-group">
<button class="btn btn-primary btn-sm" id="resetFilters">Reset Filters</button>
</div>
</div>
<div class="table-wrapper">
<table class="findings-table" id="findingsTable">
<thead>
<tr>
<th>Rule</th>
<th>File</th>
<th>Description</th>
<th>Secret</th>
<th>Metadata</th>
</tr>
</thead>
<tbody>
{{- range . }}
<tr data-rule="{{.RuleID}}" data-file="{{.File}}">
<td>{{.RuleID}}</td>
<td>
<div class="file-path-container">
<span class="file-path" title="{{.File}}">{{.File}}</span>
</div>
<div class="tag-list">
{{- range .Tags }}
<span class="tag">{{.}}</span>
{{- end}}
</div>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Line:</span>
<span class="meta-value">{{.StartLine}}</span>
</div>
</div>
</td>
<td>
<span class="description-text">{{.Description}}</span>
<span class="description-toggle" title="Expand/Collapse">↕</span>
</td>
<td>
<div class="secret-container" data-secret="{{.Secret}}" data-match="{{.Match}}">
<div class="secret-match">{{.Secret}}</div>
<button type="button" class="match-toggle" title="Show/Hide Full Match Context">Show Context</button>
<div class="match-content hidden" data-raw-match="{{.Match}}">{{.Match}}</div>
</div>
</td>
<td>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Entropy:</span>
<span class="meta-value">{{printf "%.2f" .Entropy}}</span>
</div>
{{- if .Commit}}
<div class="meta-item commit-info">
<span class="meta-label">Commit:</span>
<span class="meta-value">{{if gt (len .Commit) 7}}{{printf "%.7s" .Commit}}{{else}}{{.Commit}}{{end}}</span>
</div>
{{- if .Author}}
<div class="meta-item commit-info">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- if .Date}}
<div class="meta-item commit-info">
<span class="meta-label">Date:</span>
<span class="meta-value">{{.Date}}</span>
</div>
{{- end}}
{{- if .Link}}
<div class="meta-item commit-info">
<span class="meta-label">Link:</span>
<span class="meta-value"><a href="{{.Link}}" target="_blank" class="commit-link">View Commit</a></span>
</div>
{{- end}}
{{- else}}
{{- if .Author}}
<div class="meta-item">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- end}}
</div>
{{- if not .Match}}
<div class="match-content" data-raw-match="">-</div>
{{- end}}
</td>
</tr>
{{- end }}
</tbody>
</table>
</div>
</main>
<footer class="app-footer">
<div>Generated by Gitleaks</div>
<div>Total Findings: <strong>{{len .}}</strong></div>
</footer>
</div>
<script>
// Process data to collect unique files and rules
function processData() {
const rows = document.querySelectorAll('#findingsTable tbody tr');
const uniqueRules = new Set();
const uniqueFiles = new Set();
let isGitMode = false;
if (rows.length > 0) {
// Check if first finding has commit data to determine mode
const firstRow = rows[0];
const commitCells = firstRow.querySelectorAll('.commit-info');
isGitMode = commitCells.length > 0 && commitCells[0].textContent.trim() !== '';
}
// Set scan mode
document.getElementById('scanMode').textContent = isGitMode ? 'Git' : 'Directory';
// Adjust UI based on mode
if (isGitMode) {
// Ensure commit info columns are visible for git mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'block';
});
} else {
// Hide commit-specific UI elements for directory mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'none';
});
}
rows.forEach(row => {
uniqueRules.add(row.dataset.rule);
uniqueFiles.add(row.dataset.file);
});
// Update stats
document.getElementById('filesCount').textContent = uniqueFiles.size;
document.getElementById('rulesCount').textContent = uniqueRules.size;
// Populate rule filter dropdown
const ruleFilter = document.getElementById('filterRule');
const sortedRules = Array.from(uniqueRules).sort();
sortedRules.forEach(rule => {
const option = document.createElement('option');
option.value = rule;
option.textContent = rule;
ruleFilter.appendChild(option);
});
}
// Hide toggle button if match is same as secret
function hideRedundantToggleButtons() {
document.querySelectorAll('.secret-container').forEach(container => {
const secret = container.getAttribute('data-secret');
const match = container.getAttribute('data-match');
const toggleButton = container.querySelector('.match-toggle');
// If secret and match are the same, or if match is empty, hide the toggle button
if ((secret && match && secret.trim() === match.trim()) || !match) {
if (toggleButton) {
toggleButton.style.display = 'none';
}
}
});
}
// Setup toggle buttons
function setupToggleButtons() {
document.querySelectorAll('.match-toggle').forEach(btn => {
btn.addEventListener('click', function() {
const matchContent = this.nextElementSibling;
if (matchContent.classList.contains('hidden')) {
matchContent.classList.remove('hidden');
this.textContent = 'Hide Context';
} else {
matchContent.classList.add('hidden');
this.textContent = 'Show Context';
}
});
});
// Setup description toggle
document.querySelectorAll('.description-text').forEach(descriptionText => {
const toggleBtn = descriptionText.nextElementSibling;
if (!toggleBtn || !toggleBtn.classList.contains('description-toggle')) return;
// Initial state: collapsed
descriptionText.classList.add('description-collapsed');
toggleBtn.addEventListener('click', () => {
if (descriptionText.classList.contains('description-collapsed')) {
descriptionText.classList.remove('description-collapsed');
descriptionText.classList.add('description-expanded');
toggleBtn.textContent = '↑';
} else {
descriptionText.classList.remove('description-expanded');
descriptionText.classList.add('description-collapsed');
toggleBtn.textContent = '↕';
}
});
});
}
// Initialize dark mode from user preference
function initDarkMode() {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const storedPreference = localStorage.getItem('darkMode');
if (storedPreference === 'true' || (storedPreference === null && prefersDark)) {
document.body.classList.add('dark-mode');
}
}
// Toggle dark mode
document.getElementById('darkModeToggle').addEventListener('click', function() {
document.body.classList.toggle('dark-mode');
localStorage.setItem('darkMode', document.body.classList.contains('dark-mode'));
});
// Filter functionality
function applyFilters() {
const ruleFilter = document.getElementById('filterRule').value;
const fileFilter = document.getElementById('filterFile').value.toLowerCase();
const rows = document.querySelectorAll('#findingsTable tbody tr');
rows.forEach(row => {
const ruleMatch = ruleFilter === 'all' || row.dataset.rule === ruleFilter;
const fileMatch = fileFilter === '' || row.dataset.file.toLowerCase().includes(fileFilter);
if (ruleMatch && fileMatch) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
// Update visible count
const visibleFindings = document.querySelectorAll('#findingsTable tbody tr:not([style*="display: none"])').length;
document.querySelector('.app-footer strong').textContent = visibleFindings;
}
document.getElementById('filterRule').addEventListener('change', applyFilters);
document.getElementById('filterFile').addEventListener('input', applyFilters);
document.getElementById('resetFilters').addEventListener('click', function() {
document.getElementById('filterRule').value = 'all';
document.getElementById('filterFile').value = '';
applyFilters();
});
// Initialize
document.addEventListener('DOMContentLoaded', function() {
processData();
hideRedundantToggleButtons(); // Hide toggle buttons for matching secrets
setupToggleButtons();
initDarkMode();
});
</script>
</body>
</html>
+847
View File
@@ -0,0 +1,847 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gitleaks Security Findings Report</title>
<style>
:root {
--primary-color: #00ff00;
--primary-color-rgb: 0, 255, 0;
--primary-dark: #00cc00;
--primary-light: #66ff66;
--secondary-color: #111111;
--surface-color: #000000;
--border-color: #00ff00;
--text-color: #00ff00;
--text-light: #00cc00;
--text-inverse: #000000;
--error-color: #ff0000;
--warning-color: #ffff00;
--success-color: #00ff00;
--highlight-color: rgba(0, 255, 0, 0.2);
--highlight-secret: rgba(255, 0, 0, 0.2);
--shadow: 0 0 10px rgba(0, 255, 0, 0.8);
--radius: 0;
--font-mono: 'Courier New', monospace;
--font-main: 'Courier New', monospace;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
font-family: var(--font-main);
font-size: 16px;
line-height: 1.5;
color: var(--text-color);
background-color: #000000;
background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h40v40H0V0zm20 10a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm0 5a5 5 0 1 0 0 10 5 5 0 0 0 0-10z' fill='%23003300' fill-opacity='0.5' fill-rule='evenodd'/%3E%3C/svg%3E");
}
.app-container {
display: flex;
flex-direction: column;
height: 100%;
max-width: 100%;
overflow: hidden;
border: 1px solid #00ff00;
box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
position: relative;
}
.app-container::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 5px;
background: repeating-linear-gradient(
90deg,
#00ff00,
#00ff00 10px,
#000000 10px,
#000000 20px
);
z-index: 10;
}
.app-container::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 5px;
background: repeating-linear-gradient(
90deg,
#00ff00,
#00ff00 10px,
#000000 10px,
#000000 20px
);
z-index: 10;
}
.app-header {
background-color: #111111;
border-bottom: 1px solid #00ff00;
height: auto;
padding: 10px 15px;
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
box-shadow: var(--shadow);
z-index: 10;
}
.logo h1 {
font-size: 20px;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 2px;
margin: 0;
padding: 0;
text-shadow: 0 0 5px #00ff00;
}
.logo h1::before {
content: "[ ";
}
.logo h1::after {
content: " ]_";
animation: blink 1s step-end infinite;
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
background-color: #000000;
color: #00ff00;
border: 1px solid #00ff00;
font-family: 'Courier New', monospace;
text-transform: lowercase;
letter-spacing: 1px;
transition: all 0.2s;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
padding: 0.5rem 1rem;
}
.btn::before {
content: "[ ";
}
.btn::after {
content: " ]";
}
.btn:hover {
background-color: #00ff00;
color: #000000;
box-shadow: 0 0 10px #00ff00;
}
.btn-primary {
background-color: #000000;
color: #00ff00;
}
.btn-primary:hover {
background-color: #00ff00;
color: #000000;
}
.btn-sm {
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
}
.app-main {
flex: 1;
overflow: auto;
padding: 1.5rem;
position: relative;
}
.report-info {
background-color: #111111;
border: 1px solid #00ff00;
padding: 15px;
margin-bottom: 20px;
position: relative;
box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}
.report-info h2 {
color: #00ff00;
text-transform: uppercase;
letter-spacing: 1px;
margin-top: 0;
text-shadow: 0 0 5px #00ff00;
}
.report-info h2::before {
content: "//";
margin-right: 10px;
}
.report-date {
color: #00cc00;
font-style: italic;
font-size: 0.875rem;
}
.report-stats {
display: flex;
gap: 1.5rem;
margin-top: 1rem;
flex-wrap: wrap;
}
.stat-item {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.stat-value {
color: #00ff00;
font-weight: bold;
text-shadow: 0 0 5px #00ff00;
font-size: 1.25rem;
}
.stat-label {
text-transform: uppercase;
font-size: 10px;
letter-spacing: 1px;
color: var(--text-light);
}
.table-wrapper {
overflow-x: auto;
border: 1px solid #00ff00;
box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}
.findings-table {
width: 100%;
border-collapse: collapse;
font-size: 0.875rem;
}
.findings-table th {
background-color: #111111;
color: #00ff00;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
padding: 10px;
border: 1px solid #004400;
position: sticky;
top: 0;
z-index: 1;
text-align: left;
}
.findings-table td {
background-color: #000000;
border: 1px solid #004400;
padding: 10px;
font-size: 13px;
vertical-align: top;
max-width: 300px; /* Limit width of all cells */
overflow-wrap: break-word;
}
.findings-table tr:hover td {
background-color: #001100;
}
.findings-table th:nth-child(1) { width: 12%; } /* Rule */
.findings-table th:nth-child(2) { width: 20%; } /* File */
.findings-table th:nth-child(3) { width: 25%; } /* Description */
.findings-table th:nth-child(4) { width: 20%; } /* Secret */
.findings-table th:nth-child(5) { width: 23%; } /* Metadata */
.filters {
background-color: #111111;
padding: 15px;
border: 1px solid #00ff00;
margin-bottom: 20px;
box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.filter-group {
display: flex;
align-items: center;
gap: 0.5rem;
}
.filter-label {
color: #00ff00;
font-weight: bold;
text-transform: uppercase;
font-size: 12px;
letter-spacing: 1px;
}
.filter-input {
background-color: #000000;
border: 1px solid #00ff00;
color: #00ff00;
padding: 8px 10px;
font-family: 'Courier New', monospace;
font-size: 0.875rem;
}
.filter-input:focus {
outline: none;
box-shadow: 0 0 10px #00ff00;
}
.secret-container {
position: relative;
}
.match-toggle {
display: inline-block;
margin-top: 0.5rem;
background-color: #000000;
color: #00ff00;
border: 1px solid #00ff00;
font-family: 'Courier New', monospace;
text-transform: lowercase;
font-size: 11px;
letter-spacing: 1px;
transition: all 0.2s;
cursor: pointer;
padding: 0.25rem 0.5rem;
}
.match-toggle:hover {
background-color: #00ff00;
color: #000000;
}
.hidden {
display: none !important;
}
.secret-match {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: #110000;
border: 1px solid #ff0000;
color: #ff0000;
font-weight: bold;
padding: 8px;
overflow-x: auto;
}
.tag-list {
display: flex;
gap: 0.25rem;
flex-wrap: wrap;
}
.tag {
display: inline-block;
background-color: #001100;
color: #00ff00;
border: 1px solid #00ff00;
text-transform: lowercase;
font-size: 10px;
letter-spacing: 1px;
padding: 2px 5px;
}
.meta-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 0.5rem;
margin-top: 0.5rem;
font-size: 0.75rem;
color: var(--text-light);
}
.meta-item {
display: flex;
align-items: center;
gap: 0.25rem;
}
.meta-label {
font-weight: 500;
}
.meta-value {
font-family: var(--font-mono);
word-break: break-all;
color: #00ffff;
}
.description-toggle {
cursor: pointer;
color: #00ff00;
font-size: 0.875rem;
margin-left: 0.5rem;
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
background-color: #000000;
border: 1px solid #00ff00;
vertical-align: middle;
}
.description-toggle:hover {
background-color: #00ff00;
color: #000000;
}
.description-expanded {
white-space: normal;
}
.description-collapsed {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 250px;
display: inline-block;
}
.commit-link {
color: #00ffff;
text-decoration: underline;
}
.commit-link:hover {
text-decoration: none;
text-shadow: 0 0 5px #00ffff;
}
/* File path styling */
.file-path-container {
max-width: 100%;
}
.file-path {
display: inline-block;
max-width: 100%;
word-wrap: break-word;
word-break: break-all;
}
.match-content {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: #001100;
border: 1px solid #00ff00;
padding: 8px;
color: #00ff00;
margin-top: 0.5rem;
max-height: 300px;
overflow-y: auto;
}
.app-footer {
background-color: #111111;
color: #00ff00;
border-top: 1px solid #00ff00;
padding: 10px 15px;
font-size: 12px;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
}
/* Random binary background */
.app-main::before {
content: "";
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.9);
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='%23003300' fill-opacity='0.1'%3E%3Ctext x='0' y='10' font-family='monospace' font-size='10'%3E01001010111001010101%3C/text%3E%3Ctext x='0' y='20' font-family='monospace' font-size='10'%3E10010111001010101010%3C/text%3E%3Ctext x='0' y='30' font-family='monospace' font-size='10'%3E01011100101010101001%3C/text%3E%3Ctext x='0' y='40' font-family='monospace' font-size='10'%3E10110010101010100101%3C/text%3E%3Ctext x='0' y='50' font-family='monospace' font-size='10'%3E01100101010101001011%3C/text%3E%3Ctext x='0' y='60' font-family='monospace' font-size='10'%3E11001010101010010110%3C/text%3E%3Ctext x='0' y='70' font-family='monospace' font-size='10'%3E10010101010100101100%3C/text%3E%3Ctext x='0' y='80' font-family='monospace' font-size='10'%3E00101010101001011001%3C/text%3E%3Ctext x='0' y='90' font-family='monospace' font-size='10'%3E01010101010010110010%3C/text%3E%3Ctext x='0' y='100' font-family='monospace' font-size='10'%3E10101010100101100101%3C/text%3E%3Ctext x='0' y='110' font-family='monospace' font-size='10'%3E01010101001011001010%3C/text%3E%3Ctext x='0' y='120' font-family='monospace' font-size='10'%3E10101010010110010101%3C/text%3E%3Ctext x='0' y='130' font-family='monospace' font-size='10'%3E01010100101100101010%3C/text%3E%3Ctext x='0' y='140' font-family='monospace' font-size='10'%3E10101001011001010101%3C/text%3E%3Ctext x='0' y='150' font-family='monospace' font-size='10'%3E01010010110010101010%3C/text%3E%3Ctext x='0' y='160' font-family='monospace' font-size='10'%3E10100101100101010101%3C/text%3E%3Ctext x='0' y='170' font-family='monospace' font-size='10'%3E01001011001010101010%3C/text%3E%3Ctext x='0' y='180' font-family='monospace' font-size='10'%3E10010110010101010101%3C/text%3E%3Ctext x='0' y='190' font-family='monospace' font-size='10'%3E00101100101010101010%3C/text%3E%3Ctext x='0' y='200' font-family='monospace' font-size='10'%3E01011001010101010101%3C/text%3E%3C/g%3E%3C/svg%3E");
pointer-events: none;
opacity: 0.3;
z-index: -1;
}
@media (max-width: 768px) {
.app-header {
padding: 8px 10px;
}
.app-main {
padding: 1rem;
}
.report-stats {
flex-direction: column;
gap: 0.75rem;
}
.filters {
flex-direction: column;
gap: 0.75rem;
}
.app-footer {
flex-direction: column;
height: auto;
padding: 0.75rem 1rem;
gap: 0.5rem;
justify-content: center;
text-align: center;
}
}
</style>
</head>
<body>
<div class="app-container">
<header class="app-header">
<div class="logo">
<h1>Gitleaks Security Findings</h1>
</div>
</header>
<main class="app-main">
<div class="report-info">
<h2>Security Scan Report</h2>
<p class="report-date">Generated on {{now | date "Jan 02, 2006 15:04:05 MST"}}</p>
<div class="report-stats">
<div class="stat-item">
<span class="stat-value">{{len .}}</span>
<span class="stat-label">Total Findings</span>
</div>
<div class="stat-item">
<span class="stat-value" id="filesCount">-</span>
<span class="stat-label">Files Affected</span>
</div>
<div class="stat-item">
<span class="stat-value" id="rulesCount">-</span>
<span class="stat-label">Unique Rules Triggered</span>
</div>
<div class="stat-item" id="scanModeContainer">
<span class="stat-value" id="scanMode">-</span>
<span class="stat-label">Scan Mode</span>
</div>
</div>
</div>
<div class="filters">
<div class="filter-group">
<label class="filter-label" for="filterRule">Filter by Rule:</label>
<select class="filter-input" id="filterRule">
<option value="all">All Rules</option>
<!-- Rule options will be populated by JavaScript -->
</select>
</div>
<div class="filter-group">
<label class="filter-label" for="filterFile">Filter by File:</label>
<input type="text" class="filter-input" id="filterFile" placeholder="Enter filename...">
</div>
<div class="filter-group">
<button class="btn btn-primary btn-sm" id="resetFilters">Reset Filters</button>
</div>
</div>
<div class="table-wrapper">
<table class="findings-table" id="findingsTable">
<thead>
<tr>
<th>Rule</th>
<th>File</th>
<th>Description</th>
<th>Secret</th>
<th>Metadata</th>
</tr>
</thead>
<tbody>
{{- range . }}
<tr data-rule="{{.RuleID}}" data-file="{{.File}}">
<td>{{.RuleID}}</td>
<td>
<div class="file-path-container">
<span class="file-path" title="{{.File}}">{{.File}}</span>
</div>
<div class="tag-list">
{{- range .Tags }}
<span class="tag">{{.}}</span>
{{- end}}
</div>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Line:</span>
<span class="meta-value">{{.StartLine}}</span>
</div>
</div>
</td>
<td>
<span class="description-text">{{.Description}}</span>
<span class="description-toggle" title="Expand/Collapse">↕</span>
</td>
<td>
<div class="secret-container" data-secret="{{.Secret}}" data-match="{{.Match}}">
<div class="secret-match">{{.Secret}}</div>
<button type="button" class="match-toggle" title="Show/Hide Full Match Context">Show Context</button>
<div class="match-content hidden" data-raw-match="{{.Match}}">{{.Match}}</div>
</div>
</td>
<td>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Entropy:</span>
<span class="meta-value">{{printf "%.2f" .Entropy}}</span>
</div>
{{- if .Commit}}
<div class="meta-item commit-info">
<span class="meta-label">Commit:</span>
<span class="meta-value">{{if gt (len .Commit) 7}}{{printf "%.7s" .Commit}}{{else}}{{.Commit}}{{end}}</span>
</div>
{{- if .Author}}
<div class="meta-item commit-info">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- if .Date}}
<div class="meta-item commit-info">
<span class="meta-label">Date:</span>
<span class="meta-value">{{.Date}}</span>
</div>
{{- end}}
{{- if .Link}}
<div class="meta-item commit-info">
<span class="meta-label">Link:</span>
<span class="meta-value"><a href="{{.Link}}" target="_blank" class="commit-link">View Commit</a></span>
</div>
{{- end}}
{{- else}}
{{- if .Author}}
<div class="meta-item">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- end}}
</div>
{{- if not .Match}}
<div class="match-content" data-raw-match="">-</div>
{{- end}}
</td>
</tr>
{{- end }}
</tbody>
</table>
</div>
</main>
<footer class="app-footer">
<div>Generated by Gitleaks</div>
<div>Total Findings: <strong>{{len .}}</strong></div>
</footer>
</div>
<script>
// Process data to collect unique files and rules
function processData() {
const rows = document.querySelectorAll('#findingsTable tbody tr');
const uniqueRules = new Set();
const uniqueFiles = new Set();
let isGitMode = false;
if (rows.length > 0) {
// Check if first finding has commit data to determine mode
const firstRow = rows[0];
const commitCells = firstRow.querySelectorAll('.commit-info');
isGitMode = commitCells.length > 0 && commitCells[0].textContent.trim() !== '';
}
// Set scan mode
document.getElementById('scanMode').textContent = isGitMode ? 'Git' : 'Directory';
// Adjust UI based on mode
if (isGitMode) {
// Ensure commit info columns are visible for git mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'block';
});
} else {
// Hide commit-specific UI elements for directory mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'none';
});
}
rows.forEach(row => {
uniqueRules.add(row.dataset.rule);
uniqueFiles.add(row.dataset.file);
});
// Update stats
document.getElementById('filesCount').textContent = uniqueFiles.size;
document.getElementById('rulesCount').textContent = uniqueRules.size;
// Populate rule filter dropdown
const ruleFilter = document.getElementById('filterRule');
const sortedRules = Array.from(uniqueRules).sort();
sortedRules.forEach(rule => {
const option = document.createElement('option');
option.value = rule;
option.textContent = rule;
ruleFilter.appendChild(option);
});
}
// Hide toggle button if match is same as secret
function hideRedundantToggleButtons() {
document.querySelectorAll('.secret-container').forEach(container => {
const secret = container.getAttribute('data-secret');
const match = container.getAttribute('data-match');
const toggleButton = container.querySelector('.match-toggle');
// If secret and match are the same, or if match is empty, hide the toggle button
if ((secret && match && secret.trim() === match.trim()) || !match) {
if (toggleButton) {
toggleButton.style.display = 'none';
}
}
});
}
// Setup toggle buttons
function setupToggleButtons() {
document.querySelectorAll('.match-toggle').forEach(btn => {
btn.addEventListener('click', function() {
const matchContent = this.nextElementSibling;
if (matchContent.classList.contains('hidden')) {
matchContent.classList.remove('hidden');
this.textContent = 'Hide Context';
} else {
matchContent.classList.add('hidden');
this.textContent = 'Show Context';
}
});
});
// Setup description toggle
document.querySelectorAll('.description-text').forEach(descriptionText => {
const toggleBtn = descriptionText.nextElementSibling;
if (!toggleBtn || !toggleBtn.classList.contains('description-toggle')) return;
// Initial state: collapsed
descriptionText.classList.add('description-collapsed');
toggleBtn.addEventListener('click', () => {
if (descriptionText.classList.contains('description-collapsed')) {
descriptionText.classList.remove('description-collapsed');
descriptionText.classList.add('description-expanded');
toggleBtn.textContent = '↑';
} else {
descriptionText.classList.remove('description-expanded');
descriptionText.classList.add('description-collapsed');
toggleBtn.textContent = '↕';
}
});
});
}
// Type effect for headers (optional)
function typeEffect() {
const headers = document.querySelectorAll('h2');
headers.forEach(header => {
const text = header.textContent;
header.textContent = '';
let i = 0;
const interval = setInterval(() => {
if (i < text.length) {
header.textContent += text.charAt(i);
i++;
} else {
clearInterval(interval);
}
}, 50);
});
}
// Filter functionality
function applyFilters() {
const ruleFilter = document.getElementById('filterRule').value;
const fileFilter = document.getElementById('filterFile').value.toLowerCase();
const rows = document.querySelectorAll('#findingsTable tbody tr');
rows.forEach(row => {
const ruleMatch = ruleFilter === 'all' || row.dataset.rule === ruleFilter;
const fileMatch = fileFilter === '' || row.dataset.file.toLowerCase().includes(fileFilter);
if (ruleMatch && fileMatch) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
// Update visible count
const visibleFindings = document.querySelectorAll('#findingsTable tbody tr:not([style*="display: none"])').length;
document.querySelector('.app-footer strong').textContent = visibleFindings;
}
document.getElementById('filterRule').addEventListener('change', applyFilters);
document.getElementById('filterFile').addEventListener('input', applyFilters);
document.getElementById('resetFilters').addEventListener('click', function() {
document.getElementById('filterRule').value = 'all';
document.getElementById('filterFile').value = '';
applyFilters();
});
// Initialize
document.addEventListener('DOMContentLoaded', function() {
processData();
hideRedundantToggleButtons(); // Hide toggle buttons for matching secrets
setupToggleButtons();
typeEffect(); // Add the typing effect
});
</script>
</body>
</html>
+800
View File
@@ -0,0 +1,800 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gitleaks Security Findings Report</title>
<style>
:root {
--primary-color: #ff00ff;
--primary-color-rgb: 255, 0, 255;
--primary-dark: #cc00cc;
--primary-light: #ff66ff;
--secondary-color: #00ffff;
--surface-color: #000000;
--border-color: #00ffff;
--text-color: #ffffff;
--text-light: #00ffff;
--text-inverse: #000000;
--error-color: #ff0000;
--warning-color: #ffff00;
--success-color: #00ff00;
--highlight-color: rgba(0, 255, 255, 0.3);
--highlight-secret: rgba(255, 0, 255, 0.3);
--shadow: 0 0 10px rgba(0, 255, 255, 0.8);
--radius: 0;
--font-mono: 'Courier New', monospace;
--font-main: 'Comic Sans MS', 'Arial', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
font-family: var(--font-main);
font-size: 16px;
line-height: 1.5;
color: var(--text-color);
background-color: #000000;
background-image: url('https://cdnjs.cloudflare.com/ajax/libs/Animated_GIF/1.0.1/src/a_gif_star.gif');
cursor: url('https://cdnjs.cloudflare.com/ajax/libs/Animated_GIF/1.0.1/src/a_gif_pointer.gif'), auto;
}
.app-container {
display: flex;
flex-direction: column;
height: 100%;
max-width: 100%;
overflow: hidden;
border: 3px outset #00ffff;
box-shadow: 0 0 20px rgba(255, 0, 255, 0.5);
}
.app-header {
background: linear-gradient(to right, #ff00ff, #00ffff);
background-size: 200% 100%;
animation: rainbow 3s linear infinite;
text-shadow: 0 0 5px #ffffff;
height: auto;
padding: 10px 15px;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
box-shadow: var(--shadow);
z-index: 10;
color: var(--text-inverse);
}
.logo h1 {
animation: blink 1s step-end infinite;
font-family: 'Comic Sans MS', cursive, sans-serif;
font-size: 24px;
font-weight: bold;
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
background: linear-gradient(to bottom, #ff00ff, #00ffff);
border: 3px outset #00ffff;
text-shadow: 0 0 5px #000000;
font-weight: bold;
animation: pulse 2s infinite;
font-size: 0.875rem;
font-weight: 600;
cursor: pointer;
padding: 0.5rem 1rem;
transition: all 0.2s;
border-radius: var(--radius);
font-family: var(--font-main);
}
.btn:hover {
transform: scale(1.1);
box-shadow: 0 0 15px rgba(255, 0, 255, 0.8);
}
.btn-primary {
background: linear-gradient(to bottom, #ff00ff, #00ffff);
color: white;
}
.btn-sm {
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
}
.app-main {
flex: 1;
overflow: auto;
padding: 1.5rem;
}
.report-info {
background-image: url('https://cdnjs.cloudflare.com/ajax/libs/Animated_GIF/1.0.1/src/a_gif_sparkle.gif');
background-color: rgba(0, 0, 0, 0.7);
border: 2px solid #00ffff;
box-shadow: 0 0 10px #ff00ff;
margin-bottom: 1.5rem;
padding: 1rem;
border-radius: var(--radius);
}
.report-info h2 {
color: #ffffff;
text-shadow: 0 0 5px #ff00ff;
font-family: 'Comic Sans MS', cursive, sans-serif;
}
.report-date {
font-size: 0.875rem;
color: #00ffff;
font-style: italic;
}
.report-stats {
display: flex;
gap: 1.5rem;
margin-top: 1rem;
flex-wrap: wrap;
}
.stat-item {
display: flex;
flex-direction: column;
gap: 0.25rem;
background-color: rgba(0, 0, 0, 0.6);
padding: 10px;
border: 1px solid #00ffff;
border-radius: 5px;
}
.stat-value {
color: #ff00ff;
text-shadow: 0 0 5px #00ffff;
font-size: 1.5rem;
font-weight: 600;
}
.stat-label {
font-size: 0.875rem;
color: var(--text-light);
text-transform: uppercase;
}
.table-wrapper {
overflow-x: auto;
border: 2px solid #00ffff;
border-radius: var(--radius);
box-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}
.findings-table {
width: 100%;
border-collapse: collapse;
font-size: 0.875rem;
}
.findings-table th {
background: linear-gradient(to bottom, #ff00ff, #9900cc);
color: white;
text-shadow: 0 0 5px black;
border: 1px solid #00ffff;
padding: 0.75rem;
text-align: left;
font-weight: 500;
position: sticky;
top: 0;
z-index: 1;
}
.findings-table td {
border: 1px solid #00ffff;
background-color: rgba(0, 0, 0, 0.7);
padding: 0.75rem;
vertical-align: top;
max-width: 300px; /* Limit width of all cells */
overflow-wrap: break-word;
}
.findings-table tr:hover td {
background-color: rgba(255, 0, 255, 0.3);
}
.findings-table th:nth-child(1) { width: 12%; } /* Rule */
.findings-table th:nth-child(2) { width: 20%; } /* File */
.findings-table th:nth-child(3) { width: 25%; } /* Description */
.findings-table th:nth-child(4) { width: 20%; } /* Secret */
.findings-table th:nth-child(5) { width: 23%; } /* Metadata */
.secret-container {
position: relative;
}
.match-toggle {
display: inline-block;
margin-top: 0.5rem;
background-color: #000000;
color: #00ffff;
border: 1px solid #ff00ff;
font-size: 0.75rem;
cursor: pointer;
padding: 0.25rem 0.5rem;
border-radius: var(--radius);
animation: pulse 2s infinite;
}
.match-toggle:hover {
background-color: #ff00ff;
color: #000000;
}
.hidden {
display: none !important;
}
.secret-match {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: rgba(255, 0, 255, 0.3);
border: 1px dashed #00ffff;
padding: 0.5rem;
border-radius: var(--radius);
overflow-x: auto;
}
.tag-list {
display: flex;
gap: 0.25rem;
flex-wrap: wrap;
}
.tag {
display: inline-block;
padding: 0.125rem 0.375rem;
background-color: #ff00ff;
color: white;
border-radius: 2px;
font-size: 0.75rem;
animation: pulse 2s infinite;
}
.meta-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 0.5rem;
margin-top: 0.5rem;
font-size: 0.75rem;
color: var(--text-light);
}
.meta-item {
display: flex;
align-items: center;
gap: 0.25rem;
}
.meta-label {
font-weight: 500;
color: #00ffff;
}
.meta-value {
font-family: var(--font-mono);
word-break: break-all;
color: #ffffff;
}
.filters {
background-color: rgba(0, 0, 0, 0.7);
padding: 15px;
border: 2px solid #00ffff;
margin-bottom: 20px;
box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.filter-group {
display: flex;
align-items: center;
gap: 0.5rem;
}
.filter-label {
font-size: 0.875rem;
font-weight: 600;
color: #ff00ff;
text-shadow: 0 0 3px #00ffff;
}
.filter-input {
background-color: black;
color: #00ffff;
border: 1px solid #ff00ff;
padding: 0.375rem 0.75rem;
border-radius: var(--radius);
font-size: 0.875rem;
font-family: var(--font-main);
}
.filter-input:focus {
outline: none;
box-shadow: 0 0 10px #ff00ff;
}
.app-footer {
background: linear-gradient(to right, #00ffff, #ff00ff);
background-size: 200% 100%;
animation: rainbow 3s linear infinite reverse;
color: #000000;
font-weight: bold;
text-shadow: 0 0 2px #ffffff;
padding: 0 1.5rem;
height: auto;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 3px ridge #00ffff;
font-size: 0.75rem;
flex-shrink: 0;
padding: 10px 15px;
}
.description-toggle {
cursor: pointer;
color: #ff00ff;
font-size: 0.875rem;
margin-left: 0.5rem;
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.7);
vertical-align: middle;
animation: pulse 2s infinite;
border: 1px solid #00ffff;
}
.description-toggle:hover {
background-color: #ff00ff;
color: #000000;
}
.description-expanded {
white-space: normal;
}
.description-collapsed {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 250px;
display: inline-block;
}
.commit-link {
color: #ff00ff;
text-decoration: underline;
text-shadow: 0 0 2px #00ffff;
}
.commit-link:hover {
color: #00ffff;
text-decoration: none;
}
/* File path styling */
.file-path-container {
max-width: 100%;
}
.file-path {
display: inline-block;
max-width: 100%;
word-wrap: break-word;
word-break: break-all;
color: #ffffff;
}
.match-content {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: rgba(0, 0, 0, 0.8);
border: 1px solid #ff00ff;
padding: 0.5rem;
border-radius: var(--radius);
margin-top: 0.5rem;
max-height: 300px;
overflow-y: auto;
}
/* Add sparkles and starry effects to the page */
.app-main::before {
content: "";
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: none;
background-image: url('https://cdnjs.cloudflare.com/ajax/libs/Animated_GIF/1.0.1/src/a_gif_sparkle.gif');
opacity: 0.2;
z-index: 999;
}
@keyframes rainbow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
@keyframes blink {
0% { opacity: 1; }
50% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
@media (max-width: 768px) {
.app-header {
padding: 0 1rem;
}
.app-main {
padding: 1rem;
}
.report-stats {
flex-direction: column;
gap: 0.75rem;
}
.filters {
flex-direction: column;
gap: 0.75rem;
}
.app-footer {
flex-direction: column;
height: auto;
padding: 0.75rem 1rem;
gap: 0.5rem;
justify-content: center;
text-align: center;
}
}
</style>
</head>
<body>
<div class="app-container">
<header class="app-header">
<div class="logo">
<h1>Gitleaks Security Findings</h1>
</div>
</header>
<main class="app-main">
<div class="report-info">
<h2>Security Scan Report</h2>
<p class="report-date">Generated on {{now | date "Jan 02, 2006 15:04:05 MST"}}</p>
<div class="report-stats">
<div class="stat-item">
<span class="stat-value">{{len .}}</span>
<span class="stat-label">Total Findings</span>
</div>
<div class="stat-item">
<span class="stat-value" id="filesCount">-</span>
<span class="stat-label">Files Affected</span>
</div>
<div class="stat-item">
<span class="stat-value" id="rulesCount">-</span>
<span class="stat-label">Unique Rules Triggered</span>
</div>
<div class="stat-item" id="scanModeContainer">
<span class="stat-value" id="scanMode">-</span>
<span class="stat-label">Scan Mode</span>
</div>
</div>
</div>
<div class="filters">
<div class="filter-group">
<label class="filter-label" for="filterRule">Filter by Rule:</label>
<select class="filter-input" id="filterRule">
<option value="all">All Rules</option>
<!-- Rule options will be populated by JavaScript -->
</select>
</div>
<div class="filter-group">
<label class="filter-label" for="filterFile">Filter by File:</label>
<input type="text" class="filter-input" id="filterFile" placeholder="Enter filename...">
</div>
<div class="filter-group">
<button class="btn btn-primary btn-sm" id="resetFilters">Reset Filters</button>
</div>
</div>
<div class="table-wrapper">
<table class="findings-table" id="findingsTable">
<thead>
<tr>
<th>Rule</th>
<th>File</th>
<th>Description</th>
<th>Secret</th>
<th>Metadata</th>
</tr>
</thead>
<tbody>
{{- range . }}
<tr data-rule="{{.RuleID}}" data-file="{{.File}}">
<td>{{.RuleID}}</td>
<td>
<div class="file-path-container">
<span class="file-path" title="{{.File}}">{{.File}}</span>
</div>
<div class="tag-list">
{{- range .Tags }}
<span class="tag">{{.}}</span>
{{- end}}
</div>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Line:</span>
<span class="meta-value">{{.StartLine}}</span>
</div>
</div>
</td>
<td>
<span class="description-text">{{.Description}}</span>
<span class="description-toggle" title="Expand/Collapse">↕</span>
</td>
<td>
<div class="secret-container" data-secret="{{.Secret}}" data-match="{{.Match}}">
<div class="secret-match">{{.Secret}}</div>
<button type="button" class="match-toggle" title="Show/Hide Full Match Context">Show Context</button>
<div class="match-content hidden" data-raw-match="{{.Match}}">{{.Match}}</div>
</div>
</td>
<td>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Entropy:</span>
<span class="meta-value">{{printf "%.2f" .Entropy}}</span>
</div>
{{- if .Commit}}
<div class="meta-item commit-info">
<span class="meta-label">Commit:</span>
<span class="meta-value">{{if gt (len .Commit) 7}}{{printf "%.7s" .Commit}}{{else}}{{.Commit}}{{end}}</span>
</div>
{{- if .Author}}
<div class="meta-item commit-info">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- if .Date}}
<div class="meta-item commit-info">
<span class="meta-label">Date:</span>
<span class="meta-value">{{.Date}}</span>
</div>
{{- end}}
{{- if .Link}}
<div class="meta-item commit-info">
<span class="meta-label">Link:</span>
<span class="meta-value"><a href="{{.Link}}" target="_blank" class="commit-link">View Commit</a></span>
</div>
{{- end}}
{{- else}}
{{- if .Author}}
<div class="meta-item">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- end}}
</div>
{{- if not .Match}}
<div class="match-content" data-raw-match="">-</div>
{{- end}}
</td>
</tr>
{{- end }}
</tbody>
</table>
</div>
</main>
<footer class="app-footer">
<div>Generated by Gitleaks</div>
<div>Total Findings: <strong>{{len .}}</strong></div>
</footer>
</div>
<script>
// Process data to collect unique files and rules
function processData() {
const rows = document.querySelectorAll('#findingsTable tbody tr');
const uniqueRules = new Set();
const uniqueFiles = new Set();
let isGitMode = false;
if (rows.length > 0) {
// Check if first finding has commit data to determine mode
const firstRow = rows[0];
const commitCells = firstRow.querySelectorAll('.commit-info');
isGitMode = commitCells.length > 0 && commitCells[0].textContent.trim() !== '';
}
// Set scan mode
document.getElementById('scanMode').textContent = isGitMode ? 'Git' : 'Directory';
// Adjust UI based on mode
if (isGitMode) {
// Ensure commit info columns are visible for git mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'block';
});
} else {
// Hide commit-specific UI elements for directory mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'none';
});
}
rows.forEach(row => {
uniqueRules.add(row.dataset.rule);
uniqueFiles.add(row.dataset.file);
});
// Update stats
document.getElementById('filesCount').textContent = uniqueFiles.size;
document.getElementById('rulesCount').textContent = uniqueRules.size;
// Populate rule filter dropdown
const ruleFilter = document.getElementById('filterRule');
const sortedRules = Array.from(uniqueRules).sort();
sortedRules.forEach(rule => {
const option = document.createElement('option');
option.value = rule;
option.textContent = rule;
ruleFilter.appendChild(option);
});
}
// Hide toggle button if match is same as secret
function hideRedundantToggleButtons() {
document.querySelectorAll('.secret-container').forEach(container => {
const secret = container.getAttribute('data-secret');
const match = container.getAttribute('data-match');
const toggleButton = container.querySelector('.match-toggle');
// If secret and match are the same, or if match is empty, hide the toggle button
if ((secret && match && secret.trim() === match.trim()) || !match) {
if (toggleButton) {
toggleButton.style.display = 'none';
}
}
});
}
// Setup toggle buttons
function setupToggleButtons() {
document.querySelectorAll('.match-toggle').forEach(btn => {
btn.addEventListener('click', function() {
const matchContent = this.nextElementSibling;
if (matchContent.classList.contains('hidden')) {
matchContent.classList.remove('hidden');
this.textContent = 'Hide Context';
} else {
matchContent.classList.add('hidden');
this.textContent = 'Show Context';
}
});
});
// Setup description toggle
document.querySelectorAll('.description-text').forEach(descriptionText => {
const toggleBtn = descriptionText.nextElementSibling;
if (!toggleBtn || !toggleBtn.classList.contains('description-toggle')) return;
// Initial state: collapsed
descriptionText.classList.add('description-collapsed');
toggleBtn.addEventListener('click', () => {
if (descriptionText.classList.contains('description-collapsed')) {
descriptionText.classList.remove('description-collapsed');
descriptionText.classList.add('description-expanded');
toggleBtn.textContent = '↑';
} else {
descriptionText.classList.remove('description-expanded');
descriptionText.classList.add('description-collapsed');
toggleBtn.textContent = '↕';
}
});
});
}
// Add some MySpace-style effects
function addMySpaceEffects() {
// Maybe add some sparkle effects to the header on load
const header = document.querySelector('.app-header');
for (let i = 0; i < 5; i++) {
setTimeout(() => {
header.style.boxShadow = '0 0 20px #ff00ff';
setTimeout(() => {
header.style.boxShadow = '0 0 10px #00ffff';
}, 100);
}, i * 200);
}
}
// Filter functionality
function applyFilters() {
const ruleFilter = document.getElementById('filterRule').value;
const fileFilter = document.getElementById('filterFile').value.toLowerCase();
const rows = document.querySelectorAll('#findingsTable tbody tr');
rows.forEach(row => {
const ruleMatch = ruleFilter === 'all' || row.dataset.rule === ruleFilter;
const fileMatch = fileFilter === '' || row.dataset.file.toLowerCase().includes(fileFilter);
if (ruleMatch && fileMatch) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
// Update visible count
const visibleFindings = document.querySelectorAll('#findingsTable tbody tr:not([style*="display: none"])').length;
document.querySelector('.app-footer strong').textContent = visibleFindings;
}
document.getElementById('filterRule').addEventListener('change', applyFilters);
document.getElementById('filterFile').addEventListener('input', applyFilters);
document.getElementById('resetFilters').addEventListener('click', function() {
document.getElementById('filterRule').value = 'all';
document.getElementById('filterFile').value = '';
applyFilters();
});
// Initialize
document.addEventListener('DOMContentLoaded', function() {
processData();
hideRedundantToggleButtons(); // Hide toggle buttons for matching secrets
setupToggleButtons();
addMySpaceEffects(); // Add some fun MySpace-style effects
});
</script>
</body>
</html>
+723
View File
@@ -0,0 +1,723 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gitleaks Security Findings Report</title>
<style>
:root {
--primary-color: #000080;
--primary-color-rgb: 0, 0, 128;
--primary-dark: #000066;
--primary-light: #0000aa;
--secondary-color: #c0c0c0;
--surface-color: #c0c0c0;
--border-color: #808080;
--text-color: #000000;
--text-light: #404040;
--text-inverse: #ffffff;
--error-color: #ff0000;
--warning-color: #ffaa00;
--success-color: #008000;
--highlight-color: rgba(0, 0, 128, 0.2);
--highlight-secret: rgba(255, 0, 0, 0.2);
--shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
--radius: 0;
--font-mono: 'Courier New', monospace;
--font-main: 'MS Sans Serif', 'Tahoma', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
font-family: var(--font-main);
font-size: 16px;
line-height: 1.5;
color: var(--text-color);
background-color: #008080;
background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h40v40H0V0zm20 10a10 10 0 1 1 0 20 10 10 0 0 1 0-20z' fill='%23009090' fill-opacity='0.2' fill-rule='evenodd'/%3E%3C/svg%3E");
}
.app-container {
display: flex;
flex-direction: column;
height: 100%;
max-width: 100%;
overflow: hidden;
border: 2px outset #d4d0c8;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
}
.app-header {
height: 28px;
background: linear-gradient(to right, #000080, #1084d0);
color: var(--text-inverse);
display: flex;
align-items: center;
justify-content: space-between;
padding: 1px 2px;
flex-shrink: 0;
box-shadow: var(--shadow);
z-index: 10;
border-bottom: 2px outset #ffffff;
}
.logo h1 {
font-size: 14px;
font-weight: bold;
margin: 0;
padding: 4px 2px;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
background-color: #c0c0c0;
color: #000000;
border: 2px outset #d4d0c8;
border-radius: 0;
font-size: 12px;
padding: 3px 6px;
box-shadow: 1px 1px 0 #ffffff inset, -1px -1px 0 #808080 inset;
cursor: pointer;
transition: background-color 0.2s, color 0.2s;
font-family: var(--font-main);
}
.btn:active {
border: 2px inset #d4d0c8;
box-shadow: 1px 1px 0 #808080 inset, -1px -1px 0 #ffffff inset;
padding: 4px 5px 2px 7px;
}
.btn-primary {
background-color: var(--primary-color);
color: var(--text-inverse);
}
.btn-primary:hover {
background-color: var(--primary-dark);
}
.btn-sm {
padding: 1px 3px;
font-size: 0.75rem;
}
.app-main {
flex: 1;
overflow: auto;
padding: 1.5rem;
}
.report-info {
margin-bottom: 1.5rem;
padding: 8px;
background-color: #c0c0c0;
border: 2px inset #d4d0c8;
}
.report-date {
font-size: 0.875rem;
color: var(--text-light);
}
.report-stats {
display: flex;
gap: 1.5rem;
margin-top: 1rem;
flex-wrap: wrap;
}
.stat-item {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.stat-value {
font-size: 1.25rem;
font-weight: 600;
}
.stat-label {
font-size: 0.875rem;
color: var(--text-light);
}
.table-wrapper {
overflow-x: auto;
border: 2px inset #d4d0c8;
}
.findings-table {
width: 100%;
border-collapse: collapse;
font-size: 0.875rem;
}
.findings-table th {
background-color: #000080;
color: white;
font-weight: bold;
font-size: 12px;
padding: 4px 6px;
border: 1px solid #808080;
position: sticky;
top: 0;
z-index: 1;
}
/* Ensure table cells don't expand too much */
.findings-table td {
background-color: #ffffff;
border: 1px solid #d4d0c8;
font-size: 12px;
padding: 4px 6px;
vertical-align: top;
max-width: 300px; /* Limit width of all cells */
overflow-wrap: break-word;
}
.findings-table tr:hover td {
background-color: #e6e6e6;
}
.findings-table th:nth-child(1) { width: 12%; } /* Rule */
.findings-table th:nth-child(2) { width: 20%; } /* File */
.findings-table th:nth-child(3) { width: 25%; } /* Description */
.findings-table th:nth-child(4) { width: 20%; } /* Secret */
.findings-table th:nth-child(5) { width: 23%; } /* Metadata */
.secret-container {
position: relative;
}
.match-toggle {
display: inline-block;
margin-top: 0.5rem;
background-color: #c0c0c0;
border: 2px outset #d4d0c8;
color: #000000;
font-size: 10px;
padding: 1px 3px;
cursor: pointer;
}
.match-toggle:active {
border: 2px inset #d4d0c8;
}
.hidden {
display: none !important;
}
.secret-match {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: #ffffff;
border: 1px solid #808080;
padding: 0.5rem;
overflow-x: auto;
}
.tag-list {
display: flex;
gap: 0.25rem;
flex-wrap: wrap;
}
.tag {
display: inline-block;
background-color: #000080;
border-radius: 0;
padding: 1px 3px;
font-size: 10px;
color: var(--text-inverse);
}
.meta-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 0.5rem;
margin-top: 0.5rem;
font-size: 0.75rem;
color: var(--text-light);
}
.meta-item {
display: flex;
align-items: center;
gap: 0.25rem;
}
.meta-label {
font-weight: 500;
}
.meta-value {
font-family: var(--font-mono);
word-break: break-all;
}
.code-preview {
position: relative;
font-family: var(--font-mono);
font-size: 0.875rem;
background-color: #ffffff;
padding: 0.5rem;
border: 1px solid #808080;
overflow-x: auto;
margin-top: 0.5rem;
white-space: pre-wrap;
word-break: break-all;
}
.filters {
margin-bottom: 12px;
background-color: #c0c0c0;
padding: 8px;
border: 2px outset #d4d0c8;
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.filter-group {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 4px;
}
.filter-label {
font-size: 12px;
font-weight: normal;
}
.filter-input {
background-color: #ffffff;
border: 2px inset #d4d0c8;
padding: 3px 4px;
font-size: 12px;
font-family: var(--font-main);
}
.app-footer {
background-color: #c0c0c0;
border-top: 2px outset #d4d0c8;
font-size: 11px;
padding: 3px 8px;
height: 24px;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
}
.description-toggle {
cursor: pointer;
color: var(--primary-color);
font-size: 0.875rem;
margin-left: 0.5rem;
display: inline-flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
background-color: #c0c0c0;
border: 1px outset #d4d0c8;
font-size: 10px;
line-height: 14px;
vertical-align: middle;
}
.description-toggle:hover {
background-color: var(--primary-light);
color: var(--text-inverse);
}
.description-expanded {
white-space: normal;
}
.description-collapsed {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 250px;
display: inline-block;
}
.commit-link {
color: var(--primary-color);
text-decoration: none;
}
.commit-link:hover {
text-decoration: underline;
}
/* File path styling */
.file-path-container {
max-width: 100%;
}
.file-path {
display: inline-block;
max-width: 100%;
word-wrap: break-word;
word-break: break-all;
}
.match-content {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: #ffffff;
border: 1px solid #808080;
padding: 0.5rem;
margin-top: 0.5rem;
max-height: 300px;
overflow-y: auto;
}
@media (max-width: 768px) {
.app-header {
padding: 0 1rem;
}
.app-main {
padding: 1rem;
}
.report-stats {
flex-direction: column;
gap: 0.75rem;
}
.filters {
flex-direction: column;
gap: 0.75rem;
}
.app-footer {
flex-direction: column;
height: auto;
padding: 0.75rem 1rem;
gap: 0.5rem;
justify-content: center;
text-align: center;
}
}
</style>
</head>
<body>
<div class="app-container">
<header class="app-header">
<div class="logo">
<h1>Gitleaks Security Findings</h1>
</div>
</header>
<main class="app-main">
<div class="report-info">
<h2>Security Scan Report</h2>
<p class="report-date">Generated on {{now | date "Jan 02, 2006 15:04:05 MST"}}</p>
<div class="report-stats">
<div class="stat-item">
<span class="stat-value">{{len .}}</span>
<span class="stat-label">Total Findings</span>
</div>
<div class="stat-item">
<span class="stat-value" id="filesCount">-</span>
<span class="stat-label">Files Affected</span>
</div>
<div class="stat-item">
<span class="stat-value" id="rulesCount">-</span>
<span class="stat-label">Unique Rules Triggered</span>
</div>
<div class="stat-item" id="scanModeContainer">
<span class="stat-value" id="scanMode">-</span>
<span class="stat-label">Scan Mode</span>
</div>
</div>
</div>
<div class="filters">
<div class="filter-group">
<label class="filter-label" for="filterRule">Filter by Rule:</label>
<select class="filter-input" id="filterRule">
<option value="all">All Rules</option>
<!-- Rule options will be populated by JavaScript -->
</select>
</div>
<div class="filter-group">
<label class="filter-label" for="filterFile">Filter by File:</label>
<input type="text" class="filter-input" id="filterFile" placeholder="Enter filename...">
</div>
<div class="filter-group">
<button class="btn btn-primary btn-sm" id="resetFilters">Reset Filters</button>
</div>
</div>
<div class="table-wrapper">
<table class="findings-table" id="findingsTable">
<thead>
<tr>
<th>Rule</th>
<th>File</th>
<th>Description</th>
<th>Secret</th>
<th>Metadata</th>
</tr>
</thead>
<tbody>
{{- range . }}
<tr data-rule="{{.RuleID}}" data-file="{{.File}}">
<td>{{.RuleID}}</td>
<td>
<div class="file-path-container">
<span class="file-path" title="{{.File}}">{{.File}}</span>
</div>
<div class="tag-list">
{{- range .Tags }}
<span class="tag">{{.}}</span>
{{- end}}
</div>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Line:</span>
<span class="meta-value">{{.StartLine}}</span>
</div>
</div>
</td>
<td>
<span class="description-text">{{.Description}}</span>
<span class="description-toggle" title="Expand/Collapse">↕</span>
</td>
<td>
<div class="secret-container" data-secret="{{.Secret}}" data-match="{{.Match}}">
<div class="secret-match">{{.Secret}}</div>
<button type="button" class="match-toggle" title="Show/Hide Full Match Context">Show Context</button>
<div class="match-content hidden" data-raw-match="{{.Match}}">{{.Match}}</div>
</div>
</td>
<td>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Entropy:</span>
<span class="meta-value">{{printf "%.2f" .Entropy}}</span>
</div>
{{- if .Commit}}
<div class="meta-item commit-info">
<span class="meta-label">Commit:</span>
<span class="meta-value">{{if gt (len .Commit) 7}}{{printf "%.7s" .Commit}}{{else}}{{.Commit}}{{end}}</span>
</div>
{{- if .Author}}
<div class="meta-item commit-info">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- if .Date}}
<div class="meta-item commit-info">
<span class="meta-label">Date:</span>
<span class="meta-value">{{.Date}}</span>
</div>
{{- end}}
{{- if .Link}}
<div class="meta-item commit-info">
<span class="meta-label">Link:</span>
<span class="meta-value"><a href="{{.Link}}" target="_blank" class="commit-link">View Commit</a></span>
</div>
{{- end}}
{{- else}}
{{- if .Author}}
<div class="meta-item">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- end}}
</div>
{{- if not .Match}}
<div class="match-content" data-raw-match="">-</div>
{{- end}}
</td>
</tr>
{{- end }}
</tbody>
</table>
</div>
</main>
<footer class="app-footer">
<div>Generated by Gitleaks</div>
<div>Total Findings: <strong>{{len .}}</strong></div>
</footer>
</div>
<script>
// Process data to collect unique files and rules
function processData() {
const rows = document.querySelectorAll('#findingsTable tbody tr');
const uniqueRules = new Set();
const uniqueFiles = new Set();
let isGitMode = false;
if (rows.length > 0) {
// Check if first finding has commit data to determine mode
const firstRow = rows[0];
const commitCells = firstRow.querySelectorAll('.commit-info');
isGitMode = commitCells.length > 0 && commitCells[0].textContent.trim() !== '';
}
// Set scan mode
document.getElementById('scanMode').textContent = isGitMode ? 'Git' : 'Directory';
// Adjust UI based on mode
if (isGitMode) {
// Ensure commit info columns are visible for git mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'block';
});
} else {
// Hide commit-specific UI elements for directory mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'none';
});
}
rows.forEach(row => {
uniqueRules.add(row.dataset.rule);
uniqueFiles.add(row.dataset.file);
});
// Update stats
document.getElementById('filesCount').textContent = uniqueFiles.size;
document.getElementById('rulesCount').textContent = uniqueRules.size;
// Populate rule filter dropdown
const ruleFilter = document.getElementById('filterRule');
const sortedRules = Array.from(uniqueRules).sort();
sortedRules.forEach(rule => {
const option = document.createElement('option');
option.value = rule;
option.textContent = rule;
ruleFilter.appendChild(option);
});
}
// Hide toggle button if match is same as secret
function hideRedundantToggleButtons() {
document.querySelectorAll('.secret-container').forEach(container => {
const secret = container.getAttribute('data-secret');
const match = container.getAttribute('data-match');
const toggleButton = container.querySelector('.match-toggle');
// If secret and match are the same, or if match is empty, hide the toggle button
if ((secret && match && secret.trim() === match.trim()) || !match) {
if (toggleButton) {
toggleButton.style.display = 'none';
}
}
});
}
// Setup toggle buttons
function setupToggleButtons() {
document.querySelectorAll('.match-toggle').forEach(btn => {
btn.addEventListener('click', function() {
const matchContent = this.nextElementSibling;
if (matchContent.classList.contains('hidden')) {
matchContent.classList.remove('hidden');
this.textContent = 'Hide Context';
} else {
matchContent.classList.add('hidden');
this.textContent = 'Show Context';
}
});
});
// Setup description toggle
document.querySelectorAll('.description-text').forEach(descriptionText => {
const toggleBtn = descriptionText.nextElementSibling;
if (!toggleBtn || !toggleBtn.classList.contains('description-toggle')) return;
// Initial state: collapsed
descriptionText.classList.add('description-collapsed');
toggleBtn.addEventListener('click', () => {
if (descriptionText.classList.contains('description-collapsed')) {
descriptionText.classList.remove('description-collapsed');
descriptionText.classList.add('description-expanded');
toggleBtn.textContent = '↑';
} else {
descriptionText.classList.remove('description-expanded');
descriptionText.classList.add('description-collapsed');
toggleBtn.textContent = '↕';
}
});
});
}
// Filter functionality
function applyFilters() {
const ruleFilter = document.getElementById('filterRule').value;
const fileFilter = document.getElementById('filterFile').value.toLowerCase();
const rows = document.querySelectorAll('#findingsTable tbody tr');
rows.forEach(row => {
const ruleMatch = ruleFilter === 'all' || row.dataset.rule === ruleFilter;
const fileMatch = fileFilter === '' || row.dataset.file.toLowerCase().includes(fileFilter);
if (ruleMatch && fileMatch) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
// Update visible count
const visibleFindings = document.querySelectorAll('#findingsTable tbody tr:not([style*="display: none"])').length;
document.querySelector('.app-footer strong').textContent = visibleFindings;
}
document.getElementById('filterRule').addEventListener('change', applyFilters);
document.getElementById('filterFile').addEventListener('input', applyFilters);
document.getElementById('resetFilters').addEventListener('click', function() {
document.getElementById('filterRule').value = 'all';
document.getElementById('filterFile').value = '';
applyFilters();
});
// Initialize
document.addEventListener('DOMContentLoaded', function() {
processData();
hideRedundantToggleButtons(); // Hide toggle buttons for matching secrets
setupToggleButtons();
});
</script>
</body>
</html>
+760
View File
@@ -0,0 +1,760 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gitleaks Security Findings Report</title>
<style>
:root {
--primary-color: #2c5fb2;
--primary-color-rgb: 44, 95, 178;
--primary-dark: #224486;
--primary-light: #356bc9;
--secondary-color: #eef3ff;
--surface-color: #ffffff;
--border-color: #7da2ce;
--text-color: #000000;
--text-light: #3a6ea5;
--text-inverse: #ffffff;
--error-color: #cc0000;
--warning-color: #ffaa00;
--success-color: #50c878;
--highlight-color: rgba(44, 95, 178, 0.2);
--highlight-secret: rgba(204, 0, 0, 0.2);
--shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
--radius: 8px;
--font-mono: 'Lucida Console', monospace;
--font-main: 'Tahoma', 'Segoe UI', sans-serif;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
height: 100%;
font-family: var(--font-main);
font-size: 16px;
line-height: 1.5;
color: var(--text-color);
background-color: var(--surface-color);
background: linear-gradient(to bottom, #a1c8e9, #2573d1);
background-attachment: fixed;
}
.app-container {
display: flex;
flex-direction: column;
height: 100%;
max-width: 100%;
overflow: hidden;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
border: 1px solid #7da2ce;
}
.app-header {
height: 36px;
background: linear-gradient(to bottom, #3689de, #2c5fb2, #2151a3);
color: var(--text-inverse);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 12px;
flex-shrink: 0;
box-shadow: var(--shadow);
z-index: 10;
border-bottom: 1px solid #1a3c71;
}
.logo h1 {
font-size: 16px;
font-weight: bold;
margin: 0;
padding: 0;
text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
background: linear-gradient(to bottom, #f1f8fe, #d8e6f6);
color: #000000;
border: 1px solid #7da2ce;
border-radius: 3px;
font-size: 12px;
padding: 4px 8px;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
cursor: pointer;
transition: background-color 0.2s, color 0.2s;
font-family: var(--font-main);
}
.btn:hover {
background: linear-gradient(to bottom, #e5f1fd, #c7ddfa);
}
.btn:active {
background: linear-gradient(to bottom, #c7ddfa, #e5f1fd);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) inset;
}
.btn-primary {
background: linear-gradient(to bottom, #3689de, #2c5fb2);
color: white;
border: 1px solid #1a3c71;
}
.btn-primary:hover {
background: linear-gradient(to bottom, #4397e9, #3670c3);
}
.btn-primary:active {
background: linear-gradient(to bottom, #2151a3, #3689de);
}
.btn-sm {
padding: 2px 5px;
font-size: 0.75rem;
}
.app-main {
flex: 1;
overflow: auto;
padding: 1.5rem;
}
.report-info {
background-color: #eef3ff;
border: 1px solid #7da2ce;
border-radius: 5px;
padding: 12px;
margin-bottom: 15px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.report-info h2 {
color: #2c5fb2;
margin-top: 0;
font-size: 18px;
}
.report-date {
color: #3a6ea5;
font-size: 12px;
}
.report-stats {
display: flex;
gap: 1.5rem;
margin-top: 1rem;
flex-wrap: wrap;
}
.stat-item {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.stat-value {
font-size: 1.25rem;
font-weight: 600;
color: #2c5fb2;
}
.stat-label {
font-size: 0.875rem;
color: var(--text-light);
}
.table-wrapper {
overflow-x: auto;
border: 1px solid #7da2ce;
border-radius: 5px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.findings-table {
width: 100%;
border-collapse: collapse;
font-size: 0.875rem;
}
.findings-table th {
background: linear-gradient(to bottom, #e5f1fd, #c7ddfa);
color: #2c5fb2;
font-weight: bold;
font-size: 13px;
padding: 8px;
border: 1px solid #7da2ce;
text-align: left;
position: sticky;
top: 0;
z-index: 1;
}
/* Ensure table cells don't expand too much */
.findings-table td {
background-color: #ffffff;
border: 1px solid #d9e6f7;
font-size: 12px;
padding: 8px;
vertical-align: top;
max-width: 300px; /* Limit width of all cells */
overflow-wrap: break-word;
}
.findings-table tr:nth-child(even) td {
background-color: #f5f9ff;
}
.findings-table tr:hover td {
background-color: #e5f1fd;
}
.findings-table th:nth-child(1) { width: 12%; } /* Rule */
.findings-table th:nth-child(2) { width: 20%; } /* File */
.findings-table th:nth-child(3) { width: 25%; } /* Description */
.findings-table th:nth-child(4) { width: 20%; } /* Secret */
.findings-table th:nth-child(5) { width: 23%; } /* Metadata */
.secret-container {
position: relative;
}
.match-toggle {
display: inline-block;
margin-top: 0.5rem;
background: linear-gradient(to bottom, #f1f8fe, #d8e6f6);
border: 1px solid #7da2ce;
color: #2c5fb2;
font-size: 11px;
border-radius: 3px;
padding: 2px 5px;
cursor: pointer;
}
.match-toggle:hover {
background: linear-gradient(to bottom, #e5f1fd, #c7ddfa);
}
.hidden {
display: none !important;
}
.secret-match {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: #f9f2f2;
border: 1px solid #e0c0c0;
border-radius: 3px;
padding: 0.5rem;
overflow-x: auto;
}
.tag-list {
display: flex;
gap: 0.25rem;
flex-wrap: wrap;
}
.tag {
display: inline-block;
padding: 2px 5px;
background-color: #3689de;
color: var(--text-inverse);
border-radius: 3px;
font-size: 10px;
margin: 2px;
}
.meta-row {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 0.5rem;
margin-top: 0.5rem;
font-size: 0.75rem;
color: var(--text-light);
}
.meta-item {
display: flex;
align-items: center;
gap: 0.25rem;
}
.meta-label {
font-weight: 500;
color: #2c5fb2;
}
.meta-value {
font-family: var(--font-mono);
word-break: break-all;
}
.code-preview {
position: relative;
font-family: var(--font-mono);
font-size: 0.875rem;
background-color: var(--secondary-color);
padding: 0.5rem;
border-radius: var(--radius);
overflow-x: auto;
margin-top: 0.5rem;
white-space: pre-wrap;
word-break: break-all;
}
.filters {
margin-bottom: 15px;
background-color: #eef3ff;
padding: 10px;
border: 1px solid #7da2ce;
border-radius: 5px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.filter-group {
display: flex;
align-items: center;
gap: 0.5rem;
margin-right: 15px;
}
.filter-label {
font-size: 12px;
font-weight: bold;
color: #2c5fb2;
}
.filter-input {
background-color: white;
border: 1px solid #7da2ce;
border-radius: 3px;
padding: 3px 6px;
font-size: 12px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) inset;
font-family: var(--font-main);
}
.app-footer {
background: linear-gradient(to bottom, #eef3ff, #d8e6f6);
border-top: 1px solid #7da2ce;
font-size: 11px;
padding: 8px 12px;
color: #2c5fb2;
height: auto;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
}
.description-toggle {
cursor: pointer;
color: #2c5fb2;
font-size: 0.875rem;
margin-left: 0.5rem;
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border-radius: 50%;
background: linear-gradient(to bottom, #f1f8fe, #d8e6f6);
border: 1px solid #7da2ce;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
vertical-align: middle;
}
.description-toggle:hover {
background-color: var(--primary-light);
color: var(--text-inverse);
}
.description-expanded {
white-space: normal;
}
.description-collapsed {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 250px;
display: inline-block;
}
.commit-link {
color: #2c5fb2;
text-decoration: none;
}
.commit-link:hover {
text-decoration: underline;
}
/* File path styling */
.file-path-container {
max-width: 100%;
}
.file-path {
display: inline-block;
max-width: 100%;
word-wrap: break-word;
word-break: break-all;
}
.match-content {
font-family: var(--font-mono);
font-size: 0.875rem;
word-break: break-all;
white-space: pre-wrap;
display: block;
background-color: #f9f9f9;
border: 1px solid #d0d0d0;
border-radius: 3px;
padding: 0.5rem;
margin-top: 0.5rem;
max-height: 300px;
overflow-y: auto;
}
@media (max-width: 768px) {
.app-header {
padding: 0 1rem;
}
.app-main {
padding: 1rem;
}
.report-stats {
flex-direction: column;
gap: 0.75rem;
}
.filters {
flex-direction: column;
gap: 0.75rem;
}
.app-footer {
flex-direction: column;
height: auto;
padding: 0.75rem 1rem;
gap: 0.5rem;
justify-content: center;
text-align: center;
}
}
</style>
</head>
<body>
<div class="app-container">
<header class="app-header">
<div class="logo">
<h1>Gitleaks Security Findings</h1>
</div>
</header>
<main class="app-main">
<div class="report-info">
<h2>Security Scan Report</h2>
<p class="report-date">Generated on {{now | date "Jan 02, 2006 15:04:05 MST"}}</p>
<div class="report-stats">
<div class="stat-item">
<span class="stat-value">{{len .}}</span>
<span class="stat-label">Total Findings</span>
</div>
<div class="stat-item">
<span class="stat-value" id="filesCount">-</span>
<span class="stat-label">Files Affected</span>
</div>
<div class="stat-item">
<span class="stat-value" id="rulesCount">-</span>
<span class="stat-label">Unique Rules Triggered</span>
</div>
<div class="stat-item" id="scanModeContainer">
<span class="stat-value" id="scanMode">-</span>
<span class="stat-label">Scan Mode</span>
</div>
</div>
</div>
<div class="filters">
<div class="filter-group">
<label class="filter-label" for="filterRule">Filter by Rule:</label>
<select class="filter-input" id="filterRule">
<option value="all">All Rules</option>
<!-- Rule options will be populated by JavaScript -->
</select>
</div>
<div class="filter-group">
<label class="filter-label" for="filterFile">Filter by File:</label>
<input type="text" class="filter-input" id="filterFile" placeholder="Enter filename...">
</div>
<div class="filter-group">
<button class="btn btn-primary btn-sm" id="resetFilters">Reset Filters</button>
</div>
</div>
<div class="table-wrapper">
<table class="findings-table" id="findingsTable">
<thead>
<tr>
<th>Rule</th>
<th>File</th>
<th>Description</th>
<th>Secret</th>
<th>Metadata</th>
</tr>
</thead>
<tbody>
{{- range . }}
<tr data-rule="{{.RuleID}}" data-file="{{.File}}">
<td>{{.RuleID}}</td>
<td>
<div class="file-path-container">
<span class="file-path" title="{{.File}}">{{.File}}</span>
</div>
<div class="tag-list">
{{- range .Tags }}
<span class="tag">{{.}}</span>
{{- end}}
</div>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Line:</span>
<span class="meta-value">{{.StartLine}}</span>
</div>
</div>
</td>
<td>
<span class="description-text">{{.Description}}</span>
<span class="description-toggle" title="Expand/Collapse">↕</span>
</td>
<td>
<div class="secret-container" data-secret="{{.Secret}}" data-match="{{.Match}}">
<div class="secret-match">{{.Secret}}</div>
<button type="button" class="match-toggle" title="Show/Hide Full Match Context">Show Context</button>
<div class="match-content hidden" data-raw-match="{{.Match}}">{{.Match}}</div>
</div>
</td>
<td>
<div class="meta-row">
<div class="meta-item">
<span class="meta-label">Entropy:</span>
<span class="meta-value">{{printf "%.2f" .Entropy}}</span>
</div>
{{- if .Commit}}
<div class="meta-item commit-info">
<span class="meta-label">Commit:</span>
<span class="meta-value">{{if gt (len .Commit) 7}}{{printf "%.7s" .Commit}}{{else}}{{.Commit}}{{end}}</span>
</div>
{{- if .Author}}
<div class="meta-item commit-info">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- if .Date}}
<div class="meta-item commit-info">
<span class="meta-label">Date:</span>
<span class="meta-value">{{.Date}}</span>
</div>
{{- end}}
{{- if .Link}}
<div class="meta-item commit-info">
<span class="meta-label">Link:</span>
<span class="meta-value"><a href="{{.Link}}" target="_blank" class="commit-link">View Commit</a></span>
</div>
{{- end}}
{{- else}}
{{- if .Author}}
<div class="meta-item">
<span class="meta-label">Author:</span>
<span class="meta-value">{{.Author}}</span>
</div>
{{- end}}
{{- end}}
</div>
{{- if not .Match}}
<div class="match-content" data-raw-match="">-</div>
{{- end}}
</td>
</tr>
{{- end }}
</tbody>
</table>
</div>
</main>
<footer class="app-footer">
<div>Generated by Gitleaks</div>
<div>Total Findings: <strong>{{len .}}</strong></div>
</footer>
</div>
<script>
// Process data to collect unique files and rules
function processData() {
const rows = document.querySelectorAll('#findingsTable tbody tr');
const uniqueRules = new Set();
const uniqueFiles = new Set();
let isGitMode = false;
if (rows.length > 0) {
// Check if first finding has commit data to determine mode
const firstRow = rows[0];
const commitCells = firstRow.querySelectorAll('.commit-info');
isGitMode = commitCells.length > 0 && commitCells[0].textContent.trim() !== '';
}
// Set scan mode
document.getElementById('scanMode').textContent = isGitMode ? 'Git' : 'Directory';
// Adjust UI based on mode
if (isGitMode) {
// Ensure commit info columns are visible for git mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'block';
});
} else {
// Hide commit-specific UI elements for directory mode
document.querySelectorAll('.commit-info').forEach(el => {
el.style.display = 'none';
});
}
rows.forEach(row => {
uniqueRules.add(row.dataset.rule);
uniqueFiles.add(row.dataset.file);
});
// Update stats
document.getElementById('filesCount').textContent = uniqueFiles.size;
document.getElementById('rulesCount').textContent = uniqueRules.size;
// Populate rule filter dropdown
const ruleFilter = document.getElementById('filterRule');
const sortedRules = Array.from(uniqueRules).sort();
sortedRules.forEach(rule => {
const option = document.createElement('option');
option.value = rule;
option.textContent = rule;
ruleFilter.appendChild(option);
});
}
// Hide toggle button if match is same as secret
function hideRedundantToggleButtons() {
document.querySelectorAll('.secret-container').forEach(container => {
const secret = container.getAttribute('data-secret');
const match = container.getAttribute('data-match');
const toggleButton = container.querySelector('.match-toggle');
// If secret and match are the same, or if match is empty, hide the toggle button
if ((secret && match && secret.trim() === match.trim()) || !match) {
if (toggleButton) {
toggleButton.style.display = 'none';
}
}
});
}
// Setup toggle buttons
function setupToggleButtons() {
document.querySelectorAll('.match-toggle').forEach(btn => {
btn.addEventListener('click', function() {
const matchContent = this.nextElementSibling;
if (matchContent.classList.contains('hidden')) {
matchContent.classList.remove('hidden');
this.textContent = 'Hide Context';
} else {
matchContent.classList.add('hidden');
this.textContent = 'Show Context';
}
});
});
// Setup description toggle
document.querySelectorAll('.description-text').forEach(descriptionText => {
const toggleBtn = descriptionText.nextElementSibling;
if (!toggleBtn || !toggleBtn.classList.contains('description-toggle')) return;
// Initial state: collapsed
descriptionText.classList.add('description-collapsed');
toggleBtn.addEventListener('click', () => {
if (descriptionText.classList.contains('description-collapsed')) {
descriptionText.classList.remove('description-collapsed');
descriptionText.classList.add('description-expanded');
toggleBtn.textContent = '↑';
} else {
descriptionText.classList.remove('description-expanded');
descriptionText.classList.add('description-collapsed');
toggleBtn.textContent = '↕';
}
});
});
}
// Filter functionality
function applyFilters() {
const ruleFilter = document.getElementById('filterRule').value;
const fileFilter = document.getElementById('filterFile').value.toLowerCase();
const rows = document.querySelectorAll('#findingsTable tbody tr');
rows.forEach(row => {
const ruleMatch = ruleFilter === 'all' || row.dataset.rule === ruleFilter;
const fileMatch = fileFilter === '' || row.dataset.file.toLowerCase().includes(fileFilter);
if (ruleMatch && fileMatch) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
// Update visible count
const visibleFindings = document.querySelectorAll('#findingsTable tbody tr:not([style*="display: none"])').length;
document.querySelector('.app-footer strong').textContent = visibleFindings;
}
document.getElementById('filterRule').addEventListener('change', applyFilters);
document.getElementById('filterFile').addEventListener('input', applyFilters);
document.getElementById('resetFilters').addEventListener('click', function() {
document.getElementById('filterRule').value = 'all';
document.getElementById('filterFile').value = '';
applyFilters();
});
// Initialize
document.addEventListener('DOMContentLoaded', function() {
processData();
hideRedundantToggleButtons(); // Hide toggle buttons for matching secrets
setupToggleButtons();
});
</script>
</body>
</html>
+10 -3
View File
@@ -4,9 +4,11 @@ import (
"io/fs"
"os"
"path/filepath"
"runtime"
"github.com/fatih/semgroup"
"github.com/rs/zerolog/log"
"github.com/zricethezav/gitleaks/v8/logging"
)
type ScanTarget struct {
@@ -14,13 +16,15 @@ type ScanTarget struct {
Symlink string
}
var isWindows = runtime.GOOS == "windows"
func DirectoryTargets(source string, s *semgroup.Group, followSymlinks bool, shouldSkip func(string) bool) (<-chan ScanTarget, error) {
paths := make(chan ScanTarget)
s.Go(func() error {
defer close(paths)
return filepath.Walk(source,
func(path string, fInfo os.FileInfo, err error) error {
logger := log.With().Str("path", path).Logger()
logger := logging.With().Str("path", path).Logger()
if err != nil {
if os.IsPermission(err) {
@@ -62,7 +66,10 @@ func DirectoryTargets(source string, s *semgroup.Group, followSymlinks bool, sho
}
// TODO: Also run this check against the resolved symlink?
skip := shouldSkip(path)
skip := shouldSkip(path) ||
// TODO: Remove this in v9.
// This is an awkward hack to mitigate https://github.com/gitleaks/gitleaks/issues/1641.
(isWindows && shouldSkip(filepath.ToSlash(path)))
if fInfo.IsDir() {
// Directory
if skip {
Loaded 100 of 107 files, more files were not shown because too many files have changed in this diff. Show more