Skip to content

Commit 64137fa

Browse files
committed
feat: Support archived repo exclusion from GH org scans
1 parent 47e7b7c commit 64137fa

10 files changed

Lines changed: 710 additions & 510 deletions

File tree

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,13 @@ Timestamp: 2022-06-16 10:17:40 -0700 PDT
212212
trufflehog github --org=trufflesecurity --results=verified
213213
```
214214

215-
## 3: Scan a GitHub Repo for only verified secrets and get JSON output
215+
## 3: Scan a GitHub Org excluding archived repositories
216+
217+
```bash
218+
trufflehog github --org=trufflesecurity --exclude-archived
219+
```
220+
221+
## 4: Scan a GitHub Repo for only verified secrets and get JSON output
216222

217223
Command:
218224

@@ -227,37 +233,37 @@ Expected output:
227233
...
228234
```
229235

230-
## 4: Scan a GitHub Repo + its Issues and Pull Requests
236+
## 5: Scan a GitHub Repo + its Issues and Pull Requests
231237

232238
```bash
233239
trufflehog github --repo=https://github.com/trufflesecurity/test_keys --issue-comments --pr-comments
234240
```
235241

236-
## 5: Scan an S3 bucket for high-confidence results (verified + unknown)
242+
## 6: Scan an S3 bucket for high-confidence results (verified + unknown)
237243

238244
```bash
239245
trufflehog s3 --bucket=<bucket name> --results=verified,unknown
240246
```
241247

242-
## 6: Scan S3 buckets using IAM Roles
248+
## 7: Scan S3 buckets using IAM Roles
243249

244250
```bash
245251
trufflehog s3 --role-arn=<iam role arn>
246252
```
247253

248-
## 7: Scan a Github Repo using SSH authentication in Docker
254+
## 8: Scan a Github Repo using SSH authentication in Docker
249255

250256
```bash
251257
docker run --rm -v "$HOME/.ssh:/root/.ssh:ro" trufflesecurity/trufflehog:latest git ssh://github.com/trufflesecurity/test_keys
252258
```
253259

254-
## 8: Scan individual files or directories
260+
## 9: Scan individual files or directories
255261

256262
```bash
257263
trufflehog filesystem path/to/file1.txt path/to/file2.txt path/to/dir
258264
```
259265

260-
## 9: Scan a local git repo
266+
## 10: Scan a local git repo
261267

262268
Clone the git repo. For example [test keys]([email protected]:trufflesecurity/test_keys.git) repo.
263269
```bash
@@ -271,13 +277,13 @@ trufflehog git file://test_keys --results=verified,unknown
271277

272278
To guard against malicious git configs in local scanning (see CVE-2025-41390), TruffleHog clones local git repositories to a temporary directory prior to scanning. This follows [Git's security best practices](https://git-scm.com/docs/git#_security). If you want to specify a custom path to clone the repository to (instead of tmp), you can use the `--clone-path` flag. If you'd like to skip the local cloning process and scan the repository directly (only do this for trusted repos), you can use the `--trust-local-git-config` flag.
273279

274-
## 10: Scan GCS buckets for only verified secrets
280+
## 11: Scan GCS buckets for only verified secrets
275281

276282
```bash
277283
trufflehog gcs --project-id=<project-ID> --cloud-environment --results=verified
278284
```
279285

280-
## 11: Scan a Docker image for only verified secrets
286+
## 12: Scan a Docker image for only verified secrets
281287

282288
Use the `--image` flag multiple times to scan multiple images.
283289

@@ -292,29 +298,29 @@ trufflehog docker --image docker://new_image:tag --results=verified
292298
trufflehog docker --image file://path_to_image.tar --results=verified
293299
```
294300

295-
## 12: Scan in CI
301+
## 13: Scan in CI
296302

297303
Set the `--since-commit` flag to your default branch that people merge into (ex: "main"). Set the `--branch` flag to your PR's branch name (ex: "feature-1"). Depending on the CI/CD platform you use, this value can be pulled in dynamically (ex: [CIRCLE_BRANCH in Circle CI](https://circleci.com/docs/variables/) and [TRAVIS_PULL_REQUEST_BRANCH in Travis CI](https://docs.travis-ci.com/user/environment-variables/)). If the repo is cloned and the target branch is already checked out during the CI/CD workflow, then `--branch HEAD` should be sufficient. The `--fail` flag will return an 183 error code if valid credentials are found.
298304

299305
```bash
300306
trufflehog git file://. --since-commit main --branch feature-1 --results=verified,unknown --fail
301307
```
302308

303-
## 13: Scan a Postman workspace
309+
## 14: Scan a Postman workspace
304310

305311
Use the `--workspace-id`, `--collection-id`, `--environment` flags multiple times to scan multiple targets.
306312

307313
```bash
308314
trufflehog postman --token=<postman api token> --workspace-id=<workspace id>
309315
```
310316

311-
## 14: Scan a Jenkins server
317+
## 15: Scan a Jenkins server
312318

313319
```bash
314320
trufflehog jenkins --url https://jenkins.example.com --username admin --password admin
315321
```
316322

317-
## 15: Scan an Elasticsearch server
323+
## 16: Scan an Elasticsearch server
318324

319325
### Scan a Local Cluster
320326

@@ -342,7 +348,7 @@ trufflehog elasticsearch \
342348
--api-key 'MlVtVjBZ...ZSYlduYnF1djh3NG5FQQ=='
343349
```
344350

345-
## 16. Scan a GitHub Repository for Cross Fork Object References and Deleted Commits
351+
## 17. Scan a GitHub Repository for Cross Fork Object References and Deleted Commits
346352

347353
The following command will enumerate deleted and hidden commits on a GitHub repository and then scan them for secrets. This is an alpha release feature.
348354

@@ -356,7 +362,7 @@ In addition to the normal TruffleHog output, the `--object-discovery` flag creat
356362

357363
For more information on Cross Fork Object References, please [read our blog post](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github).
358364

359-
## 17. Scan Hugging Face
365+
## 18. Scan Hugging Face
360366

361367
### Scan a Hugging Face Model, Dataset or Space
362368

@@ -378,7 +384,7 @@ trufflehog huggingface --org <orgname> --user <username>
378384
trufflehog huggingface --model <model_id> --include-discussions --include-prs
379385
```
380386

381-
## 18. Scan stdin Input
387+
## 19. Scan stdin Input
382388

383389
```bash
384390
aws s3 cp s3://example/gzipped/data.gz - | gunzip -c | trufflehog stdin

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ var (
129129
githubClonePath = githubScan.Flag("clone-path", "Custom path where the repository should be cloned (default: temp dir).").String()
130130
githubNoCleanup = githubScan.Flag("no-cleanup", "Do not delete cloned repositories after scanning (can only be used with --clone-path).").Bool()
131131
githubIgnoreGists = githubScan.Flag("ignore-gists", "Ignore all gists in scan.").Bool()
132+
githubExcludeArchived = githubScan.Flag("exclude-archived", "Exclude archived repositories from scan.").Bool()
132133

133134
// GitHub Cross Fork Object Reference Experimental Feature
134135
githubExperimentalScan = cli.Command("github-experimental", "Run an experimental GitHub scan. Must specify at least one experimental sub-module to run: object-discovery.")
@@ -869,6 +870,7 @@ func runSingleScan(ctx context.Context, cmd string, cfg engine.Config) (metrics,
869870
ClonePath: *githubClonePath,
870871
NoCleanup: *githubNoCleanup,
871872
IgnoreGists: *githubIgnoreGists,
873+
ExcludeArchived: *githubExcludeArchived,
872874
PrintLegacyJSON: *jsonLegacy,
873875
}
874876

pkg/engine/github.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func (e *Engine) ScanGitHub(ctx context.Context, c sources.GithubConfig) (source
3232
ClonePath: c.ClonePath,
3333
NoCleanup: c.NoCleanup,
3434
IgnoreGists: c.IgnoreGists,
35+
ExcludeArchived: c.ExcludeArchived,
3536
PrintLegacyJson: c.PrintLegacyJSON,
3637
}
3738

0 commit comments

Comments
 (0)