Find a file
roxanne-tampus 024c847f83
Added braintreepayments detector (#541)
* added braintreepayments detector

* updated condition based on suggestion

* enhancements

* enhancement

* enhancement for valid response
2022-08-25 10:34:53 -07:00
.github ci improvements 2022-05-23 21:13:32 -07:00
hack Fix link typo in Adding_Detectors_external.md (#528) 2022-05-07 16:17:37 -07:00
pkg Added braintreepayments detector (#541) 2022-08-25 10:34:53 -07:00
proto Add Honeycomb detector (#687) 2022-08-24 16:50:31 -07:00
scripts 21 new detectors (#347) 2022-04-08 16:07:39 -07:00
.gitattributes Adding detectors (#46) 2022-03-04 08:39:22 -08:00
.gitignore [THOG-315] Replace bytes.buffer with strings.builder. (#533) 2022-05-09 17:02:46 -07:00
.goreleaser.yml Fix goreleaser dockerfile (#691) 2022-08-03 13:56:44 -07:00
action.yml Update github action to support generic cli command input (#670) 2022-08-01 15:05:08 -07:00
CODE_OF_CONDUCT.md Initial docs and release automation (#5) 2022-01-18 16:59:18 -08:00
CODEOWNERS Add codeowners file (#653) 2022-07-12 18:06:35 -07:00
CONTRIBUTING.md Add more contributing docs 2022-04-03 22:48:43 -07:00
Dockerfile Copy entrypoint changes into goreleaser Dockerfile build to fix github action (#686) 2022-08-02 12:50:26 -07:00
Dockerfile.goreleaser Copy entrypoint changes into goreleaser Dockerfile build to fix github action (#686) 2022-08-02 12:50:26 -07:00
entrypoint.sh Update github action to support generic cli command input (#670) 2022-08-01 15:05:08 -07:00
go.mod Bump github.com/xanzy/go-gitlab from 0.69.0 to 0.73.1 (#730) 2022-08-23 16:38:05 -07:00
go.sum Bump github.com/xanzy/go-gitlab from 0.69.0 to 0.73.1 (#730) 2022-08-23 16:38:05 -07:00
LICENSE Add license 2022-01-12 08:56:33 -08:00
main.go Add ssh:/ URI to docs (#732) 2022-08-23 23:26:09 -07:00
Makefile Fix goreleaser dockerfile (#691) 2022-08-03 13:56:44 -07:00
README.md Add ssh:/ URI to docs (#732) 2022-08-23 23:26:09 -07:00
SECURITY.md Initial docs and release automation (#5) 2022-01-18 16:59:18 -08:00

GoReleaser Logo

TruffleHog

Find leaked credentials.


CI Status Go Report Card License Total Detectors


Join The Slack

Have questions? Feedback? Jump in slack and hang out with us

https://join.slack.com/t/trufflehog-community/shared_invite/zt-pw2qbi43-Aa86hkiimstfdKH9UCpPzQ

Demo

GitHub scanning demo

docker run -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --org=trufflesecurity

What's new in v3?

TruffleHog v3 is a complete rewrite in Go with many new powerful features.

  • We've added over 700 credential detectors that support active verification against their respective APIs.
  • We've also added native support for scanning GitHub, GitLab, filesystems, and S3.
  • Instantly verify private keys against millions of github users and billions of TLS certificates using our Driftwood technology.

What is credential verification?

For every potential credential that is detected, we've painstakingly implemented programatic verification against the API that we think it belongs to. Verification eliminates false positives. For example, the AWS credential detector performs a GetCallerIdentity API call against the AWS API to verify if an AWS credential is active.

Installation

Several options:

1. Go

git clone https://github.com/trufflesecurity/trufflehog.git

cd trufflehog; go install

2. Release binaries

3. Docker

Note: Apple M1 hardware users should run with docker run --platform linux/arm64 for better performance.

Most users

docker run -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys

Apple M1 users

The linux/arm64 image is better to run on the M1 than the amd64 image. Even better is running the native darwin binary avilable, but there is not container image for that.

docker run --platform linux/arm64 -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --repo https://github.com/trufflesecurity/test_keys 

4. Pip (help wanted)

It's possible to distribute binaries in pip wheels.

Here is an example of a project that does it.

Help with setting up this packaging would be appreciated!

5. Brew

brew tap trufflesecurity/trufflehog
brew install trufflehog

Usage

TruffleHog has a sub-command for each source of data that you may want to scan:

  • git
  • github
  • gitlab
  • S3
  • filesystem
  • syslog
  • file and stdin (coming soon)

Each subcommand can have options that you can see with the -h flag provided to the sub command:

$ trufflehog git --help
usage: TruffleHog git [<flags>] <uri>

Find credentials in git repositories.

Flags:
      --help                     Show context-sensitive help (also try --help-long and --help-man).
      --debug                    Run in debug mode
      --version                  Prints trufflehog version.
  -j, --json                     Output in JSON format.
      --json-legacy              Use the pre-v3.0 JSON format. Only works with git, gitlab, and github sources.
      --concurrency=1            Number of concurrent workers.
      --no-verification          Don't verify the results.
      --only-verified            Only output verified results.
      --print-avg-detector-time  Print the average time spent on each detector.
      --no-update                Don't check for updates.
  -i, --include-paths=INCLUDE-PATHS
                                 Path to file with newline separated regexes for files to include in scan.
  -x, --exclude-paths=EXCLUDE-PATHS
                                 Path to file with newline separated regexes for files to exclude in scan.
      --since-commit=SINCE-COMMIT
                                 Commit to start scan from.
      --branch=BRANCH            Branch to scan.
      --max-depth=MAX-DEPTH      Maximum depth of commits to scan.
      --allow                    No-op flag for backwards compat.
      --entropy                  No-op flag for backwards compat.
      --regex                    No-op flag for backwards compat.

Args:
  <uri>  Git repository URL. https://, file://, or ssh:// schema expected.

For example, to scan a git repository, start with

$ trufflehog git https://github.com/trufflesecurity/trufflehog.git

Exit Codes:

  • 0: No errors and no results were found.
  • 1: An error was encountered. Sources may not have completed scans.
  • 183: No errors were encountered, but results were found. Will only be returned if --fail flag is used.

Scanning an organization

Try scanning an entire GitHub organization with the following:

docker run -it -v "$PWD:/pwd" trufflesecurity/trufflehog:latest github --org=trufflesecurity

TruffleHog OSS Github Action

- name: TruffleHog OSS
  uses: trufflesecurity/trufflehog@main
  with:
    # Repository path
    path: 
    # Start scanning from here (usually main branch).
    base: 
    # Scan commits until here (usually dev branch).
    head: # optional
    # Extra args to be passed to the trufflehog cli.
    extra_args: # optional

The TruffleHog OSS Github Action can be used to scan a range of commits for leaked credentials. The action will fail if any results are found.

For example, to scan the contents of pull requests you could use the following workflow:

name: Leaked Secrets Scan
on: [pull_request]
jobs:
  TruffleHog:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: TruffleHog OSS
        uses: trufflesecurity/trufflehog@v3.4.3
        with:
          path: ./
          base: ${{ github.event.repository.default_branch }}
          head: HEAD
          extra_args: --debug

Precommit Hook

Trufflehog can be used in a precommit hook to prevent credentials from leaking before they ever leave your computer. An example .pre-commit-config.yaml is provided (see pre-commit.com for installation).

repos:
- repo: local
  hooks:
    - id: trufflehog
      name: TruffleHog
      description: Detect secrets in your data.
      entry: bash -c 'trufflehog git file://. --only-verified --fail'
      # For running trufflehog in docker, use the following entry instead:
      # entry: bash -c 'docker run -v "$(pwd):/workdir" -i --rm trufflesecurity/trufflehog:latest git file:///workdir --only-verified --fail'
      language: system
      stages: ["commit", "push"]

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Contributing

Contributions are very welcome! Please see our contribution guidelines first.

We no longer accept contributions to TruffleHog v2, but that code is available in the v2 branch.

Adding new secret detectors

We have published some documentation and tooling to get started on adding new secret detectors. Let's improve detection together!

License Change

Since v3.0, TruffleHog is released under a AGPL 3 license, included in LICENSE. TruffleHog v3.0 uses none of the previous codebase, but care was taken to preserve backwards compatibility on the command line interface. The work previous to this release is still available licensed under GPL 2.0 in the history of this repository and the previous package releases and tags. A completed CLA is required for us to accept contributions going forward.