fix(ci): run scanners before pnpm install to avoid node_modules false positives #51
Reference in New Issue
Block a user
Delete Branch "fix/ci/scan-before-install"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
First successful gitleaks run flagged 381 "leaks" — all inside
node_modules/and.pnpm-store/, populated by thepnpm install --frozen-lockfilestep that ran earlier in the job. Upstream npm packages routinely embed demo RSA keys / fake API tokens in their READMEs and test fixtures, and gitleaks correctly (by its rules) flags them.Same class of false-positive Trivy hit in #49 — solved there by
--scanners vuln. Here, the cleanest solution is reordering: run the scanners beforepnpm install, so the working tree contains only our committed source.pnpm-lock.yaml(committed) — doesn't need install.--no-git --source .in ci.yml) — doesn't need install.pnpm-lock.yamlagainst the advisory DB — also doesn't need install. The install before audit remains for the workspace-integrity sanity check.The ordering rationale is committed as a comment at the top of each job's
steps:block, so a future contributor doesn't innocently shuffle the steps and re-flood the gate with FPs.Same reordering applied to
.gitea/workflows/security-scheduled.ymlfor consistency, even though its deep-history gitleaks scan doesn't suffer this issue (node_modulesis.gitignored from day one — never in history).Test plan
scanjob goes green end-to-end on this PR — gitleaks reports 0 leaks (or only real ones from our source, none expected).pushto main post-merge, scan stays green.security-scheduledmanually before next Monday's cron to verify the same ordering doesn't break the deep scan.After this PR
With #43 (TS/ESLint reverts), #45 (Trivy install), #49 (Trivy
--scanners vuln), #50 (gitleaks install), and now this — every gate of the CI pipeline should be green end-to-end. Phase-1 CI bring-up is then complete and we can move to A — local infra recipe (Postgres + Redis + OTel Collector).