Skip to content

Commit 8c7d8ed

Browse files
[SVLS-8660] ci: add gitleaks secrets scanning (#1134)
## Summary - Adds \`gitleaks\` secrets scanning workflow (\`.github/workflows/secrets-scan.yml\`) triggered on every PR and push to \`main\` - Pins \`gitleaks-action\` to commit SHA (v2.3.9) consistent with repo convention - Adds \`.gitleaks.toml\` with documented allowlist structure for paths, regexes, and historical commits — includes maintenance guidance for future contributors - Addressed Copilot review feedback: add \`permissions: contents: read\`, enable \`--redact\` to prevent secrets appearing in CI logs, fix allowlist key reference in comments ## Why Secrets accidentally committed to a public repo (API keys, tokens, credentials) are the highest-severity risk for a public repository. Neither \`cargo audit\` nor Copilot catch this category. \`gitleaks\` uses pattern matching to block merges before a credential lands in \`main\`. ## Test plan - [ ] Verify \`Secrets Scan\` job passes on this PR (no secrets in changed files) - [ ] After merging: add \`Secrets Scan\` as a required status check under \`Repository Settings → Branches → main → Branch protection rules\` - [ ] Optional smoke test: add a fake credential (e.g., \`AKIAIOSFODNN7EXAMPLE\`) to a comment on a test branch, confirm the job blocks it, then remove it ## Related - JIRA: https://datadoghq.atlassian.net/browse/SVLS-8660 - Part of Phase 1 CI security scanning — see \`.github/docs/ci-security-scanning-strategy.md\` - Companion PR: #1133 (Copilot instructions for PII/security review) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2ee4912 commit 8c7d8ed

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

.github/workflows/secrets-scan.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Secrets Scan
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
gitleaks:
11+
name: Secrets Scan
12+
runs-on: ubuntu-22.04
13+
permissions:
14+
contents: read
15+
steps:
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Run gitleaks
21+
uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2.3.9
22+
with:
23+
args: --redact
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}

.gitleaks.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
title = "datadog-lambda-extension gitleaks config"
2+
3+
# This file configures gitleaks to suppress known false positives.
4+
# Only add entries here after confirming a finding is NOT a real secret.
5+
# If a real secret is found: rotate it immediately, then add the commit hash to the `commits` list under [allowlist] below.
6+
#
7+
# Maintenance workflow:
8+
# 1. gitleaks flags something on a PR
9+
# 2. Review the finding — is it a real secret or a false positive?
10+
# 3. Real secret → rotate immediately, fix the code, optionally add the commit hash below
11+
# 4. False positive → add the appropriate entry below with a comment explaining why
12+
13+
[allowlist]
14+
description = "Known false positives"
15+
16+
# paths: skip entire directories or files from scanning.
17+
# Use when a directory contains third-party code or test fixtures with fake data.
18+
# Examples:
19+
# "integration-tests/node_modules" — npm dependencies, not our code
20+
# "bottlecap/tests/fixtures" — test payloads with placeholder values
21+
# "docs/examples" — documentation examples with fake keys
22+
paths = [
23+
# npm dependencies bundled under integration-tests — not our code, would be noisy
24+
"integration-tests/node_modules",
25+
]
26+
27+
# regexes: suppress findings whose matched secret value matches one of these patterns.
28+
# Use for placeholder/example values that appear in source or docs but are not real secrets.
29+
# Examples:
30+
# '''your-api-key''' — generic placeholder in docs or scripts
31+
# '''my_test_key''' — unit test placeholder (bottlecap/tests/)
32+
# '''AKIAIOSFODNN7EXAMPLE''' — AWS example key from official AWS documentation
33+
# '''DD_API_KEY_EXAMPLE''' — Datadog placeholder used in README examples
34+
regexes = []
35+
36+
# commits: suppress all findings from a specific historical commit.
37+
# Use when a commit contained a now-rotated credential that cannot be rewritten
38+
# (e.g., it is already on the default branch or in a public tag).
39+
# Always document why the commit is suppressed and confirm the credential was rotated.
40+
# Examples:
41+
# "abc123def456" — rotated DD_API_KEY accidentally committed on 2024-01-15, key invalidated
42+
commits = []

0 commit comments

Comments
 (0)