Scan data for secrets

GitHub

9min

Configuration options

Source integration to GitHub, the developer platform.



Local configuration

The GitHub integration supports using the following:

  1. Bearer token
  2. GitHub app authentication

Personal Access Tokens (classic) should be created with the following scopes: repo, gist, and read:org. (Fine-grained tokens are not supported.)

Access token


GitHub app authentication configuration

You may create/register a GitHub app to utilize TruffleHog. It is possible to use a single Github app to scan repos in multiple accounts/organizations as long as the app is installed on all of those accounts. To run a locally-configured scan using a GitHub app, there are three steps:

  1. Create/register a new Github app
  2. Install the GitHub app on the account(s)
  3. Add a source configuration using the new GitHub app to your local configuration file

You will need to configure a separate TruffleHog source integration for each account/organization you wish to scan with your app.

Below are the steps to create/register a new GitHub app.

  1. Sign in to GitHub
  2. In the upper-right corner, click your profile photo
  3. Navigate to your account settings
    • For an app owned by a personal account, click ⚙️Settings
    • For an app owned by an organization:
      • Click Your organizations
      • To the right of the organization, click ⚙️Settings
  4. In the left sidebar, click <> Developer settings
  5. Click New GitHub App
  6. Under "GitHub App name", enter a name for your app. For example, TruffleHog-scanner-app
  7. Under "Homepage URL", enter your instance URL: https://<myorgnamespace>.c1.prod.trufflehog.org
  8. Make sure that Active is selected under "Webhook"
  9. Under "Webhook URL", enter the following webhook proxy URL: https://<myorgnamespace>.c1.prod.trufflehog.org/sources/github/webhook
  10. Under "Permissions"
    • Under "Repository permissions" next to
      • "Contents" select Read-only access permission
      • "Metadata (mandatory)" select Read-only access permission
      • "Webhooks" select Read-and-write access permissions
    • Under "Organization permissions" next to
      • "Members" select Read-only access permission
      • "Webhooks" select Read-and-write access permissions
    • Under "Account permissions"
      • "Gists" select Read-and-write access permissions
  11. Under "Where can this GitHub App be installed?", select:
    • Only on this account if you want to allow this GitHub App to only be installed on the account that you are using to create the app
    • Any account if you are going to allow this GitHub App to be installed on any user or organization
  12. Click Create GitHub App
  13. After the GitHub app is created/registered successfully you need to generate a new private key for your app from Settings > Developer settings > GitHub Apps > About > Private keys > "Generate a private key". Keep in mind you can always come back here in the future and generate a new private key for your app. If you are installing the app on multiple accounts you can use a single key for all of them.
  14. Navigate to Settings / Developer settings / GitHub Apps and select your app
  15. Under About, find your AppID
Document image


Next, you need to install your app. Below are the steps to install your new GitHub app.

  1. From Developer settings navigate to GitHub Apps and select your app
  2. On the left hand panel, under General click on Install App
  3. Click on Install
  4. Make sure the All repositories option is selected
  5. Double check the permissions and click on Install
  6. If you navigate to Settings, under Integrations, click on Applications, you should see the new app under the Installed GitHub Apps list
  7. From the Developer settings page click on the app from the list of your GitHub Apps, under General, click on Install App
  8. Click on ⚙️ on the right hand side of the account for which you installed the app, check the URL https://github.com/settings/installations/<ID>.The number at the end is your app’s InstallationID. A new Installation ID is generated for each account the app is installed on.
Document image


Once you run your local scan with a configuration YAML file similar to the one shown below, TruffleHog will pick up and scan the configured GitHub source automatically! If you need to run the app for multiple accounts you need to add a new source using the same AppID with each account's InstallationID and a different name.

GitHub app authentication


If you wish, you can later delete the GitHub App, and create/register a new GitHub app and update the configuration file and use the new app to run TruffleHog.

Key

Description

Required

endpoint

Endpoint for accessing GitHub. Omitting it will use GitHub cloud.

No

repositories

List of repositories to be included in the scan. Omitting this will enumerate instead (recommended).

No

organizations

List of organizations to be included in the scan. Omitting this will enumerate instead (recommended).

No

scanUsers

Enumerate organization members and scan their public repositories

No

includeForks

Whether to include forked repositories in the scan

No

head

The name of the branch to be used as the head

No

base

The name of the branch to be used as the base

No

ignoreRepos

List of repositories to be excluded from the scan

No

includeRepos

List of repositories to be specifically included in the scan

No

includePullRequestComments

Whether to include pull request comments in the scan

No

includeIssueComments

Whether to include issue comments in the scan

No

includeGistComments

Whether to include gist comments in the scan

No

skipBinaries

Whether to exclude binary files from the scan

No

skipArchives

Whether to exclude archive files from the scan

No

includeWikis

Whether to include wikis in the scan

No

Capabilities

Feature

Supported

Scan archive files

Scan archived repositories

Scan base64 encoded data

Scan binaries

Comments

Gists

Include/Exclude Filter

Forks

History

Pre-commit

Pre-receive

Real time scanning

Auto resume

Version history

Scan in Continuous Integration (CI)

Notes:

  • TruffleHog does not scan diffs greater than 1 GB.
  • Scanning in GitHub Actions is supported but requires additional setup.
  • When creating a personal access token, make sure you create a "classic" token. Fine-grained tokens are not supported.