diff --git a/.github/workflows/no-env-files.yml b/.github/workflows/no-env-files.yml new file mode 100644 index 00000000..8ac6a6ed --- /dev/null +++ b/.github/workflows/no-env-files.yml @@ -0,0 +1,51 @@ +name: No env files + +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +jobs: + no-env-files: + name: No env files + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - name: Fail if an env or vars file is tracked + run: | + tracked=$(git ls-files) + bad=$(printf '%s\n' "$tracked" | grep -Ei '(^|/)[^/]*(\.env|\.vars|\.envrc)(\.[^/]*)?(/|$)' | grep -Eiv '\.(example|sample|template)$' | grep -Ev '(^|/)\.cursor/infisical\.env$' || true) + if [ -n "$bad" ]; then + echo "::error::Tracked env or vars files are not allowed. All secrets live only in Infisical." + echo "$bad" + exit 1 + fi + - name: Check Infisical coordinates files hold no secrets + run: | + status=0 + tracked=$(git ls-files) + while IFS= read -r f; do + [ -n "$f" ] || continue + if grep -Ev -- '^[[:space:]]*(#.*)?$' "./$f" | grep -Evq '^INFISICAL_(PROJECT_ID|ENV|DOMAIN)=[A-Za-z0-9._:/@-]*$'; then + echo "::error::$f may hold only INFISICAL_PROJECT_ID, INFISICAL_ENV and INFISICAL_DOMAIN" + status=1 + fi + done < <(printf '%s\n' "$tracked" | grep -E '(^|/)\.cursor/infisical\.env$' || true) + exit $status + - name: Check placeholder env files hold no real values + run: | + status=0 + tracked=$(git ls-files) + while IFS= read -r f; do + [ -n "$f" ] || continue + hits=$(grep -E -- '^[A-Za-z_][A-Za-z0-9_]*=[^[:space:]#]+' "./$f" | grep -Ev -- "^[A-Za-z_][A-Za-z0-9_]*=(\"\"|'')[[:space:]]*(#.*)?$" | sed -E 's/[[:space:]]+#.*$//' | awk '{ i = index($0, "="); k = tolower(substr($0, 1, i - 1)); v = tolower(substr($0, i + 1)); if (k ~ /(secret|token|password|passwd|api[-_]?key|private|credential|_key|(^|_)auth)/ && k !~ /^(author|auth_enabled)$/ && v !~ /(xxx|\.\.\.|<|changeme|change-me|your[-_]|example|placeholder|path\/to|redacted|dummy|todo)/) print }' || true) + if [ -n "$hits" ]; then + echo "::error::$f is a placeholder file but a credential-like key carries a non-placeholder value" + status=1 + fi + done < <(printf '%s\n' "$tracked" | grep -Ei '(^|/)[^/]*(\.env|\.vars|\.envrc)(\.[^/]*)?(/|$)' | grep -Ei '\.(example|sample|template)$' || true) + exit $status diff --git a/.gitignore b/.gitignore index 94f53acf..ef8ee6ce 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,22 @@ _site/ ios/CodeCapsCompanion/build/ __pycache__/ *.pyc + +# --- No secrets in files: all secrets live only in Infisical --- +.env +.env.* +*.env +.dev.vars +.dev.vars.* +.prod.vars +.prod.vars.* +*.vars +*.vars.* +*.env.* +.envrc +*.envrc +*.envrc.* +!*.example +!*.sample +!*.template +!.cursor/infisical.env diff --git a/AGENTS.md b/AGENTS.md index 79a5e2fe..37d3b2e0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -160,3 +160,9 @@ that goes backwards silently strands every installed copy. - Audit batches use the `audit-#N` branch naming and ship in `docs/audits/-.md`. - UI changes must be covered by automated visual verification where feasible: Playwright screenshot assertions for web surfaces, `xcrun simctl io booted screenshot` for iOS simulator. The owner never takes manual screenshots and does not run local UI preview sessions. Native Mac app UI is verified through code review and CI. + +## No secrets in files + +All secrets live only in Infisical. Never put a secret in a `.env`, `.vars`, `.dev.vars`, `.prod.vars` or any similar file, tracked or untracked, in any repo, ever. Read secrets from Infisical at run time through this repo's documented reader. Only `*.example`, `*.sample` and `*.template` files with empty or placeholder values may be committed. `.gitignore` blocks these file names and the `No env files` CI check fails any PR that tracks one. If a secret file is ever committed, delete it from the tree right away and keep a backup on our own systems (never in the repo or in chat). A history purge is a separate owner decision. + +The one exception is `.cursor/infisical.env`, which may hold only the `INFISICAL_PROJECT_ID`, `INFISICAL_ENV` and `INFISICAL_DOMAIN` coordinates and never a credential; CI checks its content.