mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ef704f28f | ||
|
|
7cfebca510 | ||
|
|
6d801ed61c | ||
|
|
e15ab0dc2a | ||
|
|
c39e7640e2 | ||
|
|
c0caab0355 | ||
|
|
81c92c78ca | ||
|
|
bf031592b8 | ||
|
|
acce01f233 | ||
|
|
2678a54290 | ||
|
|
289b757158 | ||
|
|
c02d830494 | ||
|
|
67b0a29ab6 | ||
|
|
f710d680dd | ||
|
|
eb2bfe5e16 | ||
|
|
55d1da131a | ||
|
|
177e9f4fc2 | ||
|
|
e93d8cb696 | ||
|
|
db43f9a342 | ||
|
|
9b15f0d33e | ||
|
|
817aa7b8d0 | ||
|
|
33082a9967 | ||
|
|
7dbfe8db2f | ||
|
|
fc98cbf159 | ||
|
|
3f0293dab0 | ||
|
|
4f6ee2bcf1 | ||
|
|
62020539f4 | ||
|
|
c8681e4858 |
No files matched your search
+11
-11
@@ -9,18 +9,18 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.18
|
go-version: 1.19
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: make test
|
run: make test
|
||||||
|
|
||||||
- name: Validate Config
|
- name: Validate Config
|
||||||
run: cd cmd/generate/config && go run main.go
|
run: cd cmd/generate/config && go run main.go
|
||||||
+10
-1
@@ -33,6 +33,7 @@ a42b32bdf11b6f4ea5c32ec76a1731b4b0c5e52a:cmd/generate/config/rules/generic.go:ge
|
|||||||
6e72472b6019d29eaa4b76b39700cd2418741f0c:detect/detect_test.go:aws-access-token:73
|
6e72472b6019d29eaa4b76b39700cd2418741f0c:detect/detect_test.go:aws-access-token:73
|
||||||
6e72472b6019d29eaa4b76b39700cd2418741f0c:detect/detect_test.go:aws-access-token:81
|
6e72472b6019d29eaa4b76b39700cd2418741f0c:detect/detect_test.go:aws-access-token:81
|
||||||
6e72472b6019d29eaa4b76b39700cd2418741f0c:detect/detect_test.go:aws-access-token:89
|
6e72472b6019d29eaa4b76b39700cd2418741f0c:detect/detect_test.go:aws-access-token:89
|
||||||
|
33082a996774ba4c8ad4ba26fd219d77497eb960:README.md:sidekiq-secret:43
|
||||||
6e72472b6019d29eaa4b76b39700cd2418741f0c:detect/detect_test.go:discord-api-token:98
|
6e72472b6019d29eaa4b76b39700cd2418741f0c:detect/detect_test.go:discord-api-token:98
|
||||||
57d2d345b6b6ea220be9d99792b21a75359555c0:detect/detect_test.go:aws-access-token:235
|
57d2d345b6b6ea220be9d99792b21a75359555c0:detect/detect_test.go:aws-access-token:235
|
||||||
57d2d345b6b6ea220be9d99792b21a75359555c0:detect/detect_test.go:aws-access-token:236
|
57d2d345b6b6ea220be9d99792b21a75359555c0:detect/detect_test.go:aws-access-token:236
|
||||||
@@ -651,7 +652,9 @@ bc26e979c5911cf647c1bede0b3700ebaaa454c8:checks_test.go:aws-access-token:36
|
|||||||
8f352bd840f028b481dc725b77d2f4904b77913b:checks_test.go:aws-access-token:34
|
8f352bd840f028b481dc725b77d2f4904b77913b:checks_test.go:aws-access-token:34
|
||||||
ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29:checks_test.go:aws-access-token:37
|
ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29:checks_test.go:aws-access-token:37
|
||||||
06c9e824d5985c8e8789321ae70de7ace3b093dc:main.go:aws-access-token:15
|
06c9e824d5985c8e8789321ae70de7ace3b093dc:main.go:aws-access-token:15
|
||||||
|
6d801ed61cf4d75d176cbf9062ec6ad706c9d1eb:detect/detect_test.go:private-key:567
|
||||||
|
6d801ed61cf4d75d176cbf9062ec6ad706c9d1eb:testdata/repos/symlinks/source_file/id_ed25519:private-key:1
|
||||||
|
acce01f2338434a78f6a4a06a097b0fd23280484:README.md:aws-access-token:218
|
||||||
README.md:aws-access-token:204
|
README.md:aws-access-token:204
|
||||||
README.md:aws-access-token:205
|
README.md:aws-access-token:205
|
||||||
README.md:aws-access-token:244
|
README.md:aws-access-token:244
|
||||||
@@ -741,3 +744,9 @@ testdata/repos/nogit/main.go:aws-access-token:20
|
|||||||
96eed6aa0f507fe0c21bb46bec32637dc4cb1a9f:detect/detect_test.go:aws-access-token:513
|
96eed6aa0f507fe0c21bb46bec32637dc4cb1a9f:detect/detect_test.go:aws-access-token:513
|
||||||
bfbc39eb185a217ead81a7174026f1c55f963660:cmd/generate/config/rules/jwt.go:jwt:17
|
bfbc39eb185a217ead81a7174026f1c55f963660:cmd/generate/config/rules/jwt.go:jwt:17
|
||||||
bfbc39eb185a217ead81a7174026f1c55f963660:cmd/generate/config/rules/jwt.go:jwt:19
|
bfbc39eb185a217ead81a7174026f1c55f963660:cmd/generate/config/rules/jwt.go:jwt:19
|
||||||
|
acce01f2338434a78f6a4a06a097b0fd23280484:README.md:aws-access-token:220
|
||||||
|
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:514
|
||||||
|
111c8b47b65627db117bd20be85ff0aee8961eb9:detect/detect_test.go:private-key:567
|
||||||
|
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:512
|
||||||
|
99d620c719020fa24baa831299f0c964da79875e:detect/detect_test.go:aws-access-token:513
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.18 AS build
|
FROM golang:1.19 AS build
|
||||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN VERSION=$(git describe --tags --abbrev=0) && \
|
RUN VERSION=$(git describe --tags --abbrev=0) && \
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# gitleaks
|
# Gitleaks
|
||||||
|
|
||||||
```
|
```
|
||||||
┌─○───┐
|
┌─○───┐
|
||||||
@@ -30,49 +30,49 @@
|
|||||||
|
|
||||||
Gitleaks is a SAST tool for **detecting** and **preventing** hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks is an **easy-to-use, all-in-one solution** for detecting secrets, past or present, in your code.
|
Gitleaks is a SAST tool for **detecting** and **preventing** hardcoded secrets like passwords, api keys, and tokens in git repos. Gitleaks is an **easy-to-use, all-in-one solution** for detecting secrets, past or present, in your code.
|
||||||
|
|
||||||
| Demos |
|
```
|
||||||
| ----------- |
|
➜ ~/code(master) gitleaks detect --source . -v
|
||||||
| CLI [](https://asciinema.org/a/455683)|
|
|
||||||
| [Github-Action](https://github.com/gitleaks/gitleaks-action) |
|
○
|
||||||
|
│╲
|
||||||
|
│ ○
|
||||||
|
○ ░
|
||||||
|
░ gitleaks
|
||||||
|
|
||||||
|
|
||||||
|
Finding: "export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef",
|
||||||
|
Secret: cafebabe:deadbeef
|
||||||
|
RuleID: sidekiq-secret
|
||||||
|
Entropy: 2.609850
|
||||||
|
File: cmd/generate/config/rules/sidekiq.go
|
||||||
|
Line: 23
|
||||||
|
Commit: cd5226711335c68be1e720b318b7bc3135a30eb2
|
||||||
|
Author: John
|
||||||
|
Email: john@users.noreply.github.com
|
||||||
|
Date: 2022-08-03T12:31:40Z
|
||||||
|
Fingerprint: cd5226711335c68be1e720b318b7bc3135a30eb2:cmd/generate/config/rules/sidekiq.go:sidekiq-secret:23
|
||||||
|
```
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
Gitleaks can be installed using Homebrew, Docker, or Go. Gitleaks is also available in binary form for many popular platforms and OS types on the [releases page](https://github.com/zricethezav/gitleaks/releases). In addition, Gitleaks can be implemented as a pre-commit hook directly in your repo or as a GitHub action using [Gitleaks-Action](https://github.com/gitleaks/gitleaks-action) (see demo above).
|
Gitleaks can be installed using Homebrew, Docker, or Go. Gitleaks is also available in binary form for many popular platforms and OS types on the [releases page](https://github.com/zricethezav/gitleaks/releases). In addition, Gitleaks can be implemented as a pre-commit hook directly in your repo or as a GitHub action using [Gitleaks-Action](https://github.com/gitleaks/gitleaks-action).
|
||||||
|
|
||||||
### MacOS
|
### Installing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# MacOS
|
||||||
brew install gitleaks
|
brew install gitleaks
|
||||||
```
|
|
||||||
|
|
||||||
### Docker
|
# Docker (DockerHub)
|
||||||
|
|
||||||
#### DockerHub
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker pull zricethezav/gitleaks:latest
|
docker pull zricethezav/gitleaks:latest
|
||||||
docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] --source="/path" [OPTIONS]
|
docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] --source="/path" [OPTIONS]
|
||||||
```
|
|
||||||
|
|
||||||
#### ghcr.io
|
# Docker (ghcr.io)
|
||||||
|
|
||||||
```bash
|
|
||||||
docker pull ghcr.io/zricethezav/gitleaks:latest
|
docker pull ghcr.io/zricethezav/gitleaks:latest
|
||||||
docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] --source="/path" [OPTIONS]
|
docker run -v ${path_to_host_folder_to_scan}:/path zricethezav/gitleaks:latest [COMMAND] --source="/path" [OPTIONS]
|
||||||
```
|
|
||||||
|
|
||||||
### From Source
|
# From Source
|
||||||
|
|
||||||
1. Download and install Go from https://golang.org/dl/
|
|
||||||
2. Clone the repo
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/zricethezav/gitleaks.git
|
git clone https://github.com/zricethezav/gitleaks.git
|
||||||
```
|
|
||||||
|
|
||||||
3. Build the binary
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd gitleaks
|
cd gitleaks
|
||||||
make build
|
make build
|
||||||
```
|
```
|
||||||
@@ -106,15 +106,16 @@ jobs:
|
|||||||
```
|
```
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/zricethezav/gitleaks
|
- repo: https://github.com/zricethezav/gitleaks
|
||||||
rev: v8.11.2
|
rev: v8.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: gitleaks
|
- id: gitleaks
|
||||||
```
|
```
|
||||||
|
|
||||||
for a [native execution of GitLeaks](https://github.com/zricethezav/gitleaks/releases) or use the [`gitleaks-docker` pre-commit ID](https://github.com/zricethezav/gitleaks/blob/master/.pre-commit-hooks.yaml) for executing GitLeaks using the [official Docker images](#docker)
|
for a [native execution of GitLeaks](https://github.com/zricethezav/gitleaks/releases) or use the [`gitleaks-docker` pre-commit ID](https://github.com/zricethezav/gitleaks/blob/master/.pre-commit-hooks.yaml) for executing GitLeaks using the [official Docker images](#docker)
|
||||||
|
|
||||||
3. Install with `pre-commit install`
|
3. Auto-update the config to the latest repos' versions by executing `pre-commit autoupdate`
|
||||||
4. Now you're all set!
|
4. Install with `pre-commit install`
|
||||||
|
5. Now you're all set!
|
||||||
|
|
||||||
```
|
```
|
||||||
➜ git commit -m "this commit contains a secret"
|
➜ git commit -m "this commit contains a secret"
|
||||||
@@ -137,26 +138,29 @@ Usage:
|
|||||||
|
|
||||||
Available Commands:
|
Available Commands:
|
||||||
completion generate the autocompletion script for the specified shell
|
completion generate the autocompletion script for the specified shell
|
||||||
detect Detect secrets in code
|
detect detect secrets in code
|
||||||
help Help about any command
|
help Help about any command
|
||||||
protect Protect secrets in code
|
protect protect secrets in code
|
||||||
version Display gitleaks version
|
version display gitleaks version
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-c, --config string config file path
|
-b, --baseline-path string path to baseline with issues that can be ignored
|
||||||
order of precedence:
|
-c, --config string config file path
|
||||||
1. --config/-c
|
order of precedence:
|
||||||
2. env var GITLEAKS_CONFIG
|
1. --config/-c
|
||||||
3. (--source/-s)/.gitleaks.toml
|
2. env var GITLEAKS_CONFIG
|
||||||
If none of the three options are used, then gitleaks will use the default config
|
3. (--source/-s)/.gitleaks.toml
|
||||||
--exit-code string exit code when leaks have been encountered (default: 1)
|
If none of the three options are used, then gitleaks will use the default config
|
||||||
-h, --help help for gitleaks
|
--exit-code int exit code when leaks have been encountered (default 1)
|
||||||
-l, --log-level string log level (debug, info, warn, error, fatal) (default "info")
|
-h, --help help for gitleaks
|
||||||
--redact redact secrets from logs and stdout
|
-l, --log-level string log level (trace, debug, info, warn, error, fatal) (default "info")
|
||||||
-f, --report-format string output format (json, csv, sarif)
|
--max-target-megabytes int files larger than this will be skipped
|
||||||
-r, --report-path string report file
|
--no-banner suppress banner
|
||||||
-s, --source string path to source (git repo, directory, file)
|
--redact redact secrets from logs and stdout
|
||||||
-v, --verbose show verbose output from scan
|
-f, --report-format string output format (json, csv, sarif) (default "json")
|
||||||
|
-r, --report-path string report file
|
||||||
|
-s, --source string path to source (default: $PWD) (default ".")
|
||||||
|
-v, --verbose show verbose output from scan
|
||||||
|
|
||||||
Use "gitleaks [command] --help" for more information about a command.
|
Use "gitleaks [command] --help" for more information about a command.
|
||||||
```
|
```
|
||||||
@@ -189,31 +193,40 @@ as a pre-commit.
|
|||||||
|
|
||||||
**NOTE**: the `protect` command can only be used on git repos, running `protect` on files or directories will result in an error message.
|
**NOTE**: the `protect` command can only be used on git repos, running `protect` on files or directories will result in an error message.
|
||||||
|
|
||||||
|
### Creating a baseline
|
||||||
|
|
||||||
|
When scanning large repositories or repositories with a long history, it can be convenient to use a baseline. When using a baseline,
|
||||||
|
gitleaks will ignore any old findings that are present in the baseline. A baseline can be any gitleaks report. To create a gitleaks report, run gitleaks with the `--report-path` parameter.
|
||||||
|
|
||||||
|
```
|
||||||
|
gitleaks detect --report-path gitleaks-report.json # This will save the report in a file called gitleaks-report.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Once as baseline is created it can be applied when running the detect command again:
|
||||||
|
|
||||||
|
```
|
||||||
|
gitleaks detect --baseline-path gitleaks-report.json --report-path findings.json
|
||||||
|
```
|
||||||
|
|
||||||
|
After running the detect command with the --baseline-path parameter, report output (findings.json) will only contain new issues.
|
||||||
|
|
||||||
### Verify Findings
|
### Verify Findings
|
||||||
|
|
||||||
You can verify a finding found by gitleaks using a `git log` command.
|
You can verify a finding found by gitleaks using a `git log` command.
|
||||||
Example output:
|
Example output:
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
Finding: aws_secret="AKIAIMNOJVGFDXXXE4OA"
|
||||||
"Description": "AWS",
|
RuleID: aws-access-token
|
||||||
"StartLine": 37,
|
Secret AKIAIMNOJVGFDXXXE4OA
|
||||||
"EndLine": 37,
|
Entropy: 3.65
|
||||||
"StartColumn": 19,
|
File: checks_test.go
|
||||||
"EndColumn": 38,
|
Line: 37
|
||||||
"Match": "\t\t\"aws_secret= \\\"AKIAIMNOJVGFDXXXE4OA\\\"\": true,",
|
Commit: ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29
|
||||||
"Secret": "AKIAIMNOJVGFDXXXE4OA",
|
Author: Zachary Rice
|
||||||
"File": "checks_test.go",
|
Email: z@email.com
|
||||||
"Commit": "ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29",
|
Date: 2018-01-28T17:39:00Z
|
||||||
"Entropy": 0,
|
Fingerprint: ec2fc9d6cb0954fb3b57201cf6133c48d8ca0d29:checks_test.go:aws-access-token:37
|
||||||
"Author": "zricethezav",
|
|
||||||
"Email": "thisispublicanyways@gmail.com",
|
|
||||||
"Date": "2018-01-28 17:39:00 -0500 -0500",
|
|
||||||
"Message": "[update] entropy check",
|
|
||||||
"Tags": [],
|
|
||||||
"RuleID": "aws-access-token"
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
We can use the following format to verify the leak:
|
We can use the following format to verify the leak:
|
||||||
@@ -356,12 +369,16 @@ stopwords = [
|
|||||||
'''endpoint''',
|
'''endpoint''',
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/zricethezav/gitleaks/blob/master/README.md).
|
Refer to the default [gitleaks config](https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml) for examples or follow the [contributing guidelines](https://github.com/zricethezav/gitleaks/blob/master/README.md).
|
||||||
|
|
||||||
### Additional Configuration
|
### Additional Configuration
|
||||||
|
|
||||||
#### gitleaks:allow
|
#### gitleaks:allow
|
||||||
|
|
||||||
If you are knowingly committing a test secret that gitleaks will catch you can add a `gitleaks:allow` comment to that line which will instruct gitleaks
|
If you are knowingly committing a test secret that gitleaks will catch you can add a `gitleaks:allow` comment to that line which will instruct gitleaks
|
||||||
to ignore that secret. Ex:
|
to ignore that secret. Ex:
|
||||||
|
|
||||||
```
|
```
|
||||||
class CustomClass:
|
class CustomClass:
|
||||||
discord_client_secret = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ' #gitleaks:allow
|
discord_client_secret = '8dyfuiRyq=vVc3RRr_edRk-fK__JItpZ' #gitleaks:allow
|
||||||
@@ -369,8 +386,8 @@ class CustomClass:
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### .gitleaksignore
|
#### .gitleaksignore
|
||||||
You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. Note: this feature is expirmental and is subject to change in the future.
|
|
||||||
|
|
||||||
|
You can ignore specific findings by creating a `.gitleaksignore` file at the root of your repo. In release v8.10.0 Gitleaks added a `Fingerprint` value to the Gitleaks report. Each leak, or finding, has a Fingerprint that uniquely identifies a secret. Add this fingerprint to the `.gitleaksignore` file to ignore that specific secret. See Gitleaks' [.gitleaksignore](https://github.com/zricethezav/gitleaks/blob/master/.gitleaksignore) for an example. Note: this feature is expirmental and is subject to change in the future.
|
||||||
|
|
||||||
## Secured by Jit
|
## Secured by Jit
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
## Who uses Gitleaks?
|
||||||
|
|
||||||
|
As the Gitleaks Community grows, we'd like to keep a list of our users.
|
||||||
|
|
||||||
|
Here's a running list of some organizations using Gitleaks[^1]:
|
||||||
|
|
||||||
|
1. [GitLab](https://docs.gitlab.com/ee/user/application_security/secret_detection/)
|
||||||
|
1. [Gitleaks](https://gitleaks.io)
|
||||||
|
1. [GoReleaser](https://goreleaser.com)
|
||||||
|
2. [Trendyol](https://trendyol.com)
|
||||||
|
|
||||||
|
Feel free to [add yours](https://github.com/zricethezav/gitleaks/edit/master/USERS.md)!
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Hey! Thanks for looking into this file!
|
||||||
|
If you're going to edit it, please:
|
||||||
|
- keep a-z ordering :)
|
||||||
|
- edit only the USERS.md file at the repository's root folder
|
||||||
|
-->
|
||||||
|
|
||||||
|
[^1]: Entries were either added by the companies themselves or by the maintainers after seeing it in the wild.
|
||||||
|
You can see all public repositories using Gitleaks or Gitleaks-Action by [searching on GitHub](https://github.com/search?q=gitleaks).
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Shout out to GoReleaser for this template: https://github.com/goreleaser/goreleaser/blob/main/USERS.md
|
||||||
|
-->
|
||||||
+43
-11
@@ -18,6 +18,9 @@ func init() {
|
|||||||
rootCmd.AddCommand(detectCmd)
|
rootCmd.AddCommand(detectCmd)
|
||||||
detectCmd.Flags().String("log-opts", "", "git log options")
|
detectCmd.Flags().String("log-opts", "", "git log options")
|
||||||
detectCmd.Flags().Bool("no-git", false, "treat git repo as a regular directory and scan those files, --log-opts has no effect on the scan when --no-git is set")
|
detectCmd.Flags().Bool("no-git", false, "treat git repo as a regular directory and scan those files, --log-opts has no effect on the scan when --no-git is set")
|
||||||
|
detectCmd.Flags().Bool("pipe", false, "scan input from stdin, ex: `cat some_file | gitleaks detect --pipe`")
|
||||||
|
detectCmd.Flags().Bool("follow-symlinks", false, "scan files that are symlinks to other files")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var detectCmd = &cobra.Command{
|
var detectCmd = &cobra.Command{
|
||||||
@@ -51,11 +54,11 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
detector := detect.NewDetector(cfg)
|
detector := detect.NewDetector(cfg)
|
||||||
detector.Config.Path, err = cmd.Flags().GetString("config")
|
detector.Config.Path, err = cmd.Flags().GetString("config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
source, err := cmd.Flags().GetString("source")
|
source, err := cmd.Flags().GetString("source")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
// if config path is not set, then use the {source}/.gitleaks.toml path.
|
// if config path is not set, then use the {source}/.gitleaks.toml path.
|
||||||
// note that there may not be a `{source}/.gitleaks.toml` file, this is ok.
|
// note that there may not be a `{source}/.gitleaks.toml` file, this is ok.
|
||||||
@@ -64,27 +67,50 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
// set verbose flag
|
// set verbose flag
|
||||||
if detector.Verbose, err = cmd.Flags().GetBool("verbose"); err != nil {
|
if detector.Verbose, err = cmd.Flags().GetBool("verbose"); err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
// set redact flag
|
// set redact flag
|
||||||
if detector.Redact, err = cmd.Flags().GetBool("redact"); err != nil {
|
if detector.Redact, err = cmd.Flags().GetBool("redact"); err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
|
}
|
||||||
|
if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
|
|
||||||
if fileExists(filepath.Join(source, ".gitleaksignore")) {
|
if fileExists(filepath.Join(source, ".gitleaksignore")) {
|
||||||
detector.AddGitleaksIgnore(filepath.Join(source, ".gitleaksignore"))
|
if err = detector.AddGitleaksIgnore(filepath.Join(source, ".gitleaksignore")); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("could not call AddGitleaksIgnore")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ignore findings from the baseline (an existing report in json format generated earlier)
|
||||||
|
baselinePath, _ := cmd.Flags().GetString("baseline-path")
|
||||||
|
if baselinePath != "" {
|
||||||
|
err = detector.AddBaseline(baselinePath)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Msgf("Could not load baseline. The path must point of a gitleaks report generated using the default format: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set follow symlinks flag
|
||||||
|
if detector.FollowSymlinks, err = cmd.Flags().GetBool("follow-symlinks"); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
|
|
||||||
// set exit code
|
// set exit code
|
||||||
exitCode, err := cmd.Flags().GetInt("exit-code")
|
exitCode, err := cmd.Flags().GetInt("exit-code")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("could not get exit code")
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine what type of scan:
|
// determine what type of scan:
|
||||||
// - git: scan the history of the repo
|
// - git: scan the history of the repo
|
||||||
// - no-git: scan files by treating the repo as a plain directory
|
// - no-git: scan files by treating the repo as a plain directory
|
||||||
noGit, err := cmd.Flags().GetBool("no-git")
|
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 {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err)
|
||||||
}
|
}
|
||||||
@@ -94,19 +120,25 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
findings, err = detector.DetectFiles(source)
|
findings, err = detector.DetectFiles(source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// don't exit on error, just log it
|
// don't exit on error, just log it
|
||||||
log.Error().Msg(err.Error())
|
log.Error().Err(err).Msg("")
|
||||||
|
}
|
||||||
|
} else if fromPipe {
|
||||||
|
findings, err = detector.DetectReader(os.Stdin, 10)
|
||||||
|
if err != nil {
|
||||||
|
// log fatal to exit, no need to continue since a report
|
||||||
|
// will not be generated when scanning from a pipe...for now
|
||||||
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var logOpts string
|
var logOpts string
|
||||||
logOpts, err = cmd.Flags().GetString("log-opts")
|
logOpts, err = cmd.Flags().GetString("log-opts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
findings, err = detector.DetectGit(source, logOpts, detect.DetectType)
|
findings, err = detector.DetectGit(source, logOpts, detect.DetectType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// don't exit on error, just log it
|
// don't exit on error, just log it
|
||||||
log.Error().Msg(err.Error())
|
log.Error().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +164,7 @@ func runDetect(cmd *cobra.Command, args []string) {
|
|||||||
ext, _ := cmd.Flags().GetString("report-format")
|
ext, _ := cmd.Flags().GetString("report-format")
|
||||||
if reportPath != "" {
|
if reportPath != "" {
|
||||||
if err := report.Write(findings, cfg, ext, reportPath); err != nil {
|
if err := report.Write(findings, cfg, ext, reportPath); err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("could not write")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
configRules := []*config.Rule{}
|
var configRules []*config.Rule
|
||||||
configRules = append(configRules, rules.AdafruitAPIKey())
|
configRules = append(configRules, rules.AdafruitAPIKey())
|
||||||
configRules = append(configRules, rules.AdobeClientID())
|
configRules = append(configRules, rules.AdobeClientID())
|
||||||
configRules = append(configRules, rules.AdobeClientSecret())
|
configRules = append(configRules, rules.AdobeClientSecret())
|
||||||
@@ -41,6 +41,9 @@ func main() {
|
|||||||
configRules = append(configRules, rules.Contentful())
|
configRules = append(configRules, rules.Contentful())
|
||||||
configRules = append(configRules, rules.Databricks())
|
configRules = append(configRules, rules.Databricks())
|
||||||
configRules = append(configRules, rules.DatadogtokenAccessToken())
|
configRules = append(configRules, rules.DatadogtokenAccessToken())
|
||||||
|
configRules = append(configRules, rules.DigitalOceanPAT())
|
||||||
|
configRules = append(configRules, rules.DigitalOceanOAuthToken())
|
||||||
|
configRules = append(configRules, rules.DigitalOceanRefreshToken())
|
||||||
configRules = append(configRules, rules.DiscordAPIToken())
|
configRules = append(configRules, rules.DiscordAPIToken())
|
||||||
configRules = append(configRules, rules.DiscordClientID())
|
configRules = append(configRules, rules.DiscordClientID())
|
||||||
configRules = append(configRules, rules.DiscordClientSecret())
|
configRules = append(configRules, rules.DiscordClientSecret())
|
||||||
@@ -141,6 +144,8 @@ func main() {
|
|||||||
configRules = append(configRules, rules.SquareSpaceAccessToken())
|
configRules = append(configRules, rules.SquareSpaceAccessToken())
|
||||||
configRules = append(configRules, rules.SumoLogicAccessID())
|
configRules = append(configRules, rules.SumoLogicAccessID())
|
||||||
configRules = append(configRules, rules.SumoLogicAccessToken())
|
configRules = append(configRules, rules.SumoLogicAccessToken())
|
||||||
|
configRules = append(configRules, rules.TeamsWebhook())
|
||||||
|
configRules = append(configRules, rules.TelegramBotToken())
|
||||||
configRules = append(configRules, rules.TravisCIAccessToken())
|
configRules = append(configRules, rules.TravisCIAccessToken())
|
||||||
configRules = append(configRules, rules.Twilio())
|
configRules = append(configRules, rules.Twilio())
|
||||||
configRules = append(configRules, rules.TwitchAPIToken())
|
configRules = append(configRules, rules.TwitchAPIToken())
|
||||||
@@ -169,9 +174,7 @@ func main() {
|
|||||||
// nasty dereferencing.
|
// nasty dereferencing.
|
||||||
ruleLookUp[rule.RuleID] = *rule
|
ruleLookUp[rule.RuleID] = *rule
|
||||||
}
|
}
|
||||||
config := config.Config{
|
|
||||||
Rules: ruleLookUp,
|
|
||||||
}
|
|
||||||
tmpl, err := template.ParseFiles(templatePath)
|
tmpl, err := template.ParseFiles(templatePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Failed to parse template")
|
log.Fatal().Err(err).Msg("Failed to parse template")
|
||||||
@@ -181,6 +184,9 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Failed to create rules.toml")
|
log.Fatal().Err(err).Msg("Failed to create rules.toml")
|
||||||
}
|
}
|
||||||
tmpl.Execute(f, config)
|
|
||||||
|
if err = tmpl.Execute(f, config.Config{Rules: ruleLookUp}); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("could not execute template")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DigitalOceanPAT() *config.Rule {
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "DigitalOcean Personal Access Token",
|
||||||
|
RuleID: "digitalocean-pat",
|
||||||
|
SecretGroup: 1,
|
||||||
|
Regex: generateUniqueTokenRegex(`dop_v1_[a-f0-9]{64}`),
|
||||||
|
Keywords: []string{"dop_v1_"},
|
||||||
|
}
|
||||||
|
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("do", "dop_v1_"+secrets.NewSecret(hex("64"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DigitalOceanOAuthToken() *config.Rule {
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "DigitalOcean OAuth Access Token",
|
||||||
|
RuleID: "digitalocean-access-token",
|
||||||
|
SecretGroup: 1,
|
||||||
|
Regex: generateUniqueTokenRegex(`doo_v1_[a-f0-9]{64}`),
|
||||||
|
Keywords: []string{"doo_v1_"},
|
||||||
|
}
|
||||||
|
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("do", "doo_v1_"+secrets.NewSecret(hex("64"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func DigitalOceanRefreshToken() *config.Rule {
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "DigitalOcean OAuth Refresh Token",
|
||||||
|
RuleID: "digitalocean-refresh-token",
|
||||||
|
SecretGroup: 1,
|
||||||
|
Regex: generateUniqueTokenRegex(`dor_v1_[a-f0-9]{64}`),
|
||||||
|
Keywords: []string{"dor_v1_"},
|
||||||
|
}
|
||||||
|
|
||||||
|
tps := []string{
|
||||||
|
generateSampleSecret("do", "dor_v1_"+secrets.NewSecret(hex("64"))),
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ func PrivateKey() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
Description: "Private Key",
|
Description: "Private Key",
|
||||||
RuleID: "private-key",
|
RuleID: "private-key",
|
||||||
Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY-----[\s\S-]*KEY----`),
|
Regex: regexp.MustCompile(`(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY----`),
|
||||||
Keywords: []string{"-----BEGIN"},
|
Keywords: []string{"-----BEGIN"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func SlackWebHook() *config.Rule {
|
|||||||
Description: "Slack Webhook",
|
Description: "Slack Webhook",
|
||||||
RuleID: "slack-web-hook",
|
RuleID: "slack-web-hook",
|
||||||
Regex: regexp.MustCompile(
|
Regex: regexp.MustCompile(
|
||||||
`https:\/\/hooks.slack.com\/services\/[A-Za-z0-9+\/]{44,46}`),
|
`https:\/\/hooks.slack.com\/(services|workflows)\/[A-Za-z0-9+\/]{44,46}`),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"hooks.slack.com",
|
"hooks.slack.com",
|
||||||
},
|
},
|
||||||
@@ -44,7 +44,8 @@ func SlackWebHook() *config.Rule {
|
|||||||
|
|
||||||
// validate
|
// validate
|
||||||
tps := []string{
|
tps := []string{
|
||||||
"https://hooks.slack.com/services/" + secrets.NewSecret(alphaNumeric("44")), // gitleaks:allow
|
"https://hooks.slack.com/services/" + secrets.NewSecret(alphaNumeric("44")), // gitleaks:allow
|
||||||
|
"https://hooks.slack.com/workflows/" + secrets.NewSecret(alphaNumeric("44")), // gitleaks:allow
|
||||||
}
|
}
|
||||||
return validate(r, tps, nil)
|
return validate(r, tps, nil)
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TeamsWebhook() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Microsoft Teams Webhook",
|
||||||
|
RuleID: "microsoft-teams-webhook",
|
||||||
|
Regex: regexp.MustCompile(
|
||||||
|
`https:\/\/[a-z0-9]+\.webhook\.office\.com\/webhookb2\/[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}@[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}\/IncomingWebhook\/[a-z0-9]{32}\/[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}`),
|
||||||
|
Keywords: []string{
|
||||||
|
"webhook.office.com",
|
||||||
|
"webhookb2",
|
||||||
|
"IncomingWebhook",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
"https://mycompany.webhook.office.com/webhookb2/" + secrets.NewSecret(`[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}@[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}\/IncomingWebhook\/[a-z0-9]{32}\/[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}`), // gitleaks:allow
|
||||||
|
}
|
||||||
|
return validate(r, tps, nil)
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TelegramBotToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
Description: "Telegram Bot API Token",
|
||||||
|
RuleID: "telegram-bot-api-token",
|
||||||
|
SecretGroup: 1,
|
||||||
|
Regex: regexp.MustCompile(`(?i)(?:^|[^0-9])([0-9]{5,16}:A[a-zA-Z0-9_\-]{34})(?:$|[^a-zA-Z0-9_\-])`),
|
||||||
|
Keywords: []string{
|
||||||
|
"telegram",
|
||||||
|
"api",
|
||||||
|
"bot",
|
||||||
|
"token",
|
||||||
|
"url",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
validToken := secrets.NewSecret(numeric("8") + ":A" + alphaNumericExtendedShort("34"))
|
||||||
|
minToken := secrets.NewSecret(numeric("5") + ":A" + alphaNumericExtendedShort("34"))
|
||||||
|
maxToken := secrets.NewSecret(numeric("16") + ":A" + alphaNumericExtendedShort("34"))
|
||||||
|
tps := []string{
|
||||||
|
// variable assigment
|
||||||
|
generateSampleSecret("telegram", validToken),
|
||||||
|
// URL contaning token
|
||||||
|
generateSampleSecret("url", "https://api.telegram.org/bot"+validToken+"/sendMessage"),
|
||||||
|
// object constructor
|
||||||
|
`const bot = new Telegraf("` + validToken + `")`,
|
||||||
|
// .env
|
||||||
|
`API_TOKEN = ` + validToken,
|
||||||
|
// YAML
|
||||||
|
`bot: ` + validToken,
|
||||||
|
// Token with min bot_id
|
||||||
|
generateSampleSecret("telegram", minToken),
|
||||||
|
// Token with max bot_id
|
||||||
|
generateSampleSecret("telegram", maxToken),
|
||||||
|
}
|
||||||
|
|
||||||
|
tooSmallToken := secrets.NewSecret(numeric("4") + ":A" + alphaNumericExtendedShort("34"))
|
||||||
|
tooBigToken := secrets.NewSecret(numeric("17") + ":A" + alphaNumericExtendedShort("34"))
|
||||||
|
fps := []string{
|
||||||
|
// Token with too small bot_id
|
||||||
|
generateSampleSecret("telegram", tooSmallToken),
|
||||||
|
// Token with too big bot_id
|
||||||
|
generateSampleSecret("telegram", tooBigToken),
|
||||||
|
}
|
||||||
|
|
||||||
|
return validate(r, tps, fps)
|
||||||
|
}
|
||||||
+12
-7
@@ -16,6 +16,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
protectCmd.Flags().Bool("staged", false, "detect secrets in a --staged state")
|
protectCmd.Flags().Bool("staged", false, "detect secrets in a --staged state")
|
||||||
|
protectCmd.Flags().String("log-opts", "", "git log options")
|
||||||
rootCmd.AddCommand(protectCmd)
|
rootCmd.AddCommand(protectCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,11 +47,11 @@ func runProtect(cmd *cobra.Command, args []string) {
|
|||||||
detector := detect.NewDetector(cfg)
|
detector := detect.NewDetector(cfg)
|
||||||
detector.Config.Path, err = cmd.Flags().GetString("config")
|
detector.Config.Path, err = cmd.Flags().GetString("config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
source, err := cmd.Flags().GetString("source")
|
source, err := cmd.Flags().GetString("source")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
// if config path is not set, then use the {source}/.gitleaks.toml path.
|
// if config path is not set, then use the {source}/.gitleaks.toml path.
|
||||||
// note that there may not be a `{source}/.gitleaks.toml` file, this is ok.
|
// note that there may not be a `{source}/.gitleaks.toml` file, this is ok.
|
||||||
@@ -59,17 +60,21 @@ func runProtect(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
// set verbose flag
|
// set verbose flag
|
||||||
if detector.Verbose, err = cmd.Flags().GetBool("verbose"); err != nil {
|
if detector.Verbose, err = cmd.Flags().GetBool("verbose"); err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
// set redact flag
|
// set redact flag
|
||||||
if detector.Redact, err = cmd.Flags().GetBool("redact"); err != nil {
|
if detector.Redact, err = cmd.Flags().GetBool("redact"); err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
|
}
|
||||||
|
|
||||||
|
if detector.MaxTargetMegaBytes, err = cmd.Flags().GetInt("max-target-megabytes"); err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
|
|
||||||
// get log options for git scan
|
// get log options for git scan
|
||||||
logOpts, err := cmd.Flags().GetString("log-opts")
|
logOpts, err := cmd.Flags().GetString("log-opts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
|
|
||||||
// start git scan
|
// start git scan
|
||||||
@@ -81,7 +86,7 @@ func runProtect(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// don't exit on error, just log it
|
// don't exit on error, just log it
|
||||||
log.Error().Err(err)
|
log.Error().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
|
|
||||||
// log info about the scan
|
// log info about the scan
|
||||||
@@ -96,7 +101,7 @@ func runProtect(cmd *cobra.Command, args []string) {
|
|||||||
ext, _ := cmd.Flags().GetString("report-format")
|
ext, _ := cmd.Flags().GetString("report-format")
|
||||||
if reportPath != "" {
|
if reportPath != "" {
|
||||||
if err = report.Write(findings, cfg, ext, reportPath); err != nil {
|
if err = report.Write(findings, cfg, ext, reportPath); err != nil {
|
||||||
log.Fatal().Err(err)
|
log.Fatal().Err(err).Msg("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(findings) != 0 {
|
if len(findings) != 0 {
|
||||||
|
|||||||
+10
-1
@@ -42,9 +42,12 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringP("source", "s", ".", "path to source (default: $PWD)")
|
rootCmd.PersistentFlags().StringP("source", "s", ".", "path to source (default: $PWD)")
|
||||||
rootCmd.PersistentFlags().StringP("report-path", "r", "", "report file")
|
rootCmd.PersistentFlags().StringP("report-path", "r", "", "report file")
|
||||||
rootCmd.PersistentFlags().StringP("report-format", "f", "json", "output format (json, csv, sarif)")
|
rootCmd.PersistentFlags().StringP("report-format", "f", "json", "output format (json, csv, sarif)")
|
||||||
|
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)")
|
rootCmd.PersistentFlags().StringP("log-level", "l", "info", "log level (trace, debug, info, warn, error, fatal)")
|
||||||
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "show verbose output from scan")
|
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "show verbose output from scan")
|
||||||
|
rootCmd.PersistentFlags().Int("max-target-megabytes", 0, "files larger than this will be skipped")
|
||||||
rootCmd.PersistentFlags().Bool("redact", false, "redact secrets from logs and stdout")
|
rootCmd.PersistentFlags().Bool("redact", false, "redact secrets from logs and stdout")
|
||||||
|
rootCmd.PersistentFlags().Bool("no-banner", false, "suppress banner")
|
||||||
err := viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
|
err := viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Msgf("err binding config %s", err.Error())
|
log.Fatal().Msgf("err binding config %s", err.Error())
|
||||||
@@ -76,7 +79,13 @@ func initLog() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initConfig() {
|
func initConfig() {
|
||||||
fmt.Fprint(os.Stderr, banner)
|
hideBanner, err := rootCmd.Flags().GetBool("no-banner")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal().Msg(err.Error())
|
||||||
|
}
|
||||||
|
if !hideBanner {
|
||||||
|
_, _ = fmt.Fprint(os.Stderr, banner)
|
||||||
|
}
|
||||||
cfgPath, err := rootCmd.Flags().GetString("config")
|
cfgPath, err := rootCmd.Flags().GetString("config")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Msg(err.Error())
|
log.Fatal().Msg(err.Error())
|
||||||
|
|||||||
+49
-2
@@ -238,6 +238,33 @@ keywords = [
|
|||||||
"datadog",
|
"datadog",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "DigitalOcean OAuth Access Token"
|
||||||
|
id = "digitalocean-access-token"
|
||||||
|
regex = '''(?i)\b(doo_v1_[a-f0-9]{64})(?:['|\"|\n|\r|\s|\x60|;]|$)'''
|
||||||
|
secretGroup = 1
|
||||||
|
keywords = [
|
||||||
|
"doo_v1_",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "DigitalOcean Personal Access Token"
|
||||||
|
id = "digitalocean-pat"
|
||||||
|
regex = '''(?i)\b(dop_v1_[a-f0-9]{64})(?:['|\"|\n|\r|\s|\x60|;]|$)'''
|
||||||
|
secretGroup = 1
|
||||||
|
keywords = [
|
||||||
|
"dop_v1_",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "DigitalOcean OAuth Refresh Token"
|
||||||
|
id = "digitalocean-refresh-token"
|
||||||
|
regex = '''(?i)\b(dor_v1_[a-f0-9]{64})(?:['|\"|\n|\r|\s|\x60|;]|$)'''
|
||||||
|
secretGroup = 1
|
||||||
|
keywords = [
|
||||||
|
"dor_v1_",
|
||||||
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Discord API key"
|
description = "Discord API key"
|
||||||
id = "discord-api-token"
|
id = "discord-api-token"
|
||||||
@@ -462,6 +489,9 @@ keywords = [
|
|||||||
"key","api","token","secret","client","passwd","password","auth","access",
|
"key","api","token","secret","client","passwd","password","auth","access",
|
||||||
]
|
]
|
||||||
[rules.allowlist]
|
[rules.allowlist]
|
||||||
|
paths = [
|
||||||
|
'''Database.refactorlog'''
|
||||||
|
]
|
||||||
stopwords= [
|
stopwords= [
|
||||||
"client",
|
"client",
|
||||||
"endpoint",
|
"endpoint",
|
||||||
@@ -2227,6 +2257,14 @@ keywords = [
|
|||||||
"messagebird","message-bird","message_bird",
|
"messagebird","message-bird","message_bird",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Microsoft Teams Webhook"
|
||||||
|
id = "microsoft-teams-webhook"
|
||||||
|
regex = '''https:\/\/[a-z0-9]+\.webhook\.office\.com\/webhookb2\/[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}@[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}\/IncomingWebhook\/[a-z0-9]{32}\/[a-z0-9]{8}-([a-z0-9]{4}-){3}[a-z0-9]{12}'''
|
||||||
|
keywords = [
|
||||||
|
"webhook.office.com","webhookb2","incomingwebhook",
|
||||||
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Netlify Access Token"
|
description = "Netlify Access Token"
|
||||||
id = "netlify-access-token"
|
id = "netlify-access-token"
|
||||||
@@ -2365,7 +2403,7 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Private Key"
|
description = "Private Key"
|
||||||
id = "private-key"
|
id = "private-key"
|
||||||
regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY-----[\s\S-]*KEY----'''
|
regex = '''(?i)-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*KEY----'''
|
||||||
keywords = [
|
keywords = [
|
||||||
"-----begin",
|
"-----begin",
|
||||||
]
|
]
|
||||||
@@ -2529,7 +2567,7 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Slack Webhook"
|
description = "Slack Webhook"
|
||||||
id = "slack-web-hook"
|
id = "slack-web-hook"
|
||||||
regex = '''https:\/\/hooks.slack.com\/services\/[A-Za-z0-9+\/]{44,46}'''
|
regex = '''https:\/\/hooks.slack.com\/(services|workflows)\/[A-Za-z0-9+\/]{44,46}'''
|
||||||
keywords = [
|
keywords = [
|
||||||
"hooks.slack.com",
|
"hooks.slack.com",
|
||||||
]
|
]
|
||||||
@@ -2577,6 +2615,15 @@ keywords = [
|
|||||||
"sumo",
|
"sumo",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
description = "Telegram Bot API Token"
|
||||||
|
id = "telegram-bot-api-token"
|
||||||
|
regex = '''(?i)(?:^|[^0-9])([0-9]{5,16}:A[a-zA-Z0-9_\-]{34})(?:$|[^a-zA-Z0-9_\-])'''
|
||||||
|
secretGroup = 1
|
||||||
|
keywords = [
|
||||||
|
"telegram","api","bot","token","url",
|
||||||
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
description = "Travis CI Access Token"
|
description = "Travis CI Access Token"
|
||||||
id = "travisci-access-token"
|
id = "travisci-access-token"
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package detect
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/v8/report"
|
||||||
|
)
|
||||||
|
|
||||||
|
func IsNew(finding report.Finding, baseline []report.Finding) bool {
|
||||||
|
// Explicitly testing each property as it gives significantly better performance in comparison to cmp.Equal(). Drawback is that
|
||||||
|
// the code requires maintanance if/when the Finding struct changes
|
||||||
|
for _, b := range baseline {
|
||||||
|
|
||||||
|
if finding.Author == b.Author &&
|
||||||
|
finding.Commit == b.Commit &&
|
||||||
|
finding.Date == b.Date &&
|
||||||
|
finding.Description == b.Description &&
|
||||||
|
finding.Email == b.Email &&
|
||||||
|
finding.EndColumn == b.EndColumn &&
|
||||||
|
finding.EndLine == b.EndLine &&
|
||||||
|
finding.Entropy == b.Entropy &&
|
||||||
|
finding.File == b.File &&
|
||||||
|
// Omit checking finding.Fingerprint - if the format of the fingerprint changes, the users will see unexpected behaviour
|
||||||
|
finding.Match == b.Match &&
|
||||||
|
finding.Message == b.Message &&
|
||||||
|
finding.RuleID == b.RuleID &&
|
||||||
|
finding.Secret == b.Secret &&
|
||||||
|
finding.StartColumn == b.StartColumn &&
|
||||||
|
finding.StartLine == b.StartLine {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadBaseline(baselinePath string) ([]report.Finding, error) {
|
||||||
|
var previousFindings []report.Finding
|
||||||
|
jsonFile, err := os.Open(baselinePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not open %s", baselinePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if cerr := jsonFile.Close(); cerr != nil {
|
||||||
|
log.Warn().Err(cerr).Msg("problem closing jsonFile handle")
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
bytes, err := io.ReadAll(jsonFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not read data from the file %s", baselinePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(bytes, &previousFindings)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("the format of the file %s is not supported", baselinePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
return previousFindings, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
package detect
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/report"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsNew(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
findings report.Finding
|
||||||
|
baseline []report.Finding
|
||||||
|
expect bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
findings: report.Finding{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "0000",
|
||||||
|
},
|
||||||
|
baseline: []report.Finding{
|
||||||
|
{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "0000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
findings: report.Finding{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "0000",
|
||||||
|
},
|
||||||
|
baseline: []report.Finding{
|
||||||
|
{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "0002",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
findings: report.Finding{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "0000",
|
||||||
|
Tags: []string{"a", "b"},
|
||||||
|
},
|
||||||
|
baseline: []report.Finding{
|
||||||
|
{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "0000",
|
||||||
|
Tags: []string{"a", "c"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: false, // Updated tags doesn't make it a new finding
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range tests {
|
||||||
|
assert.Equal(t, test.expect, IsNew(test.findings, test.baseline))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFileLoadBaseline(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
Filename string
|
||||||
|
ExpectedError error
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
Filename: "../testdata/baseline/baseline.csv",
|
||||||
|
ExpectedError: errors.New("the format of the file ../testdata/baseline/baseline.csv is not supported"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Filename: "../testdata/baseline/baseline.sarif",
|
||||||
|
ExpectedError: errors.New("the format of the file ../testdata/baseline/baseline.sarif is not supported"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Filename: "../testdata/baseline/notfound.json",
|
||||||
|
ExpectedError: errors.New("could not open ../testdata/baseline/notfound.json"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
_, err := LoadBaseline(test.Filename)
|
||||||
|
assert.Equal(t, test.ExpectedError.Error(), err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIgnoreIssuesInBaseline(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
findings []report.Finding
|
||||||
|
baseline []report.Finding
|
||||||
|
expectCount int
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
findings: []report.Finding{
|
||||||
|
{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
baseline: []report.Finding{
|
||||||
|
{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectCount: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
findings: []report.Finding{
|
||||||
|
{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "5",
|
||||||
|
Fingerprint: "a",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
baseline: []report.Finding{
|
||||||
|
{
|
||||||
|
Author: "a",
|
||||||
|
Commit: "5",
|
||||||
|
Fingerprint: "b",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expectCount: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
d, _ := NewDetectorDefaultConfig()
|
||||||
|
d.baseline = test.baseline
|
||||||
|
for _, finding := range test.findings {
|
||||||
|
d.addFinding(finding)
|
||||||
|
}
|
||||||
|
assert.Equal(t, test.expectCount, len(d.findings))
|
||||||
|
}
|
||||||
|
}
|
||||||
+108
-8
@@ -4,19 +4,21 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/h2non/filetype"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
"github.com/zricethezav/gitleaks/v8/detect/git"
|
"github.com/zricethezav/gitleaks/v8/detect/git"
|
||||||
"github.com/zricethezav/gitleaks/v8/report"
|
"github.com/zricethezav/gitleaks/v8/report"
|
||||||
|
|
||||||
"github.com/fatih/semgroup"
|
"github.com/fatih/semgroup"
|
||||||
"github.com/gitleaks/go-gitdiff/gitdiff"
|
"github.com/gitleaks/go-gitdiff/gitdiff"
|
||||||
"github.com/h2non/filetype"
|
|
||||||
ahocorasick "github.com/petar-dambovaliev/aho-corasick"
|
ahocorasick "github.com/petar-dambovaliev/aho-corasick"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
@@ -49,6 +51,12 @@ type Detector struct {
|
|||||||
// verbose is a flag to print findings
|
// verbose is a flag to print findings
|
||||||
Verbose bool
|
Verbose bool
|
||||||
|
|
||||||
|
// files larger than this will be skipped
|
||||||
|
MaxTargetMegaBytes int
|
||||||
|
|
||||||
|
// followSymlinks is a flag to enable scanning symlink files
|
||||||
|
FollowSymlinks bool
|
||||||
|
|
||||||
// commitMap is used to keep track of commits that have been scanned.
|
// commitMap is used to keep track of commits that have been scanned.
|
||||||
// This is only used for logging purposes and git scans.
|
// This is only used for logging purposes and git scans.
|
||||||
commitMap map[string]bool
|
commitMap map[string]bool
|
||||||
@@ -66,6 +74,12 @@ type Detector struct {
|
|||||||
// matching given a set of words (keywords from the rules in the config)
|
// matching given a set of words (keywords from the rules in the config)
|
||||||
prefilter ahocorasick.AhoCorasick
|
prefilter ahocorasick.AhoCorasick
|
||||||
|
|
||||||
|
// a list of known findings that should be ignored
|
||||||
|
baseline []report.Finding
|
||||||
|
|
||||||
|
// path to baseline
|
||||||
|
baselinePath string
|
||||||
|
|
||||||
// gitleaksIgnore
|
// gitleaksIgnore
|
||||||
gitleaksIgnore map[string]bool
|
gitleaksIgnore map[string]bool
|
||||||
}
|
}
|
||||||
@@ -76,7 +90,8 @@ type Fragment struct {
|
|||||||
Raw string
|
Raw string
|
||||||
|
|
||||||
// FilePath is the path to the file if applicable
|
// FilePath is the path to the file if applicable
|
||||||
FilePath string
|
FilePath string
|
||||||
|
SymlinkFile string
|
||||||
|
|
||||||
// CommitSHA is the SHA of the commit if applicable
|
// CommitSHA is the SHA of the commit if applicable
|
||||||
CommitSHA string
|
CommitSHA string
|
||||||
@@ -145,6 +160,18 @@ func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Detector) AddBaseline(baselinePath string) error {
|
||||||
|
if baselinePath != "" {
|
||||||
|
baseline, err := LoadBaseline(baselinePath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.baseline = baseline
|
||||||
|
}
|
||||||
|
d.baselinePath = baselinePath
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// DetectBytes scans the given bytes and returns a list of findings
|
// DetectBytes scans the given bytes and returns a list of findings
|
||||||
func (d *Detector) DetectBytes(content []byte) []report.Finding {
|
func (d *Detector) DetectBytes(content []byte) []report.Finding {
|
||||||
return d.DetectString(string(content))
|
return d.DetectString(string(content))
|
||||||
@@ -173,6 +200,7 @@ func (d *Detector) detectRule(fragment Fragment, rule config.Rule) []report.Find
|
|||||||
finding := report.Finding{
|
finding := report.Finding{
|
||||||
Description: rule.Description,
|
Description: rule.Description,
|
||||||
File: fragment.FilePath,
|
File: fragment.FilePath,
|
||||||
|
SymlinkFile: fragment.SymlinkFile,
|
||||||
RuleID: rule.RuleID,
|
RuleID: rule.RuleID,
|
||||||
Match: fmt.Sprintf("file detected: %s", fragment.FilePath),
|
Match: fmt.Sprintf("file detected: %s", fragment.FilePath),
|
||||||
Tags: rule.Tags,
|
Tags: rule.Tags,
|
||||||
@@ -193,6 +221,15 @@ func (d *Detector) detectRule(fragment Fragment, rule config.Rule) []report.Find
|
|||||||
return findings
|
return findings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If flag configure and raw data size bigger then the flag
|
||||||
|
if d.MaxTargetMegaBytes > 0 {
|
||||||
|
rawLength := len(fragment.Raw) / 1000000
|
||||||
|
if rawLength > d.MaxTargetMegaBytes {
|
||||||
|
log.Debug().Msgf("skipping file: %s scan due to size: %d", fragment.FilePath, rawLength)
|
||||||
|
return findings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
matchIndices := rule.Regex.FindAllStringIndex(fragment.Raw, -1)
|
matchIndices := rule.Regex.FindAllStringIndex(fragment.Raw, -1)
|
||||||
for _, matchIndex := range matchIndices {
|
for _, matchIndex := range matchIndices {
|
||||||
// extract secret from match
|
// extract secret from match
|
||||||
@@ -211,6 +248,7 @@ func (d *Detector) detectRule(fragment Fragment, rule config.Rule) []report.Find
|
|||||||
finding := report.Finding{
|
finding := report.Finding{
|
||||||
Description: rule.Description,
|
Description: rule.Description,
|
||||||
File: fragment.FilePath,
|
File: fragment.FilePath,
|
||||||
|
SymlinkFile: fragment.SymlinkFile,
|
||||||
RuleID: rule.RuleID,
|
RuleID: rule.RuleID,
|
||||||
StartLine: loc.startLine,
|
StartLine: loc.startLine,
|
||||||
EndLine: loc.endLine,
|
EndLine: loc.endLine,
|
||||||
@@ -346,18 +384,24 @@ func (d *Detector) DetectGit(source string, logOpts string, gitScanType GitScanT
|
|||||||
if err := s.Wait(); err != nil {
|
if err := s.Wait(); err != nil {
|
||||||
return d.findings, err
|
return d.findings, err
|
||||||
}
|
}
|
||||||
log.Debug().Msgf("%d commits scanned. Note: this number might be smaller than expected due to commits with no additions", len(d.commitMap))
|
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")
|
||||||
if git.ErrEncountered {
|
if git.ErrEncountered {
|
||||||
return d.findings, fmt.Errorf("%s", "git error encountered, see logs")
|
return d.findings, fmt.Errorf("%s", "git error encountered, see logs")
|
||||||
}
|
}
|
||||||
return d.findings, nil
|
return d.findings, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type scanTarget struct {
|
||||||
|
Path string
|
||||||
|
Symlink string
|
||||||
|
}
|
||||||
|
|
||||||
// DetectFiles accepts a path to a source directory or file and begins a scan of the
|
// DetectFiles accepts a path to a source directory or file and begins a scan of the
|
||||||
// file or directory.
|
// file or directory.
|
||||||
func (d *Detector) DetectFiles(source string) ([]report.Finding, error) {
|
func (d *Detector) DetectFiles(source string) ([]report.Finding, error) {
|
||||||
s := semgroup.NewGroup(context.Background(), 4)
|
s := semgroup.NewGroup(context.Background(), 4)
|
||||||
paths := make(chan string)
|
paths := make(chan scanTarget)
|
||||||
s.Go(func() error {
|
s.Go(func() error {
|
||||||
defer close(paths)
|
defer close(paths)
|
||||||
return filepath.Walk(source,
|
return filepath.Walk(source,
|
||||||
@@ -372,7 +416,25 @@ func (d *Detector) DetectFiles(source string) ([]report.Finding, error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if fInfo.Mode().IsRegular() {
|
if fInfo.Mode().IsRegular() {
|
||||||
paths <- path
|
paths <- scanTarget{
|
||||||
|
Path: path,
|
||||||
|
Symlink: "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if fInfo.Mode().Type() == fs.ModeSymlink && d.FollowSymlinks {
|
||||||
|
realPath, err := filepath.EvalSymlinks(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
realPathFileInfo, _ := os.Stat(realPath)
|
||||||
|
if realPathFileInfo.IsDir() {
|
||||||
|
log.Debug().Msgf("found symlinked directory: %s -> %s [skipping]", path, realPath)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
paths <- scanTarget{
|
||||||
|
Path: realPath,
|
||||||
|
Symlink: path,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -380,7 +442,7 @@ func (d *Detector) DetectFiles(source string) ([]report.Finding, error) {
|
|||||||
for pa := range paths {
|
for pa := range paths {
|
||||||
p := pa
|
p := pa
|
||||||
s.Go(func() error {
|
s.Go(func() error {
|
||||||
b, err := os.ReadFile(p)
|
b, err := os.ReadFile(p.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -395,7 +457,10 @@ func (d *Detector) DetectFiles(source string) ([]report.Finding, error) {
|
|||||||
|
|
||||||
fragment := Fragment{
|
fragment := Fragment{
|
||||||
Raw: string(b),
|
Raw: string(b),
|
||||||
FilePath: p,
|
FilePath: p.Path,
|
||||||
|
}
|
||||||
|
if p.Symlink != "" {
|
||||||
|
fragment.SymlinkFile = p.Symlink
|
||||||
}
|
}
|
||||||
for _, finding := range d.Detect(fragment) {
|
for _, finding := range d.Detect(fragment) {
|
||||||
// need to add 1 since line counting starts at 1
|
// need to add 1 since line counting starts at 1
|
||||||
@@ -415,6 +480,36 @@ func (d *Detector) DetectFiles(source string) ([]report.Finding, error) {
|
|||||||
return d.findings, nil
|
return d.findings, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
findings := []report.Finding{}
|
||||||
|
|
||||||
|
for {
|
||||||
|
n, err := reader.Read(buf[:cap(buf)])
|
||||||
|
buf = buf[:n]
|
||||||
|
if err != nil {
|
||||||
|
if err != io.EOF {
|
||||||
|
return findings, err
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment := Fragment{
|
||||||
|
Raw: string(buf),
|
||||||
|
}
|
||||||
|
for _, finding := range d.Detect(fragment) {
|
||||||
|
findings = append(findings, finding)
|
||||||
|
if d.Verbose {
|
||||||
|
printFinding(finding)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return findings, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Detect scans the given fragment and returns a list of findings
|
// Detect scans the given fragment and returns a list of findings
|
||||||
func (d *Detector) Detect(fragment Fragment) []report.Finding {
|
func (d *Detector) Detect(fragment Fragment) []report.Finding {
|
||||||
var findings []report.Finding
|
var findings []report.Finding
|
||||||
@@ -424,7 +519,7 @@ func (d *Detector) Detect(fragment Fragment) []report.Finding {
|
|||||||
|
|
||||||
// check if filepath is allowed
|
// check if filepath is allowed
|
||||||
if fragment.FilePath != "" && (d.Config.Allowlist.PathAllowed(fragment.FilePath) ||
|
if fragment.FilePath != "" && (d.Config.Allowlist.PathAllowed(fragment.FilePath) ||
|
||||||
fragment.FilePath == d.Config.Path) {
|
fragment.FilePath == d.Config.Path || (d.baselinePath != "" && fragment.FilePath == d.baselinePath)) {
|
||||||
return findings
|
return findings
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,6 +568,11 @@ func (d *Detector) addFinding(finding report.Finding) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.baseline != nil && !IsNew(finding, d.baseline) {
|
||||||
|
log.Debug().Msgf("baseline duplicate -- ignoring finding with Fingerprint %s", finding.Fingerprint)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
d.findingMutex.Lock()
|
d.findingMutex.Lock()
|
||||||
d.findings = append(d.findings, finding)
|
d.findings = append(d.findings, finding)
|
||||||
if d.Verbose {
|
if d.Verbose {
|
||||||
|
|||||||
+58
-1
@@ -470,7 +470,7 @@ func TestFromGit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFromGit tests the FromGit function
|
// TestFromFiles tests the FromFiles function
|
||||||
func TestFromFiles(t *testing.T) {
|
func TestFromFiles(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
cfgName string
|
cfgName string
|
||||||
@@ -491,6 +491,7 @@ func TestFromFiles(t *testing.T) {
|
|||||||
Secret: "AKIALALEMEL33243OLIA",
|
Secret: "AKIALALEMEL33243OLIA",
|
||||||
Line: "\n\tawsToken := \"AKIALALEMEL33243OLIA\"",
|
Line: "\n\tawsToken := \"AKIALALEMEL33243OLIA\"",
|
||||||
File: "../testdata/repos/nogit/main.go",
|
File: "../testdata/repos/nogit/main.go",
|
||||||
|
SymlinkFile: "",
|
||||||
RuleID: "aws-access-key",
|
RuleID: "aws-access-key",
|
||||||
Tags: []string{"key", "AWS"},
|
Tags: []string{"key", "AWS"},
|
||||||
Entropy: 3.0841837,
|
Entropy: 3.0841837,
|
||||||
@@ -537,6 +538,7 @@ func TestFromFiles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
cfg, _ := vc.Translate()
|
cfg, _ := vc.Translate()
|
||||||
detector := NewDetector(cfg)
|
detector := NewDetector(cfg)
|
||||||
|
detector.FollowSymlinks = true
|
||||||
findings, err := detector.DetectFiles(tt.source)
|
findings, err := detector.DetectFiles(tt.source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
@@ -546,6 +548,61 @@ func TestFromFiles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDetectWithSymlinks(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
cfgName string
|
||||||
|
source string
|
||||||
|
expectedFindings []report.Finding
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
source: filepath.Join(repoBasePath, "symlinks/file_symlink"),
|
||||||
|
cfgName: "simple",
|
||||||
|
expectedFindings: []report.Finding{
|
||||||
|
{
|
||||||
|
Description: "Asymmetric Private Key",
|
||||||
|
StartLine: 1,
|
||||||
|
EndLine: 1,
|
||||||
|
StartColumn: 1,
|
||||||
|
EndColumn: 35,
|
||||||
|
Match: "-----BEGIN OPENSSH PRIVATE KEY-----",
|
||||||
|
Secret: "-----BEGIN OPENSSH PRIVATE KEY-----",
|
||||||
|
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",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
viper.AddConfigPath(configPath)
|
||||||
|
viper.SetConfigName("simple")
|
||||||
|
viper.SetConfigType("toml")
|
||||||
|
err := viper.ReadInConfig()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var vc config.ViperConfig
|
||||||
|
err = viper.Unmarshal(&vc)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
cfg, _ := vc.Translate()
|
||||||
|
detector := NewDetector(cfg)
|
||||||
|
detector.FollowSymlinks = true
|
||||||
|
findings, err := detector.DetectFiles(tt.source)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
assert.ElementsMatch(t, tt.expectedFindings, findings)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func moveDotGit(from, to string) error {
|
func moveDotGit(from, to string) error {
|
||||||
repoDirs, err := os.ReadDir("../testdata/repos")
|
repoDirs, err := os.ReadDir("../testdata/repos")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -131,6 +131,10 @@ func printFinding(f report.Finding) {
|
|||||||
fmt.Printf("%-12s %s\n", "Secret:", secret)
|
fmt.Printf("%-12s %s\n", "Secret:", secret)
|
||||||
fmt.Printf("%-12s %s\n", "RuleID:", f.RuleID)
|
fmt.Printf("%-12s %s\n", "RuleID:", f.RuleID)
|
||||||
fmt.Printf("%-12s %f\n", "Entropy:", f.Entropy)
|
fmt.Printf("%-12s %f\n", "Entropy:", f.Entropy)
|
||||||
|
if f.File == "" {
|
||||||
|
fmt.Println("")
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Printf("%-12s %s\n", "File:", f.File)
|
fmt.Printf("%-12s %s\n", "File:", f.File)
|
||||||
fmt.Printf("%-12s %d\n", "Line:", f.StartLine)
|
fmt.Printf("%-12s %d\n", "Line:", f.StartLine)
|
||||||
if f.Commit == "" {
|
if f.Commit == "" {
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
module github.com/zricethezav/gitleaks/v8
|
module github.com/zricethezav/gitleaks/v8
|
||||||
|
|
||||||
go 1.17
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/charmbracelet/lipgloss v0.5.0
|
||||||
github.com/fatih/semgroup v1.2.0
|
github.com/fatih/semgroup v1.2.0
|
||||||
github.com/gitleaks/go-gitdiff v0.8.0
|
github.com/gitleaks/go-gitdiff v0.8.0
|
||||||
github.com/h2non/filetype v1.1.3
|
github.com/h2non/filetype v1.1.3
|
||||||
@@ -13,7 +14,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/charmbracelet/lipgloss v0.5.0 // indirect
|
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ func writeCsv(f []Finding, w io.WriteCloser) error {
|
|||||||
err := cw.Write([]string{"RuleID",
|
err := cw.Write([]string{"RuleID",
|
||||||
"Commit",
|
"Commit",
|
||||||
"File",
|
"File",
|
||||||
|
"SymlinkFile",
|
||||||
"Secret",
|
"Secret",
|
||||||
"Match",
|
"Match",
|
||||||
"StartLine",
|
"StartLine",
|
||||||
@@ -35,6 +36,7 @@ func writeCsv(f []Finding, w io.WriteCloser) error {
|
|||||||
err = cw.Write([]string{f.RuleID,
|
err = cw.Write([]string{f.RuleID,
|
||||||
f.Commit,
|
f.Commit,
|
||||||
f.File,
|
f.File,
|
||||||
|
f.SymlinkFile,
|
||||||
f.Secret,
|
f.Secret,
|
||||||
f.Match,
|
f.Match,
|
||||||
strconv.Itoa(f.StartLine),
|
strconv.Itoa(f.StartLine),
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func TestWriteCSV(t *testing.T) {
|
|||||||
EndColumn: 2,
|
EndColumn: 2,
|
||||||
Message: "opps",
|
Message: "opps",
|
||||||
File: "auth.py",
|
File: "auth.py",
|
||||||
|
SymlinkFile: "",
|
||||||
Commit: "0000000000000000",
|
Commit: "0000000000000000",
|
||||||
Author: "John Doe",
|
Author: "John Doe",
|
||||||
Email: "johndoe@gmail.com",
|
Email: "johndoe@gmail.com",
|
||||||
|
|||||||
+3
-3
@@ -22,9 +22,9 @@ type Finding struct {
|
|||||||
Secret string
|
Secret string
|
||||||
|
|
||||||
// File is the name of the file containing the finding
|
// File is the name of the file containing the finding
|
||||||
File string
|
File string
|
||||||
|
SymlinkFile string
|
||||||
Commit string
|
Commit string
|
||||||
|
|
||||||
// Entropy is the shannon entropy of Value
|
// Entropy is the shannon entropy of Value
|
||||||
Entropy float32
|
Entropy float32
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ func TestWriteJSON(t *testing.T) {
|
|||||||
EndColumn: 2,
|
EndColumn: 2,
|
||||||
Message: "opps",
|
Message: "opps",
|
||||||
File: "auth.py",
|
File: "auth.py",
|
||||||
|
SymlinkFile: "",
|
||||||
Commit: "0000000000000000",
|
Commit: "0000000000000000",
|
||||||
Author: "John Doe",
|
Author: "John Doe",
|
||||||
Email: "johndoe@gmail.com",
|
Email: "johndoe@gmail.com",
|
||||||
|
|||||||
+5
-1
@@ -109,11 +109,15 @@ func getResults(findings []Finding) []Results {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getLocation(f Finding) []Locations {
|
func getLocation(f Finding) []Locations {
|
||||||
|
uri := f.File
|
||||||
|
if f.SymlinkFile != "" {
|
||||||
|
uri = f.SymlinkFile
|
||||||
|
}
|
||||||
return []Locations{
|
return []Locations{
|
||||||
{
|
{
|
||||||
PhysicalLocation: PhysicalLocation{
|
PhysicalLocation: PhysicalLocation{
|
||||||
ArtifactLocation: ArtifactLocation{
|
ArtifactLocation: ArtifactLocation{
|
||||||
URI: f.File,
|
URI: uri,
|
||||||
},
|
},
|
||||||
Region: Region{
|
Region: Region{
|
||||||
StartLine: f.StartLine,
|
StartLine: f.StartLine,
|
||||||
|
|||||||
Vendored
+2
@@ -0,0 +1,2 @@
|
|||||||
|
RuleID,Commit,File,Secret,Match,StartLine,EndLine,StartColumn,EndColumn,Author,Message,Date,Email,Fingerprint
|
||||||
|
1,b,c,f,s,m,s,e,s,e,a,m,f,r,f
|
||||||
|
Vendored
+40
@@ -0,0 +1,40 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Description": "PyPI upload token",
|
||||||
|
"StartLine": 32,
|
||||||
|
"EndLine": 32,
|
||||||
|
"StartColumn": 21,
|
||||||
|
"EndColumn": 106,
|
||||||
|
"Match": "************************",
|
||||||
|
"Secret": "************************",
|
||||||
|
"File": "detect/detect_test.go",
|
||||||
|
"Commit": "9326f35380636bcbe61e94b0584d1618c4b5c2c2",
|
||||||
|
"Entropy": 1.9606875,
|
||||||
|
"Author": "****",
|
||||||
|
"Email": "****",
|
||||||
|
"Date": "2022-03-07T14:33:06Z",
|
||||||
|
"Message": "Escape - character in regex character groups (#802)\n\n* fix char escape\n\n* add test\n\n* fix verbosity in make test",
|
||||||
|
"Tags": [],
|
||||||
|
"RuleID": "pypi-upload-token",
|
||||||
|
"Fingerprint": "9326f35380636bcbe61e94b0584d1618c4b5c2c2:detect/detect_test.go:pypi-upload-token:32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "PyPI upload token",
|
||||||
|
"StartLine": 33,
|
||||||
|
"EndLine": 33,
|
||||||
|
"StartColumn": 21,
|
||||||
|
"EndColumn": 106,
|
||||||
|
"Match": "************************",
|
||||||
|
"Secret": "************************",
|
||||||
|
"File": "detect/detect_test.go",
|
||||||
|
"Commit": "9326f35380636bcbe61e94b0584d1618c4b5c2c2",
|
||||||
|
"Entropy": 1.9606875,
|
||||||
|
"Author": "****",
|
||||||
|
"Email": "****",
|
||||||
|
"Date": "2022-03-07T14:33:06Z",
|
||||||
|
"Message": "Escape - character in regex character groups (#802)\n\n* fix char escape\n\n* add test\n\n* fix verbosity in make test",
|
||||||
|
"Tags": [],
|
||||||
|
"RuleID": "pypi-upload-token",
|
||||||
|
"Fingerprint": "9326f35380636bcbe61e94b0584d1618c4b5c2c2:detect/detect_test.go:pypi-upload-token:33"
|
||||||
|
}
|
||||||
|
]
|
||||||
Vendored
+6
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json",
|
||||||
|
"version": "2.1.0",
|
||||||
|
"runs": [
|
||||||
|
]
|
||||||
|
}
|
||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
RuleID,Commit,File,Secret,Match,StartLine,EndLine,StartColumn,EndColumn,Author,Message,Date,Email,Fingerprint
|
RuleID,Commit,File,SymlinkFile,Secret,Match,StartLine,EndLine,StartColumn,EndColumn,Author,Message,Date,Email,Fingerprint
|
||||||
test-rule,0000000000000000,auth.py,a secret,line containing secret,1,2,1,2,John Doe,opps,10-19-2003,johndoe@gmail.com,fingerprint
|
test-rule,0000000000000000,auth.py,,a secret,line containing secret,1,2,1,2,John Doe,opps,10-19-2003,johndoe@gmail.com,fingerprint
|
||||||
|
+1
@@ -8,6 +8,7 @@
|
|||||||
"Match": "line containing secret",
|
"Match": "line containing secret",
|
||||||
"Secret": "a secret",
|
"Secret": "a secret",
|
||||||
"File": "auth.py",
|
"File": "auth.py",
|
||||||
|
"SymlinkFile": "",
|
||||||
"Commit": "0000000000000000",
|
"Commit": "0000000000000000",
|
||||||
"Entropy": 0,
|
"Entropy": 0,
|
||||||
"Author": "John Doe",
|
"Author": "John Doe",
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../source_file/id_ed25519
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||||
|
QyNTUxOQAAACA8YWKYztuuvxUIMomc3zv0OdXCT57Cc2cRYu3TMbX9XAAAAJDiKO3C4ijt
|
||||||
|
wgAAAAtzc2gtZWQyNTUxOQAAACA8YWKYztuuvxUIMomc3zv0OdXCT57Cc2cRYu3TMbX9XA
|
||||||
|
AAAECzmj8DGxg5YHtBK4AmBttMXDQHsPAaCyYHQjJ4YujRBTxhYpjO266/FQgyiZzfO/Q5
|
||||||
|
1cJPnsJzZxFi7dMxtf1cAAAADHJvb3RAZGV2aG9zdAE=
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
Reference in new issue
Block a user