diff --git a/.semgrepignore b/.semgrepignore index f364a070..bf2da1c8 100644 --- a/.semgrepignore +++ b/.semgrepignore @@ -9,3 +9,14 @@ node_modules/ coverage/ .next/ .turbo/ + +# Test fixtures contain INTENTIONAL fake secrets (AWS/JWT/Postgres/etc.) to +# exercise kit's own secret-scanner + redactor — they are not real credentials, +# and they trip semgrep's secret-detection rules as false positives. Tests are +# not shipped (dist/ is), so SAST coverage of them has low value + high noise. +*.test.ts + +# Workflow YAML is covered by the dedicated `kit gha-audit` (#60: unpinned +# actions, pwn-requests). semgrep's secret rules only false-positive here on +# `${{ secrets.* }}` references (which are NOT literal tokens). +.github/ diff --git a/CHANGELOG.md b/CHANGELOG.md index fdc4dd5a..3c38b99a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). ## [Unreleased] +## [1.26.0] - 2026-06-24 + +### Changed + +- **Secrets scan distinguishes verified-live from unverified — no more critical-failing a clean repo on its own test fixtures.** `kit check`'s trufflehog git-history scan previously failed `critical` on _any_ finding, counting secret-SHAPED strings the same as confirmed leaks — so a repo's own test fixtures / example connection strings / docs blocked the gate. Now only a **verified-live** secret (one trufflehog confirmed still works) is a `critical` fail ("rotate now"); unverified secret-shaped strings are a `warn` to review ("0 verified-live — review for test/example data"). New pure, fixture-tested `classifyTrufflehogFindings`. This is the #1 false-positive class for any security tool whose own suite contains fake secrets. +- **semgrep `.semgrepignore` excludes test fixtures + `.github/` (noise reduction).** Test files carry intentional fake secrets to exercise kit's scanner/redactor (semgrep secret-rule false positives; tests aren't shipped), and workflow YAML is covered by the dedicated `kit gha-audit` (#60) — semgrep only false-positived there on `${{ secrets.* }}` references. Drops kit's own semgrep result from a `fail` (16 fixture/noise findings) to a `warn` (genuine low-severity items only). + ## [1.25.1] - 2026-06-24 ### Fixed diff --git a/package-lock.json b/package-lock.json index 6bb236da..0d13265e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sandstream-kit", - "version": "1.25.1", + "version": "1.26.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sandstream-kit", - "version": "1.25.1", + "version": "1.26.0", "license": "MIT", "workspaces": [ "packages/*" diff --git a/package.json b/package.json index 60d4cf7d..c37db274 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sandstream-kit", - "version": "1.25.1", + "version": "1.26.0", "description": "developer kit. zero LLM, local-first, multi-vault. one command from git clone to working dev environment.", "license": "MIT", "funding": "https://buymeacoffee.com/sandstream", diff --git a/src/check-security.test.ts b/src/check-security.test.ts index 75005496..ddaf0970 100644 --- a/src/check-security.test.ts +++ b/src/check-security.test.ts @@ -6,8 +6,34 @@ import { parseOsvVulnCount, parseTrivyVulnCount, classifySocketResult, + classifyTrufflehogFindings, } from "./check-security.js"; +describe("classifyTrufflehogFindings (verified vs unverified)", () => { + const line = (det: string, verified: boolean) => + JSON.stringify({ DetectorName: det, Verified: verified }); + + it("ignores the trufflehog info log line (no DetectorName)", () => { + const out = classifyTrufflehogFindings('{"level":"info","msg":"starting"}\n'); + assert.deepStrictEqual(out, { verified: 0, unverified: 0 }); + }); + + it("splits verified-live from unverified findings", () => { + const stdout = [ + '{"level":"info"}', + line("Postgres", false), + line("Postgres", false), + line("AWS", true), + ].join("\n"); + assert.deepStrictEqual(classifyTrufflehogFindings(stdout), { verified: 1, unverified: 2 }); + }); + + it("counts an unparseable DetectorName line conservatively as unverified", () => { + const out = classifyTrufflehogFindings('{"DetectorName":"X" broken json'); + assert.deepStrictEqual(out, { verified: 0, unverified: 1 }); + }); +}); + describe("classifySocketResult (fail-closed)", () => { it("never passes when Socket is not logged in (the false-green guard)", () => { for (const raw of [ diff --git a/src/check-security.ts b/src/check-security.ts index 3802cc1a..73abf65a 100644 --- a/src/check-security.ts +++ b/src/check-security.ts @@ -488,6 +488,34 @@ async function checkPinnedVersions(): Promise { }; } +/** + * Count trufflehog `--json` findings split by Verified (live) vs unverified. Pure. + * + * trufflehog prefixes an info LOG line ({"level":...}); only DetectorName lines are + * findings. `Verified: true` = trufflehog reached the provider and the credential + * WORKS (a real, live leak). Unverified = secret-SHAPED but unconfirmed — very often + * test fixtures / example connection strings / docs. A DetectorName line that won't + * parse is counted conservatively as unverified (surfaced, just not as critical). + */ +export function classifyTrufflehogFindings(stdout: string): { + verified: number; + unverified: number; +} { + let verified = 0; + let unverified = 0; + for (const line of stdout.trim().split("\n")) { + if (!line.includes('"DetectorName"')) continue; + try { + const j = JSON.parse(line) as { Verified?: boolean }; + if (j.Verified === true) verified++; + else unverified++; + } catch { + unverified++; + } + } + return { verified, unverified }; +} + /** * Scan for secrets in code using trufflehog or basic pattern matching */ @@ -522,22 +550,31 @@ async function checkSecretsInCode(): Promise { { timeout: 90_000 }, ); - // trufflehog --json prefixes an info LOG line ({"level":...}); only count - // lines that are real findings (they carry a DetectorName). - const findings = stdout - .trim() - .split("\n") - .filter((l) => l.includes('"DetectorName"')); + // Split verified-live from unverified (#noise-reduction). Only a VERIFIED + // secret — one trufflehog confirmed still works — is a critical fail (rotate + // now). Unverified secret-shaped strings (overwhelmingly test fixtures / + // example connection strings) are a warn to review, not a release-blocking + // critical. Avoids failing a clean repo on its own test data. + const { verified, unverified } = classifyTrufflehogFindings(stdout); - if (findings.length > 0) { + if (verified > 0) { return { category: "secrets", name: "secrets scan", status: "fail", - detail: `${findings.length} secret(s) committed in git history -run: trufflehog git file://.`, + detail: `${verified} VERIFIED-LIVE secret(s) in git history -rotate now; run: trufflehog git file://.`, severity: "critical", }; } + if (unverified > 0) { + return { + category: "secrets", + name: "secrets scan", + status: "warn", + detail: `${unverified} unverified secret-shaped string(s) in git history (0 verified-live) — review for test/example data: trufflehog git file://.`, + severity: "medium", + }; + } return { category: "secrets",