pury
Version:
🛡️ AI-powered security scanner with advanced threat detection, dual reporting system (detailed & summary), and comprehensive code analysis
60 lines (58 loc) • 2.32 kB
JavaScript
import { promises as fs } from 'fs';
export class HtmlReporter {
async output(report) {
const html = this.generateHTML(report);
console.log(html);
}
async writeToFile(report, filePath) {
const html = this.generateHTML(report);
await fs.writeFile(filePath, html, 'utf8');
}
generateHTML(report) {
return `
<html>
<head>
<title>PuryAI Security Report</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
.header { background: #2196F3; color: white; padding: 20px; border-radius: 5px; }
.summary { margin: 20px 0; padding: 15px; background: #f5f5f5; border-radius: 5px; }
.finding { margin: 10px 0; padding: 15px; border-left: 4px solid #ccc; background: #fff; }
.critical { border-left-color: #f44336; }
.high { border-left-color: #ff9800; }
.medium { border-left-color: #ffeb3b; }
.low { border-left-color: #4caf50; }
</style>
</head>
<body>
<div class="header">
<h1>🛡️ PuryAI Security Report</h1>
<p>Generated on ${new Date(report.metadata.timestamp).toLocaleString()}</p>
</div>
<div class="summary">
<h2>📊 Summary</h2>
<p><strong>Files Scanned:</strong> ${report.summary.filesScanned}</p>
<p><strong>Threats Found:</strong> ${report.summary.threatsFound}</p>
<p><strong>Scan Duration:</strong> ${(report.summary.scanDuration / 1000).toFixed(2)}s</p>
</div>
<div class="findings">
<h2>🔍 Findings</h2>
${report.findings
.map(finding => `
<div class="finding ${finding.severity}">
<h3>${finding.title}</h3>
<p><strong>File:</strong> ${finding.file}${finding.line ? `:${finding.line}` : ''}</p>
<p><strong>Severity:</strong> ${finding.severity.toUpperCase()}</p>
<p><strong>Description:</strong> ${finding.description}</p>
${finding.evidence ? `<p><strong>Evidence:</strong> <code>${finding.evidence}</code></p>` : ''}
${finding.suggestion ? `<p><strong>Suggestion:</strong> ${finding.suggestion}</p>` : ''}
</div>
`)
.join('')}
</div>
</body>
</html>`;
}
}
//# sourceMappingURL=html.js.map