Home

Awesome

Gitleaks Action


  ┌─○───┐
  │ │╲  │
  │ │ ○ │
  │ ○ ┌─┴───────────────────┐
  └─░─┤  4 github actions   │
      └─────────────────────┘

<p align="left"> <a href="https://github.com/zricethezav/gitleaks-action"> <img alt="gitleaks badge" src="https://img.shields.io/badge/protected%20by-gitleaks-blue"> </a> </p>

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. Enable Gitleaks-Action in your GitHub workflows to be alerted when secrets are leaked as soon as they happen. Check out our demos here (.gif) and here (.png), or see what's new in v2 here. Don't forget to check out our blog, which details how to configure and set up Gitleaks-Action for organizations and enterprises.

Usage Example

name: gitleaks
on:
  pull_request:
  push:
  workflow_dispatch:
  schedule:
    - cron: "0 4 * * *" # run once a day at 4 AM
jobs:
  scan:
    name: gitleaks
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: gitleaks/gitleaks-action@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} # Only required for Organizations, not personal accounts.

Environment Variables:


Questions

Do I need a free license key?

If you are scanning repos that belong to an organization account, you will need to obtain a free license key

If you are scanning repos that belong to a personal account, then no license key is required.

How do I get a free license key?

You can visit gitleaks.io to sign up for a free license key. Clicking "Sign Up" will take you to a google form where you will need to supply name, email, and company. An email with a license key will show up shortly after submission.

Can I use a custom gitleaks configuration?

You can! This GitHub Action follows a similar order of precedence as the gitleaks CLI tool. You can use GITLEAKS_CONFIG to explicitly set a config path or create a gitleaks.toml at the root of the repo which will be automatically detected and used by gitleaks-action.

Does this GitHub Action send any data to 3rd parties?

The only data that gitleaks-action sends to any third party is data related to license key validation (namely GITLEAKS_LICENSE, repo name, and repo owner), which is sent to the license key validation service, keygen. Your code never leaves GitHub because the scanning takes place within the GitHub Actions docker container.

Can I use gitleaks-action as a third-party tool for GitHub code scanning?

You can but it is not recommended because it gives a false sense of security. If a secret is leaked in one commit, then removed in a subsequent commit, the security alert in the GitHub Security dashboard will show as resolved, even though the secret is still visible in the commit history. To truly address the leak, you should rotate the secret (and also consider re-writing the git history to remove the leak altogether).

Why is my gitleaks-action job suddenly failing?

6/21/2022

On June 21, 2022, we merged Gitleaks Action v2 into the master branch. This was a breaking update, and we made an effort to contact as many of our users as possible via GitHub, social media, etc. If you didn't know this breaking update was coming, we sincerely apologize for the inconvenience. The good news is, remedying the job failure is straightforward! You can either:

  1. Upgrade to v2, or
  2. Pin to an older version

Please note that if you are scanning repos that belong to an organization, you'll have to acquire a GITLEAKS_LICENSE to use v2 (free "Trial" license available). That might come as a surprise to my users that are accustomed to using Gitleaks-Action free of charge, so I wrote a blog post explaining how/why I decided to monetize this project: https://blog.gitleaks.io/gitleaks-llc-announcement-d7d06a52e801

Finally, please see above for a summary of why I think you'll love the new v2 release: v2 Benefits

How can I get a gitleaks badge on my readme?

Enable this gitleaks-action and copy <img alt="gitleaks badge" src="https://img.shields.io/badge/protected%20by-gitleaks-blue"> to your readme.

License Change

Since v2.0.0 of Gitleaks-Action, the license has changed from MIT to a commercial license. Prior versions to v2.0.0 of Gitleaks-Actions will remain under the MIT license.

Contributing

Please see our contributing guidelines.

Copyright © 2022 Gitleaks LLC - All Rights Reserved