mirror of
https://github.com/KeygraphHQ/shannon.git
synced 2026-05-19 15:38:23 +02:00
100 lines
3.8 KiB
JavaScript
100 lines
3.8 KiB
JavaScript
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
import { path, fs } from 'zx';
|
|
import chalk from 'chalk';
|
|
import { validateQueueAndDeliverable } from './queue-validation.js';
|
|
|
|
// Factory function for vulnerability queue validators
|
|
function createVulnValidator(vulnType) {
|
|
return async (sourceDir) => {
|
|
try {
|
|
await validateQueueAndDeliverable(vulnType, sourceDir);
|
|
return true;
|
|
} catch (error) {
|
|
console.log(chalk.yellow(` Queue validation failed for ${vulnType}: ${error.message}`));
|
|
return false;
|
|
}
|
|
};
|
|
}
|
|
|
|
// Factory function for exploit deliverable validators
|
|
function createExploitValidator(vulnType) {
|
|
return async (sourceDir) => {
|
|
const evidenceFile = path.join(sourceDir, 'deliverables', `${vulnType}_exploitation_evidence.md`);
|
|
return await fs.pathExists(evidenceFile);
|
|
};
|
|
}
|
|
|
|
// MCP agent mapping - assigns each agent to a specific Playwright instance to prevent conflicts
|
|
export const MCP_AGENT_MAPPING = Object.freeze({
|
|
// Phase 1: Pre-reconnaissance (actual prompt name is 'pre-recon-code')
|
|
// NOTE: Pre-recon is pure code analysis and doesn't use browser automation,
|
|
// but assigning MCP server anyway for consistency and future extensibility
|
|
'pre-recon-code': 'playwright-agent1',
|
|
|
|
// Phase 2: Reconnaissance (actual prompt name is 'recon')
|
|
'recon': 'playwright-agent2',
|
|
|
|
// Phase 3: Vulnerability Analysis (5 parallel agents)
|
|
'vuln-injection': 'playwright-agent1',
|
|
'vuln-xss': 'playwright-agent2',
|
|
'vuln-auth': 'playwright-agent3',
|
|
'vuln-ssrf': 'playwright-agent4',
|
|
'vuln-authz': 'playwright-agent5',
|
|
|
|
// Phase 4: Exploitation (5 parallel agents - same as vuln counterparts)
|
|
'exploit-injection': 'playwright-agent1',
|
|
'exploit-xss': 'playwright-agent2',
|
|
'exploit-auth': 'playwright-agent3',
|
|
'exploit-ssrf': 'playwright-agent4',
|
|
'exploit-authz': 'playwright-agent5',
|
|
|
|
// Phase 5: Reporting (actual prompt name is 'report-executive')
|
|
// NOTE: Report generation is typically text-based and doesn't use browser automation,
|
|
// but assigning MCP server anyway for potential screenshot inclusion or future needs
|
|
'report-executive': 'playwright-agent3'
|
|
});
|
|
|
|
// Direct agent-to-validator mapping - much simpler than pattern matching
|
|
export const AGENT_VALIDATORS = Object.freeze({
|
|
// Pre-reconnaissance agent - validates the code analysis deliverable created by the agent
|
|
'pre-recon': async (sourceDir) => {
|
|
const codeAnalysisFile = path.join(sourceDir, 'deliverables', 'code_analysis_deliverable.md');
|
|
return await fs.pathExists(codeAnalysisFile);
|
|
},
|
|
|
|
// Reconnaissance agent
|
|
'recon': async (sourceDir) => {
|
|
const reconFile = path.join(sourceDir, 'deliverables', 'recon_deliverable.md');
|
|
return await fs.pathExists(reconFile);
|
|
},
|
|
|
|
// Vulnerability analysis agents
|
|
'injection-vuln': createVulnValidator('injection'),
|
|
'xss-vuln': createVulnValidator('xss'),
|
|
'auth-vuln': createVulnValidator('auth'),
|
|
'ssrf-vuln': createVulnValidator('ssrf'),
|
|
'authz-vuln': createVulnValidator('authz'),
|
|
|
|
// Exploitation agents
|
|
'injection-exploit': createExploitValidator('injection'),
|
|
'xss-exploit': createExploitValidator('xss'),
|
|
'auth-exploit': createExploitValidator('auth'),
|
|
'ssrf-exploit': createExploitValidator('ssrf'),
|
|
'authz-exploit': createExploitValidator('authz'),
|
|
|
|
// Executive report agent
|
|
'report': async (sourceDir) => {
|
|
const reportFile = path.join(sourceDir, 'deliverables', 'comprehensive_security_assessment_report.md');
|
|
|
|
const reportExists = await fs.pathExists(reportFile);
|
|
|
|
if (!reportExists) {
|
|
console.log(chalk.red(` ❌ Missing required deliverable: comprehensive_security_assessment_report.md`));
|
|
}
|
|
|
|
return reportExists;
|
|
}
|
|
}); |