π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
fix(security): fail closed on unvalidated `security scan` --depth/--type/--target (#2866)
Dragan Spiridonov76453115a828
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 80baec9ca7..7d34c83c96 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- `RUFLO_STATUSLINE_COST_SYMBOL` β override the leading `$` (e.g. `β‘`, `β¬`, `π±`); empty string shows the number alone.- `RUFLO_STATUSLINE_HIDE_COST` β `1`/`true`/`yes`/`on` hides the segment. `cost.total_cost_usd` is a client-side estimate that may differ from the actual bill and is misleading on subscription plans.+### Fixed++- **`security scan` failed open on unvalidated `--depth` / `--type` / `--target`** β an unrecognised `--type` matched none of the three phase guards, so no phase ran at all and the command still printed "No security issues found!" and exited 0; an unrecognised `--depth` fell through chained ternaries to the *shallowest* traversal (so `--depth full` scanned less than the default `standard`), which on a tree whose only HIGH finding sat below that budget also flipped the critical/high exit-code gate from 1 to 0; and a non-existent or non-directory `--target` read nothing, which the swallowed dir-read catches turned into a clean banner, exit 0, and a **persisted CLEAN report** that `getSecurityStatus` then surfaced as CLEAN. All three now fail closed before anything is scanned or written. Chained ternaries replaced with exhaustive `Record<ScanDepth, number>` maps behind real type predicates, and the recursion guard now positive-tests its budget so a bad value stops traversal instead of disabling the limiter. (`v3/@claude-flow/cli/src/commands/security.ts`)++### Changed++- **`security scan --depth full` is deprecated, not removed** β `full` was never a supported depth, but the CLI itself emitted it (statusline insight, announcement, the CLAUDE.md `init` generates, two shipped agent definitions). It is now normalised to `deep` with a warning rather than rejected, and those emitters have been updated to `--depth deep`. (`v3/@claude-flow/cli/src/funnel/insights.ts`, `funnel/messages.ts`, `commands/announcements.ts`, `init/claudemd-generator.ts`, `.claude/agents/v3/security-architect*.md`)++### Removed++- **`security scan --type container` is rejected instead of silently reporting clean** β it had been advertised in `--type`'s help since the command was written, but no phase ever implemented it, so it scanned nothing and printed a clean bill of health. It now exits 1 with an explicit "not implemented" message, and the help text no longer offers it. **Breaking** for any pipeline passing `--type container`, which previously exited 0. (`v3/@claude-flow/cli/src/commands/security.ts`)+## [3.32.10] - 2026-07-26Bug-fix release closing the tracker-fire sweep from 2026-07-24 β 2026-07-26. All fixes are surgical and additive; no API surface change, no schema change, patch semver.diff --git a/v3/@claude-flow/cli/.claude/agents/v3/security-architect-aidefence.md b/v3/@claude-flow/cli/.claude/agents/v3/security-architect-aidefence.mdindex 4da10330ef..c6f2be28d3 100644--- a/v3/@claude-flow/cli/.claude/agents/v3/security-architect-aidefence.md+++ b/v3/@claude-flow/cli/.claude/agents/v3/security-architect-aidefence.md@@ -140,7 +140,7 @@ hooks:# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββecho "π Running comprehensive security validation..."- npx claude-flow@v3alpha security scan --depth full --output-format json > /tmp/security-scan.json 2>/dev/null+ npx claude-flow@v3alpha security scan --depth deep --output-format json > /tmp/security-scan.json 2>/dev/nullVULNERABILITIES=$(jq -r '.vulnerabilities | length' /tmp/security-scan.json 2>/dev/null || echo "0")CRITICAL_COUNT=$(jq -r '.vulnerabilities | map(select(.severity == "critical")) | length' /tmp/security-scan.json 2>/dev/null || echo "0")HIGH_COUNT=$(jq -r '.vulnerabilities | map(select(.severity == "high")) | length' /tmp/security-scan.json 2>/dev/null || echo "0")diff --git a/v3/@claude-flow/cli/.claude/agents/v3/security-architect.md b/v3/@claude-flow/cli/.claude/agents/v3/security-architect.mdindex a20012f2dc..377a30043a 100644--- a/v3/@claude-flow/cli/.claude/agents/v3/security-architect.md+++ b/v3/@claude-flow/cli/.claude/agents/v3/security-architect.md@@ -58,7 +58,7 @@ hooks:echo "β Security architecture analysis complete"# 1. Run comprehensive security validation- npx claude-flow@v3alpha security scan --depth full --output-format json > /tmp/security-scan.json 2>/dev/null+ npx claude-flow@v3alpha security scan --depth deep --output-format json > /tmp/security-scan.json 2>/dev/nullVULNERABILITIES=$(jq -r '.vulnerabilities | length' /tmp/security-scan.json 2>/dev/null || echo "0")CRITICAL_COUNT=$(jq -r '.vulnerabilities | map(select(.severity == "critical")) | length' /tmp/security-scan.json 2>/dev/null || echo "0")@@ -834,7 +834,7 @@ mcp__claude-flow__memory_usage({```bash# Full security scan-npx claude-flow@v3alpha security scan --depth full+npx claude-flow@v3alpha security scan --depth deep# CVE-specific checksnpx claude-flow@v3alpha security cve --check CVE-2024-001diff --git a/v3/@claude-flow/cli/__tests__/security-scan-enum-validation.test.ts b/v3/@claude-flow/cli/__tests__/security-scan-enum-validation.test.tsnew file mode 100644index 0000000000..37d52dea8f--- /dev/null+++ b/v3/@claude-flow/cli/__tests__/security-scan-enum-validation.test.ts@@ -0,0 +1,246 @@+/**+ * `security scan` used to fail open on an unrecognised --depth, --type or+ * --target.+ *+ * An unknown --type matched none of the three phase guards, so no phase ran at+ * all and the command still printed "No security issues found!" and exited 0.+ * An unknown --depth fell through the chained ternaries to the shallowest+ * traversal, so `--depth full` scanned *less* than the default `standard` β and+ * because it dropped the HIGH-severity finding, it also flipped the+ * critical/high exit-code gate from 1 to 0. A non-existent --target read+ * nothing, and the swallowed dir-read catches turned that into a clean banner,+ * exit 0, and a PERSISTED clean report. A typo was indistinguishable from a+ * clean bill of health.+ *+ * `full` is a special case: the CLI itself emitted that string (statusline+ * insight, announcement, generated CLAUDE.md, shipped agent defs), so it is+ * normalised to `deep` with a warning rather than hard-rejected.+ *+ * Black-box against the real built CLI binary, matching the convention in+ * security-scan-persistence.test.ts (no test in this repo reconstructs a+ * CommandContext by hand). NOTE: bin/cli.js runs dist/, so `npx tsc` must have+ * run for these to exercise the current source.+ */+import { describe, it, expect, beforeEach, afterEach } from 'vitest';+import { spawnSync } from 'child_process';+import { mkdtempSync, mkdirSync, rmSync, writeFileSync, existsSync, readdirSync } from 'fs';+import { join } from 'path';+import { tmpdir } from 'os';+import { fileURLToPath } from 'url';++const CLI_BIN = fileURLToPath(new URL('../bin/cli.js', import.meta.url));++let scanTarget: string;++/**+ * Run `security scan` against the fixture. stdout and stderr are kept separate:+ * diagnostics go to stderr, and a caller redirecting stdout to a file must not+ * silently receive an empty document with no explanation.+ */+function scan(...args: string[]) {+ const res = spawnSync(process.execPath, [CLI_BIN, 'security', 'scan', '--target', scanTarget, ...args], {+ encoding: 'utf-8',+ timeout: 60_000,+ });+ const stdout = res.stdout ?? '';+ const stderr = res.stderr ?? '';+ return { code: res.status, stdout, stderr, out: `${stdout}${stderr}` };+}++beforeEach(() => {+ scanTarget = mkdtempSync(join(tmpdir(), 'security-scan-enum-'));+ writeFileSync(+ join(scanTarget, 'package.json'),+ JSON.stringify({ name: 'security-scan-enum-fixture', version: '1.0.0' }),+ );+ // MEDIUM at the root. Found by the code-pattern phase, gated on depth !== 'quick'.+ writeFileSync(join(scanTarget, 'root-eval.ts'), 'export const r = (x: string) => eval(x);\n');+ // HIGH at the root, reachable by the secret phase at every depth β so `quick`+ // is demonstrably a shallow scan rather than a no-op.+ writeFileSync(join(scanTarget, 'root-secret.ts'), 'export const k = "AKIAIOSFODNN7EXAMPLE";\n');+ // HIGH at nesting level 3: inside standard's budget (5), outside quick's (3).+ mkdirSync(join(scanTarget, 'l1', 'l2', 'l3'), { recursive: true });+ writeFileSync(+ join(scanTarget, 'l1', 'l2', 'l3', 'deep-secret.ts'),+ 'export const key = "AKIAIOSFODNN7EXAMPLE";\n',+ );+ // HIGH at nesting level 6: inside deep's budget (10), outside standard's (5).+ // Without this, no test distinguishes deep from standard and the deepest scan+ // mode could be gutted while the suite stayed green.+ mkdirSync(join(scanTarget, 'l1', 'l2', 'l3', 'l4', 'l5', 'l6'), { recursive: true });+ writeFileSync(+ join(scanTarget, 'l1', 'l2', 'l3', 'l4', 'l5', 'l6', 'deepest-secret.ts'),+ 'export const key = "AKIAIOSFODNN7EXAMPLE";\n',+ );+});++afterEach(() => {+ rmSync(scanTarget, { recursive: true, force: true });+});++describe('security scan β enum flag validation (fails closed)', () => {+ it('still scans normally when both flags are valid', () => {+ const { code, out } = scan('--depth', 'deep', '--type', 'code');+ // Three secrets plus the eval().+ expect(out).toContain('Total Issues: 4');+ // A HIGH finding must keep failing the critical/high gate.+ expect(code).toBe(1);+ });++ it('rejects an unrecognised --depth instead of scanning shallower', () => {+ const { code, out } = scan('--depth', 'bogus-value', '--type', 'all');+ expect(out).toContain("Invalid --depth 'bogus-value'");+ expect(out).toContain('quick, standard, deep');+ expect(code).toBe(1);+ });++ it('rejects an unrecognised --type instead of skipping every phase', () => {+ const { code, out } = scan('--depth', 'deep', '--type', 'bogus-type');+ expect(out).toContain("Invalid --type 'bogus-type'");+ expect(out).toContain('code, deps, all');+ expect(code).toBe(1);+ });++ it('rejects a case-variant --type, since the phase guards are case-sensitive', () => {+ const { code, out } = scan('--depth', 'deep', '--type', 'CODE');+ expect(out).toContain("Invalid --type 'CODE'");+ expect(code).toBe(1);+ });++ it("rejects --type 'container' as unimplemented rather than reporting clean", () => {+ const { code, out } = scan('--depth', 'deep', '--type', 'container');+ expect(out).toContain("--type 'container' is not implemented yet");+ expect(code).toBe(1);+ });++ it('tells a case-variant container it is unimplemented, not misspelled', () => {+ const { code, out } = scan('--depth', 'deep', '--type', 'Container');+ expect(out).toContain('is not implemented yet');+ expect(code).toBe(1);+ });++ it('never prints the clean-result banner for a rejected flag', () => {+ for (const args of [+ ['--depth', 'bogus-value'],+ ['--type', 'bogus-type'],+ ['--type', 'container'],+ ]) {+ const { out } = scan(...args);+ expect(out).not.toContain('No security issues found!');+ }+ });++ it('sends rejection diagnostics to stderr, so a stdout redirect is not silently empty', () => {+ // A shipped agent invocation redirects stdout to a .json file. If the+ // diagnostic went to stdout it would be swallowed by that redirect; if it+ // went nowhere the agent would get an empty file and no explanation.+ const { stdout, stderr } = scan('--type', 'bogus-type');+ expect(stderr).toContain("Invalid --type 'bogus-type'");+ expect(stdout).not.toContain('Invalid --type');+ });++ it('persists no scan report when a flag is rejected', () => {+ scan('--depth', 'deep', '--type', 'bogus-type');+ expect(existsSync(join(scanTarget, '.claude', 'security-scans'))).toBe(false);+ });++ it('cannot write outside .claude/security-scans via a traversing --type', () => {+ // The report path is built as scan-${scanType}-${depth}.json, so an+ // unvalidated --type could shape it. Against the unpatched command this+ // payload wrote <target>/.claude/escaped-deep.json (measured).+ const { code } = scan('--type', '../../../escaped', '--depth', 'deep');+ expect(code).toBe(1);+ const claudeDir = join(scanTarget, '.claude');+ const stray = existsSync(claudeDir)+ ? readdirSync(claudeDir).filter((f) => f.includes('escaped'))+ : [];+ expect(stray).toEqual([]);+ });++ it('treats an empty --depth as absent and uses the documented default', () => {+ const { out } = scan('--depth', '', '--type', 'code');+ expect(out).toContain('Depth: standard');+ expect(out).not.toContain('Invalid --depth');+ });+});++describe("security scan β `--depth full` is a deprecated alias, not a hard failure", () => {+ // The CLI itself printed `--depth full` in its statusline insight,+ // announcement, generated CLAUDE.md and two shipped agent definitions.+ // Rejecting it would break the invocations we told users to run.+ it('accepts full and still scans', () => {+ const { code, stdout } = scan('--depth', 'full', '--type', 'code');+ expect(stdout).toContain('Total Issues: 4');+ expect(code).toBe(1);+ });++ it('warns on stderr that full is deprecated, naming what it was treated as', () => {+ const { stderr } = scan('--depth', 'full', '--type', 'code');+ expect(stderr).toContain("--depth 'full' is deprecated");+ expect(stderr).toContain("treated as 'deep'");+ });++ it('gives full the deep budget, not the shallowest one it used to fall through to', () => {+ // The original bug: 'full' mapped to 3, shallower than the default 5.+ const { stdout } = scan('--depth', 'full', '--type', 'code');+ expect(stdout).toContain('Depth: deep');+ });+});++describe('security scan β --target fails closed', () => {+ it('rejects a target that does not exist instead of reporting it clean', () => {+ const missing = join(scanTarget, 'no', 'such', 'dir');+ const res = spawnSync(process.execPath, [CLI_BIN, 'security', 'scan', '--target', missing], {+ encoding: 'utf-8',+ timeout: 60_000,+ });+ expect(`${res.stdout}${res.stderr}`).toContain('Target does not exist');+ expect(`${res.stdout}${res.stderr}`).not.toContain('No security issues found!');+ expect(res.status).toBe(1);+ });++ it('fabricates no persisted CLEAN report for a non-existent target', () => {+ // The persisted report is the input to getSecurityStatus, which reports+ // CLEAN on total === 0. A typo used to manufacture that signal, and+ // mkdirSync(recursive) even created the directory tree to hold it.+ const missing = join(scanTarget, 'typo-target');+ spawnSync(process.execPath, [CLI_BIN, 'security', 'scan', '--target', missing], {+ encoding: 'utf-8',+ timeout: 60_000,+ });+ expect(existsSync(missing)).toBe(false);+ });++ it('rejects a target that is a file rather than a directory', () => {+ const file = join(scanTarget, 'root-eval.ts');+ const res = spawnSync(process.execPath, [CLI_BIN, 'security', 'scan', '--target', file], {+ encoding: 'utf-8',+ timeout: 60_000,+ });+ expect(`${res.stdout}${res.stderr}`).toContain('Target is not a directory');+ expect(res.status).toBe(1);+ });+});++describe('security scan β depth maps preserve the documented traversal budgets', () => {+ it('deep reaches deeper than standard', () => {+ // Level-6 secret is inside deep's budget (10) only. Without this assertion+ // deep could be cut to 4 and every other test would still pass.+ const { stdout } = scan('--depth', 'deep', '--type', 'code');+ expect(stdout).toContain('Total Issues: 4');+ });++ it('standard stops short of the level-6 secret', () => {+ const { stdout } = scan('--depth', 'standard', '--type', 'code');+ expect(stdout).toContain('Total Issues: 3');+ });++ it('quick stays shallow β the root secret only, not the nested ones', () => {+ // quick's secret budget (3) excludes l1/l2/l3, and the code-pattern phase is+ // skipped entirely at this depth. Still a real scan reporting a real+ // finding, unlike the silent no-op an unrecognised --type used to produce.+ const { code, stdout } = scan('--depth', 'quick', '--type', 'code');+ expect(stdout).toContain('Total Issues: 1');+ expect(code).toBe(1);+ });+});diff --git a/v3/@claude-flow/cli/src/commands/announcements.ts b/v3/@claude-flow/cli/src/commands/announcements.tsindex 1eb37bdd32..ccf32ee7ae 100644Binary files a/v3/@claude-flow/cli/src/commands/announcements.ts and b/v3/@claude-flow/cli/src/commands/announcements.ts differdiff --git a/v3/@claude-flow/cli/src/commands/security.ts b/v3/@claude-flow/cli/src/commands/security.tsindex 986af34cf2..850deac91b 100644--- a/v3/@claude-flow/cli/src/commands/security.ts+++ b/v3/@claude-flow/cli/src/commands/security.ts@@ -8,16 +8,59 @@import type { Command, CommandContext, CommandResult } from '../types.js';import { output } from '../output.js';import { execSync } from 'node:child_process';+import { existsSync, statSync } from 'node:fs';+import { resolve as resolvePath } from 'node:path';import { createBuiltinAIDefence, type DefenceEngine } from '../security/builtin-aidefence.js';+// Accepted values for `security scan`'s enum flags β the single source of truth+// for both validation and the traversal-depth maps below.+const SCAN_DEPTHS = ['quick', 'standard', 'deep'] as const;+const SCAN_TYPES = ['code', 'deps', 'all'] as const;+type ScanDepth = (typeof SCAN_DEPTHS)[number];+type ScanType = (typeof SCAN_TYPES)[number];++// Real type predicates, not `as` casts. Array.includes() does not narrow a+// string to a literal union on its own, so without these the depth-map lookups+// below need an unchecked assertion β and an unchecked assertion would let a+// future refactor index the maps with an invalid key, yielding `undefined`.+// That matters: `undefined <= 0` is false and `undefined - 1` is NaN, so the+// recursion guard in scanDir would never fire. An unsafe cast here would+// silently disable the depth limiter β the exact class of failure this command+// is being fixed for.+const isScanDepth = (v: string): v is ScanDepth => (SCAN_DEPTHS as readonly string[]).includes(v);+const isScanType = (v: string): v is ScanType => (SCAN_TYPES as readonly string[]).includes(v);++// `full` was never a supported depth, but the CLI itself printed it β the+// statusline insight, the announcement, the release-notes blurb, the CLAUDE.md+// that `init` generates, and two shipped agent definitions all tell people to+// run `security scan --depth full`. Pre-fix it silently fell through to the+// SHALLOWEST traversal, which is the bug. Hard-rejecting it would break every+// caller we ourselves told to use it, so it is normalised to the depth the word+// promised, with a warning. Remove once those emitters have aged out.+const DEPRECATED_SCAN_DEPTHS: Record<string, ScanDepth> = { full: 'deep' };++// `container` has been advertised in --type's help since this command was+// written, but no phase below implements it. Accepting it would reproduce the+// exact bug this validation exists to fix: a documented flag value that scans+// nothing and still prints a clean bill of health. Rejected explicitly, with+// its own message, until a container phase exists.+const UNIMPLEMENTED_SCAN_TYPES = ['container'] as const;++// Directory-recursion limits per depth. Exhaustive records rather than chained+// ternaries, so adding a depth is a compile error here instead of a silently+// shallower scan. CODE_SCAN_DEPTH.quick is unreachable β phase 3 is gated on+// depth !== 'quick' β but is present so the record stays total.+const SECRET_SCAN_DEPTH: Record<ScanDepth, number> = { quick: 3, standard: 5, deep: 10 };+const CODE_SCAN_DEPTH: Record<ScanDepth, number> = { quick: 0, standard: 5, deep: 10 };+// Scan subcommandconst scanCommand: Command = {name: 'scan',- description: 'Run security scan on target (code, dependencies, containers)',+ description: 'Run security scan on target (code, dependencies)',options: [{ name: 'target', short: 't', type: 'string', description: 'Target path or URL to scan', default: '.' },{ name: 'depth', short: 'd', type: 'string', description: 'Scan depth: quick, standard, deep', default: 'standard' },- { name: 'type', type: 'string', description: 'Scan type: code, deps, container, all', default: 'all' },+ { name: 'type', type: 'string', description: 'Scan type: code, deps, all', default: 'all' },{ name: 'output', short: 'o', type: 'string', description: 'Output format: text, json, sarif', default: 'text' },{ name: 'fix', short: 'f', type: 'boolean', description: 'Auto-fix vulnerabilities where possible' },],@@ -27,10 +70,64 @@ const scanCommand: Command = {],action: async (ctx: CommandContext): Promise<CommandResult> => {const target = ctx.flags.target as string || '.';- const depth = ctx.flags.depth as string || 'standard';+ const requestedDepth = ctx.flags.depth as string || 'standard';const scanType = ctx.flags.type as string || 'all';const fix = ctx.flags.fix as boolean;+ // A security scanner must never silently degrade on an unrecognised enum+ // value. An unknown --depth used to fall through to the shallowest+ // traversal (so `--depth full` scanned *less* than the default), and an+ // unknown --type skipped every phase while still reporting "No security+ // issues found!" with exit 0 β a typo was indistinguishable from a clean+ // result, and it silently disabled the critical/high exit-code gate.+ // Fail closed instead, before anything is printed or scanned.+ const aliasedDepth = DEPRECATED_SCAN_DEPTHS[requestedDepth];+ if (aliasedDepth) {+ output.printWarning(+ `--depth '${requestedDepth}' is deprecated and has been treated as '${aliasedDepth}'. ` ++ `Use one of: ${SCAN_DEPTHS.join(', ')}.`,+ );+ }+ const candidateDepth = aliasedDepth ?? requestedDepth;+ if (!isScanDepth(candidateDepth)) {+ output.printError(+ `Invalid --depth '${requestedDepth}'. Expected one of: ${SCAN_DEPTHS.join(', ')}.`,+ );+ return { success: false, exitCode: 1 };+ }+ const depth: ScanDepth = candidateDepth;++ // Case-insensitive so `--type Container` gets the accurate "not implemented"+ // message rather than being reported as a misspelling.+ if ((UNIMPLEMENTED_SCAN_TYPES as readonly string[]).includes(scanType.toLowerCase())) {+ output.printError(+ `--type '${scanType}' is not implemented yet. Expected one of: ${SCAN_TYPES.join(', ')}.`,+ );+ return { success: false, exitCode: 1 };+ }+ if (!isScanType(scanType)) {+ output.printError(+ `Invalid --type '${scanType}'. Expected one of: ${SCAN_TYPES.join(', ')}.`,+ );+ return { success: false, exitCode: 1 };+ }++ // --target names WHAT gets scanned, and was never validated. A path that+ // does not exist (or is a file, not a directory) made every phase read+ // nothing, and the swallowed dir-read catches turned that into zero+ // findings, the clean banner, exit 0 β and a PERSISTED clean report that+ // getSecurityStatus then reports as CLEAN. Same fail-open class as the enum+ // flags, and the likelier typo of the two, so it fails closed too.+ const resolvedTarget = resolvePath(target);+ if (!existsSync(resolvedTarget)) {+ output.printError(`Target does not exist: ${resolvedTarget}`);+ return { success: false, exitCode: 1 };+ }+ if (!statSync(resolvedTarget).isDirectory()) {+ output.printError(`Target is not a directory: ${resolvedTarget}`);+ return { success: false, exitCode: 1 };+ }+output.writeln();output.writeln(output.bold('Security Scan'));output.writeln(output.dim('β'.repeat(50)));@@ -103,7 +200,9 @@ const scanCommand: Command = {];const scanDir = (dir: string, depthLimit: number) => {- if (depthLimit <= 0) return;+ // Positive-test rather than `<= 0`: undefined and NaN both fail this,+ // so a bad budget stops the recursion instead of disabling the limiter.+ if (!(depthLimit > 0)) return;try {const entries = fs.readdirSync(dir, { withFileTypes: true });for (const entry of entries) {@@ -135,7 +234,7 @@ const scanCommand: Command = {} catch { /* dir read error */ }};- const scanDepth = depth === 'deep' ? 10 : depth === 'standard' ? 5 : 3;+ const scanDepth = SECRET_SCAN_DEPTH[depth];scanDir(path.resolve(target), scanDepth);}@@ -151,7 +250,9 @@ const scanCommand: Command = {];const scanCodeDir = (dir: string, depthLimit: number) => {- if (depthLimit <= 0) return;+ // Positive-test rather than `<= 0`: undefined and NaN both fail this,+ // so a bad budget stops the recursion instead of disabling the limiter.+ if (!(depthLimit > 0)) return;try {const entries = fs.readdirSync(dir, { withFileTypes: true });for (const entry of entries) {@@ -184,7 +285,7 @@ const scanCommand: Command = {} catch { /* dir read error */ }};- const scanDepth = depth === 'deep' ? 10 : 5;+ const scanDepth = CODE_SCAN_DEPTH[depth];scanCodeDir(path.resolve(target), scanDepth);}@@ -1297,7 +1398,7 @@ export const securityCommand: Command = {output.writeln();output.writeln('Subcommands:');output.printList([- 'scan - Run security scans on code, deps, containers',+ 'scan - Run security scans on code, deps','cve - Check and manage CVE vulnerabilities','threats - Threat modeling (STRIDE, DREAD, PASTA)','audit - Security audit logging and compliance',diff --git a/v3/@claude-flow/cli/src/funnel/insights.ts b/v3/@claude-flow/cli/src/funnel/insights.tsindex 97b8e15b50..fb4684d574 100644--- a/v3/@claude-flow/cli/src/funnel/insights.ts+++ b/v3/@claude-flow/cli/src/funnel/insights.ts@@ -85,7 +85,7 @@ function securityInsight(ctx: LocalInsightContext): LocalInsight | null {};}if (s.status === 'PENDING') {- return { id: 'insight-scan-pending', text: 'π‘ Security scan pending β Run ruflo security scan --depth full', priority: 70 };+ return { id: 'insight-scan-pending', text: 'π‘ Security scan pending β Run ruflo security scan --depth deep', priority: 70 };}return null;}diff --git a/v3/@claude-flow/cli/src/funnel/messages.ts b/v3/@claude-flow/cli/src/funnel/messages.tsindex c956fa282f..d4cbee4a1a 100644--- a/v3/@claude-flow/cli/src/funnel/messages.ts+++ b/v3/@claude-flow/cli/src/funnel/messages.ts@@ -153,7 +153,7 @@ export const MESSAGES: FunnelMessage[] = [schemaVersion: 1,id: 'local.edu.security-scan',class: 'educational',- text: 'π ruflo security scan --depth full β audits dependencies and config',+ text: 'π ruflo security scan --depth deep β audits dependencies and config',url: 'https://cognitum.one/docs/security',},{diff --git a/v3/@claude-flow/cli/src/init/claudemd-generator.ts b/v3/@claude-flow/cli/src/init/claudemd-generator.tsindex 5aa511e728..2fc6250fcc 100644--- a/v3/@claude-flow/cli/src/init/claudemd-generator.ts+++ b/v3/@claude-flow/cli/src/init/claudemd-generator.ts@@ -260,7 +260,7 @@ function securitySection(): string {- Always use parameterized queries (prevent injection)\`\`\`bash-npx @claude-flow/cli@latest security scan --depth full+npx @claude-flow/cli@latest security scan --depth deepnpx @claude-flow/cli@latest security audit --report\`\`\`