Skip to content

Commit e400e7e

Browse files
tablackburnclaude
andcommitted
ci: scope GITGUARDIAN_API_KEY to ggshield-action step only
Per Copilot review feedback on YouTubeMusicPS#21: the previous job-level env exposed the full secret value to every step in the job (including actions/checkout and any future additions), even though only the ggshield-action step needs it. Switches to a boolean-gate pattern: job-level env exposes only GGSHIELD_ENABLED (a "true"/"false" string indicating whether the secret is set), and the actual GITGUARDIAN_API_KEY value is scoped via step-level env on the ggshield-action invocation. Behavior unchanged when the secret is set; better defense-in-depth against future steps inheriting the secret unintentionally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cc3d14e commit e400e7e

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

.github/workflows/ggshield.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ jobs:
99
name: GitGuardian Scan
1010
runs-on: ubuntu-latest
1111
# Skip Dependabot PRs (no secret access, only updates dependencies). The
12-
# secret-presence check is enforced per-step via `env.GITGUARDIAN_API_KEY`
13-
# below, because the `secrets` context isn't available in `if:` expressions.
12+
# secret-presence check is enforced per-step via the `GGSHIELD_ENABLED`
13+
# boolean (the `secrets` context isn't available in `if:` expressions, so
14+
# we surface it as a job-level env value). Only the action step receives
15+
# the actual secret, scoped via its own step-level `env`.
1416
if: github.actor != 'dependabot[bot]'
1517
env:
16-
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
18+
GGSHIELD_ENABLED: ${{ secrets.GITGUARDIAN_API_KEY != '' }}
1719
steps:
1820
- uses: actions/checkout@v6
19-
if: env.GITGUARDIAN_API_KEY != ''
21+
if: env.GGSHIELD_ENABLED == 'true'
2022
with:
2123
fetch-depth: 0
2224
- uses: GitGuardian/ggshield-action@v1
23-
if: env.GITGUARDIAN_API_KEY != ''
25+
if: env.GGSHIELD_ENABLED == 'true'
26+
env:
27+
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}

0 commit comments

Comments
 (0)