Skip to content

Commit 5fbd7c1

Browse files
authored
Added rule to check for Trufflehog Github action (#249)
* Added rule for TruffleHog
1 parent 4484e16 commit 5fbd7c1

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests:
2+
- name: "Should have TruffleHog enabled"
3+
def: {}
4+
params: {}
5+
expect: "pass"
6+
git:
7+
repo_base: github_action_with_trufflehog
8+
- name: "Should not have Renovate enabled"
9+
def: {}
10+
params: {}
11+
expect: "fail"
12+
git:
13+
repo_base: github_action_without_trufflehog
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: Secret Scanning
16+
uses: trufflesecurity/trufflehog@v3.86.1
17+
with:
18+
extra_args: --results=verified,unknown
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
version: v1
3+
release_phase: alpha
4+
type: rule-type
5+
name: trufflehog_github_action
6+
display_name: Prevent Secret Exposure using TruffleHog GitHub Action
7+
short_failure_message: TruffleHog is not configured via a GitHub action
8+
severity:
9+
value: medium
10+
context: {}
11+
description: |
12+
Verifies that automated secret detection is implemented using TruffleHog GitHub
13+
Action to scan repositories for exposed secrets and sensitive information.
14+
This is crucial for preventing data breaches and unauthorized access that
15+
could occur from accidentally committed credentials, API keys, or other
16+
sensitive data. Regular scanning helps maintain security compliance and protects your organization's assets.
17+
18+
For technical details, see the [TruffleHog documentation](https://github.com/trufflesecurity/trufflehog)
19+
and [GitHub Action implementation guide](https://github.com/marketplace/actions/trufflehog-oss).
20+
guidance: |
21+
Ensure that TruffleHog is configured and enabled for the repository.
22+
23+
For more information, see the [TruffleHog GitHub Action](https://github.com/marketplace/actions/trufflehog-oss#octocat-trufflehog-github-action documentation.
24+
def:
25+
in_entity: repository
26+
rule_schema:
27+
type: object
28+
properties: {}
29+
ingest:
30+
type: git
31+
git: {}
32+
eval:
33+
type: rego
34+
rego:
35+
type: deny-by-default
36+
def: |
37+
package minder
38+
39+
import rego.v1
40+
41+
actions := github_workflow.ls_actions("./.github/workflows")
42+
43+
default message := "No TruffleHog GitHub action found for automated secret detection"
44+
default allow := false
45+
allow if {
46+
# check that there is a trufflehog action
47+
"trufflesecurity/trufflehog" in actions
48+
}
49+
# Defines the configuration for alerting on the rule
50+
alert:
51+
type: security_advisory
52+
security_advisory: {}

0 commit comments

Comments
 (0)