Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

fix(security): mark absent manifests and malformed audit reports incomplete

Dragan Spiridonov2a445ea5585a
diff --git a/v3/@claude-flow/cli/__tests__/security-audit-no-lockfile-4124.test.ts b/v3/@claude-flow/cli/__tests__/security-audit-no-lockfile-4124.test.ts
index b921533de7..13ac4d9641 100644
--- a/v3/@claude-flow/cli/__tests__/security-audit-no-lockfile-4124.test.ts
+++ b/v3/@claude-flow/cli/__tests__/security-audit-no-lockfile-4124.test.ts
@@ -7,7 +7,7 @@
*/
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { spawnSync } from 'child_process';
-import { mkdtempSync, rmSync, writeFileSync, readFileSync } from 'fs';
+import { mkdtempSync, rmSync, writeFileSync, readFileSync, unlinkSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
import { fileURLToPath } from 'url';
@@ -32,6 +32,7 @@ describe('interpretNpmAudit', () => {
});
it('rejects output with no vulnerability report and non-JSON output', () => {
expect(interpretNpmAudit('{}').ok).toBe(false);
+ expect(interpretNpmAudit('{"vulnerabilities":[]}').ok).toBe(false);
expect(interpretNpmAudit('not json').ok).toBe(false);
});
it('accepts a real report, including an empty one', () => {
@@ -60,6 +61,14 @@ describe('security scan / cve on a lockfile-less (pnpm) project', () => {
expect(getSecurityStatus(dir).status).toBe('PENDING');
});
+ it('an explicit dependency scan without package.json is incomplete, not CLEAN', () => {
+ unlinkSync(join(dir, 'package.json'));
+ const res = spawnSync(process.execPath, [CLI_BIN, 'security', 'scan', '--target', dir, '--depth', 'quick', '--type', 'deps'], { encoding: 'utf-8', timeout: 60_000 });
+ expect(res.status).toBe(2);
+ expect(`${res.stdout}${res.stderr}`).toContain('Dependency scan skipped');
+ expect(getSecurityStatus(dir).status).toBe('PENDING');
+ });
+
it('cve --list exits non-zero instead of printing "No known vulnerabilities"', () => {
const res = spawnSync(process.execPath, [CLI_BIN, 'security', 'cve', '--list'], { cwd: dir, encoding: 'utf-8', timeout: 60_000 });
const out = `${res.stdout}${res.stderr}`;
diff --git a/v3/@claude-flow/cli/src/commands/security.ts b/v3/@claude-flow/cli/src/commands/security.ts
index 4397e20795..751e8c94db 100644
--- a/v3/@claude-flow/cli/src/commands/security.ts
+++ b/v3/@claude-flow/cli/src/commands/security.ts
@@ -231,6 +231,8 @@ const scanCommand: Command = {
});
}
}
+ } else {
+ depsSkipped = 'No package.json found in the scan target; dependency scan could not run.';
}
} catch (err) { depsSkipped = `npm audit could not run: ${err instanceof Error ? err.message : String(err)}`; }
}
@@ -464,7 +466,7 @@ export function interpretNpmAudit(raw: string, dir?: string): NpmAuditResult {
const summary = typeof audit.error.summary === 'string' ? audit.error.summary : 'npm audit failed.';
return { ok: false, reason: `npm audit failed (${code}): ${summary}${code === 'ENOLOCK' ? auditHint(dir) : ''}` };
}
- if (!audit || typeof audit !== 'object' || !audit.vulnerabilities || typeof audit.vulnerabilities !== 'object') {
+ if (!audit || typeof audit !== 'object' || !audit.vulnerabilities || typeof audit.vulnerabilities !== 'object' || Array.isArray(audit.vulnerabilities)) {
return { ok: false, reason: 'npm audit returned no vulnerability report.' };
}
return { ok: true, vulnerabilities: audit.vulnerabilities as Record<string, NpmAuditVuln> };