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
11 changes: 11 additions & 0 deletions .semgrepignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
26 changes: 26 additions & 0 deletions src/check-security.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
53 changes: 45 additions & 8 deletions src/check-security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,34 @@ async function checkPinnedVersions(): Promise<SecurityCheckResult> {
};
}

/**
* 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
*/
Expand Down Expand Up @@ -522,22 +550,31 @@ async function checkSecretsInCode(): Promise<SecurityCheckResult> {
{ 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",
Expand Down
Loading