Skip to content

Commit c1820ee

Browse files
committed
Scan for committed secrets during every pull request
Issue: PGO-2490
1 parent d6800dd commit c1820ee

File tree

4 files changed

+66
-15
lines changed

4 files changed

+66
-15
lines changed

.github/workflows/trivy.yaml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
with: { go-version: stable }
4949
- run: go mod download
5050

51-
# Report success only when detected licenses are listed in [/trivy.yaml].
51+
# Report success only when detected licenses are listed in [.trivyignore.yaml].
5252
- name: Scan licenses
5353
uses: ./.github/actions/trivy
5454
env:
@@ -59,6 +59,27 @@ jobs:
5959
cache: restore,use
6060
database: skip
6161

62+
secrets:
63+
# Run this job after the cache job regardless of its success or failure.
64+
needs: [cache]
65+
if: >-
66+
${{ !cancelled() }}
67+
68+
runs-on: ubuntu-24.04
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
# Report success only when detected secrets are listed in [.trivyignore.yaml].
73+
- name: Scan licenses
74+
uses: ./.github/actions/trivy
75+
env:
76+
TRIVY_EXIT_CODE: 1
77+
TRIVY_SCANNERS: secret
78+
TRIVY_SECRET_CONFIG: trivy-secret.yaml
79+
with:
80+
cache: restore,use
81+
database: skip
82+
6283
vulnerabilities:
6384
# Run this job after the cache job regardless of its success or failure.
6485
needs: [cache]

.trivyignore.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2024 - 2025 Crunchy Data Solutions, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# https://trivy.dev/latest/docs/configuration/filtering#trivyignoreyaml
6+
7+
# Specify an exact list of recognized and acceptable licenses.
8+
# [A GitHub workflow](.github/workflows/trivy.yaml) rejects pull requests that import licenses not in this list.
9+
#
10+
# https://trivy.dev/latest/docs/scanner/license
11+
licenses:
12+
- id: Apache-2.0
13+
- id: BSD-2-Clause
14+
- id: BSD-3-Clause
15+
- id: ISC
16+
- id: MIT
17+
18+
# These values are used for testing and are not secret.
19+
# [A GitHub workflow](.github/workflows/trivy.yaml) rejects pull requests that contain secrets not in this list.
20+
#
21+
# https://trivy.dev/latest/docs/scanner/secret
22+
secrets:
23+
- id: jwt-token
24+
paths:
25+
- internal/testing/token_*
26+
27+
- id: private-key
28+
paths:
29+
- internal/pki/*_test.go

trivy-secret.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 - 2025 Crunchy Data Solutions, Inc.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
# schema documentation: https://trivy.dev/latest/docs/scanner/secret#configuration
6+
7+
# Trivy has some built-in rules to ignore tests and documentation.
8+
# Disable those and define false-positives in [.trivyignore.yaml].
9+
#
10+
# https://github.com/aquasecurity/trivy/blob/-/pkg/fanal/secret/builtin-allow-rules.go
11+
disable-allow-rules:
12+
- examples
13+
- markdown
14+
- tests
15+
- vendor

trivy.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)