Skip to main content

Detect secrets from all sources using GitGuardian's brains

Project description


ggshield: protect your code with GitGuardian

PyPI Docker Image Version (latest semver) License GitHub stars GitHub Workflow Status Codecov

ggshield is a CLI application that runs in your local environment or in a CI environment to help you detect more than 350+ types of secrets, as well as other potential security vulnerabilities or policy breaks affecting your codebase.

ggshield uses our public API through py-gitguardian to scan and detect potential vulnerabilities in files and other text content.

Only metadata such as call time, request size and scan mode is stored from scans using ggshield, therefore secrets and policy breaks incidents will not be displayed on your dashboard and your files and secrets won't be stored.

Table of Contents

Installation

macOS - Using Homebrew

You can install ggshield using Homebrew by running the following command:

$ brew install gitguardian/tap/ggshield

Linux packages

Deb and RPM packages are available on Cloudsmith.

Setup instructions:

Other Operating Systems - Using pip

Installing

$ pip install ggshield

ggshield supports Python 3.7 and newer.

The package should run on MacOS, Linux and Windows.

Updating

To update ggshield you can add the option -U/--upgrade to the pip install command.

$ pip install -U ggshield

Initial setup

To use ggshield you need to authenticate against GitGuardian servers. To do so, use the ggshield auth login command. This command automates the provisioning of a personal access token and its configuration on the local workstation.

You can learn more about it from ggshield auth login documentation.

Alternatively, you can create your personal access token manually and you can store it in the GITGUARDIAN_API_KEY environment variable to complete the setup.

Getting started

Secrets

You can now use ggshield to search for secrets:

  • in files: ggshield secret scan path -r .
  • in repositories: ggshield secret scan repo .
  • in Docker images: ggshield secret scan docker ubuntu:22.04
  • in Pypi packages: ggshield secret scan pypi flask
  • and more, have a look at ggshield secret scan --help output for details.

Infrastructure-as-Code (IaC)

You can also search for vulnerabilities in your IaC files using the following command:

ggshield iac scan all .

However, if you are only interested in new potential IaC vulnerabilities, you can run:

ggshield iac scan diff --ref=HEAD~1 .

Have a look at ggshield iac scan --help for more details.

Integrations

You can integrate ggshield in your CI/CD workflow.

To catch errors earlier, use ggshield as a pre-commit, pre-push or pre-receive Git hook.

Learn more

For more information, have a look at the documentation

Output

If no secrets or policy breaks have been found, the exit code will be 0:

$ ggshield secret scan pre-commit

If a secret or other issue is found in your staged code or in your CI, you will have an alert giving you the type of policy break, the filename where the policy break has been found and a patch giving you the position of the policy break in the file:

$ ggshield secret scan pre-commit

🛡️  ⚔️  🛡️  2 policy breaks have been found in file production.rb

11 | config.paperclip_defaults = {
12 |     :s3_credentials => {
13 |     :bucket => "XXX",
14 |     :access_key_id => "XXXXXXXXXXXXXXXXXXXX",
                            |_____AWS Keys_____|

15 |     :secret_access_key => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                |_______________AWS Keys_______________|

16 |     }
17 | }

Lines that are too long are truncated to match the size of the terminal, unless the verbose mode is used (-v or --verbose).

Related open source projects

License

ggshield is MIT licensed.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ggshield-1.17.0.tar.gz (101.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ggshield-1.17.0-py3-none-any.whl (141.4 kB view details)

Uploaded Python 3

File details

Details for the file ggshield-1.17.0.tar.gz.

File metadata

  • Download URL: ggshield-1.17.0.tar.gz
  • Upload date:
  • Size: 101.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for ggshield-1.17.0.tar.gz
Algorithm Hash digest
SHA256 cfbd06f5858a54715cfa0fafa66f074fe9e98005c49aa17dc2f108262761e233
MD5 ea955c345e27314a11c7e9e3d0373142
BLAKE2b-256 67a2c75ea8ab0465b0f3c0d071dd773f0f3c5bf3b1d66a991464279e421d03ce

See more details on using hashes here.

File details

Details for the file ggshield-1.17.0-py3-none-any.whl.

File metadata

  • Download URL: ggshield-1.17.0-py3-none-any.whl
  • Upload date:
  • Size: 141.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for ggshield-1.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 738a6db9b4bd54b87094d0dd3ccfa464d58dff69c6d5a979507da385af81892a
MD5 229a47628ca83ebbfebd0339c47ca5d5
BLAKE2b-256 3fde9454601d574dfc4f5e4c9895760e03d613fc0af91483381bc4eb12fa2bd1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page