Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitleaks GitHub Action Rule #250

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions rule-types/github/gitleaks_github_action.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests:
- name: "Should have Gitleaks enabled"
def: {}
params: {}
expect: "pass"
git:
repo_base: github_action_with_gitleaks
- name: "Should not have Gitleaks enabled"
def: {}
params: {}
expect: "fail"
git:
repo_base: github_action_without_gitleaks
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: gitleaks
on:
workflow_dispatch:
schedule:
# Run every 15 minutes
- cron: '0/15 * * * *'
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Self-hosted Gitleaks
uses: gitleaks/gitleaks-action@v2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Just Checkout
on:
workflow_dispatch:
schedule:
# Run every 15 minutes
- cron: '0/15 * * * *'
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
43 changes: 43 additions & 0 deletions rule-types/github/gitleaks_github_action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
version: v1
release_phase: alpha
type: rule-type
name: gitleaks_github_action
display_name: Enable Gitleaks to prevent leakage of passwords or keys
short_failure_message: Gitleaks is not configured via a GitHub action
severity:
value: medium
context: {}
description: |
Verifies that Gitleaks is configured via a GitHub action for the repository.
guidance: |
Ensure that Gitleaks is configured and enabled for the repository.
Gitleaks is an open-source secret scanner for git repositories, files, and directories.
For more information, see the [GitHub Action Gitleaks](https://github.com/gitleaks/gitleaks-action) documentation.
def:
in_entity: repository
rule_schema:
type: object
properties: {}
ingest:
type: git
git: {}
eval:
type: rego
rego:
type: deny-by-default
def: |
package minder

import rego.v1

actions := github_workflow.ls_actions("./.github/workflows")

default message := "Gitleaks GitHub action is not configured"
default allow := false
allow if contains(actions[_], "gitleaks/gitleaks-action")
Comment on lines +36 to +38
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to check that the workflow is on for both pull_request and push events?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do you want to add a remediation using the usage example from either the action or the repo?


# Defines the configuration for alerting on the rule
alert:
type: security_advisory
security_advisory: {}
Loading