Skip to content
Merged
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
32 changes: 32 additions & 0 deletions .github/workflows/secret-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: secret-and-phi-scan

# Server-side backstop for the local pre-commit hook (which a developer can skip with
# --no-verify). Runs the same .gitleaks.toml ruleset against the checked-out tree.
#
# We invoke the gitleaks *binary* via its Docker image rather than gitleaks/gitleaks-action,
# because that Action requires a GITLEAKS_LICENSE for organization-owned repos. The binary
# itself is MIT-licensed with no such requirement.

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Scan working tree for secrets + PHI
run: |
docker run --rm -v "${{ github.workspace }}:/repo" \
ghcr.io/gitleaks/gitleaks:v8.30.1 \
dir /repo \
--config /repo/.gitleaks.toml \
--redact \
--verbose \
--exit-code 1
62 changes: 62 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# gitleaks config — shared by the pre-commit hook and the CI scan.
# Goal: keep secrets and obvious PHI/PII out of GitHub (see threat model — we protect the
# remote, not LLM egress). Built-in secret rules are inherited; the custom rules below add
# high-signal PHI/PII patterns. Deliberately NOT flagged: bare NPIs and dates of birth — on
# their own those are not PHI violations for this repo, and regexing them is pure noise.
#
# Free-text patient NAMES are intentionally absent: there is no low-false-positive regex for
# them. Names stay a code-review concern (especially for hand-authored queries/*.sql).
title = "Chamber Cardio nao-analytics-agent — secrets + PHI/PII gate"

[extend]
# Inherit all of gitleaks' built-in secret detectors (Anthropic sk-ant- keys, AWS keys,
# private keys, generic high-entropy tokens, etc.).
useDefault = true

# --- Global allowlist ----------------------------------------------------------------------
[[allowlists]]
description = "Paths that are machine-generated or hold no patient data."
paths = [
'''poetry\.lock''',
'''\.gitleaks\.toml''', # don't flag the example patterns in this file itself
]

# --- Secret rules (augment the built-ins) --------------------------------------------------

[[rules]]
id = "anthropic-api-key"
description = "Anthropic API key (sk-ant-...). Our #1 secret; gitleaks' defaults miss it."
regex = '''sk-ant-[A-Za-z0-9]+-[A-Za-z0-9_-]{20,}'''
keywords = ["sk-ant-"]
tags = ["secret", "anthropic"]

# --- PHI / PII rules -----------------------------------------------------------------------

[[rules]]
id = "phi-us-ssn"
description = "Possible US Social Security Number (PHI)"
regex = '''\b\d{3}-\d{2}-\d{4}\b'''
tags = ["PHI", "PII"]

[[rules]]
id = "phi-us-phone"
description = "Possible US phone number (PII)"
# Requires delimiters between groups so a bare 10-digit NPI (e.g. 1234567890) does NOT match.
regex = '''\b(?:\+?1[-.\s])?\(?\d{3}\)?[-.\s]\d{3}[-.\s]\d{4}\b'''
tags = ["PII"]

[[rules]]
id = "phi-email"
description = "Email address (possible patient PII)"
regex = '''[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}'''
tags = ["PII"]

[[rules.allowlists]]
description = "Known-safe, non-patient addresses and infra hostnames."
regexTarget = "match"
regexes = [
'''@chambercardio\.com''', # our own corporate domain
'''git@github\.com''', # SSH remote in nao_config.yaml / sync script
'''@(example|test|invalid)\.(com|org|net)''',
'''noreply@''',
]
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default_stages: [pre-commit]
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.1
hooks:
- id: gitleaks
name: 🔐 secrets + PHI scan
description: "Block secrets and obvious PHI/PII from being committed (uses .gitleaks.toml)"
Loading