Skip to content

aiskillstore/marketplace / skills/0x8506/vibe-security

vibe-security

Verified

Security intelligence for code analysis. Detects SQL injection, XSS, CSRF, authentication issues, crypto failures, and more. Actions: scan, analyze, fix, audit, check, review, secure, validate, sanitize, protect. Languages: JavaScript, TypeScript, Python, PHP, Java, Go, Ruby. Frameworks: Express, Django, Flask, Laravel, Spring, Rails. Vulnerabilities: SQL injection, XSS, CSRF, authentication bypass, authorization issues, command injection, path traversal, insecure deserialization, weak crypto, sensitive data exposure. Topics: input validation, output encoding, parameterized queries, password hashing, session management, CORS, CSP, security headers, rate limiting, dependency scanning.

FileKindSize
SKILL.mdskill md14.2 KB
data/advanced-patterns.csvother3.0 KB
data/compliance-mapping.csvother2.1 KB
data/fix-templates.csvother2.4 KB
data/frameworks.csvother1.1 KB
data/iac-security.csvother2.2 KB
data/languages-extended.csvother1.7 KB
data/patterns.csvother1.5 KB
data/rules.csvother1.5 KB
data/supply-chain.csvother839 B
data/vulnerabilities.csvother1.4 KB
scripts/ast_analyzer.pyexecutablescript9.2 KB
scripts/autofix_engine.pyexecutablescript11.7 KB
scripts/core.pyexecutablescript4.0 KB
scripts/cve_integration.pyexecutablescript9.9 KB
scripts/dataflow_analyzer.pyexecutablescript10.6 KB
scripts/fix_engine.pyexecutablescript13.8 KB
scripts/reporter.pyexecutablescript13.5 KB
scripts/search.pyexecutablescript3.0 KB
skill-report.jsonconfig152.3 KB

scripts/reporter.py

View on GitHub
#!/usr/bin/env python3
"""
Security reporting and analytics engine
Generates comprehensive security reports in multiple formats
"""
import json
from pathlib import Path
from typing import Dict, List, Any, Optional
from datetime import datetime
from collections import defaultdict, Counter
import csv


class SecurityReporter:
    """Generate security reports and analytics"""
    
    def __init__(self, scan_results: Dict[str, Any]):
        self.scan_results = scan_results
        self.vulnerabilities = scan_results.get('vulnerabilities', [])
        
    def generate_html_report(self, output_path: str) -> str:
        """Generate comprehensive HTML report"""
        html = f"""
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vibe Security Report</title>
    <style>
        * {{ margin: 0; padding: 0; box-sizing: border-box; }}
        body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; line-height: 1.6; color: #333; background: #f5f5f5; }}
        .container {{ max-width: 1200px; margin: 0 auto; padding: 20px; }}
        header {{ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 40px 20px; text-align: center; border-radius: 10px; margin-bottom: 30px; }}
        h1 {{ font-size: 2.5em; margin-bottom: 10px; }}
        .meta {{ opacity: 0.9; }}
        .summary {{ display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }}
        .summary-card {{ background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }}
        .summary-card h3 {{ font-size: 0.9em; color: #666; text-transform: uppercase; margin-bottom: 10px; }}
        .summary-card .value {{ font-size: 2.5em; font-weight: bold; }}
        .critical .value {{ color: #e53e3e; }}
        .high .value {{ color: #dd6b20; }}
        .medium .value {{ color: #d69e2e; }}
        .low .value {{ color: #38a169; }}
        .chart {{ background: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); margin-bottom: 30px; }}
        .vulnerability {{ background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); margin-bottom: 20px; border-left: 4px solid #e53e3e; }}
        .vulnerability.high {{ border-left-color: #dd6b20; }}
        .vulnerability.medium {{ border-left-color: #d69e2e; }}
        .vulnerability.low {{ border-left-color: #38a169; }}
        .vuln-header {{ display: flex; justify-content: space-between; align-items: start; margin-bottom: 15px; }}
        .vuln-title {{ font-size: 1.2em; font-weight: bold; }}
        .severity-badge {{ padding: 5px 15px; border-radius: 20px; font-size: 0.85em; font-weight: bold; text-transform: uppercase; }}
        .severity-badge.critical {{ background: #e53e3e; color: white; }}
        .severity-badge.high {{ background: #dd6b20; color: white; }}
        .severity-badge.medium {{ background: #d69e2e; color: white; }}
        .severity-badge.low {{ background: #38a169; color: white; }}
        .vuln-details {{ margin-top: 15px; }}
        .vuln-meta {{ color: #666; font-size: 0.9em; margin-bottom: 10px; }}
        code {{ background: #f7fafc; padding: 2px 6px; border-radius: 4px; font-family: 'Monaco', 'Courier New', monospace; font-size: 0.9em; }}
        pre {{ background: #2d3748; color: #e2e8f0; padding: 15px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }}
        .recommendation {{ background: #ebf8ff; border-left: 4px solid #3182ce; padding: 15px; margin-top: 15px; border-radius: 4px; }}
        footer {{ text-align: center; padding: 40px 20px; color: #666; }}
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>πŸ”’ Vibe Security Report</h1>
            <div class="meta">
                <p>Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}</p>
                <p>Project: {self.scan_results.get('project_name', 'Unknown')}</p>
            </div>
        </header>
        
        {self._generate_summary_section()}
        {self._generate_severity_chart()}
        {self._generate_vulnerabilities_section()}
        
        <footer>
            <p>Generated by Vibe Security</p>
            <p>For questions or support, visit github.com/vibe-security</p>
        </footer>
    </div>
</body>
</html>
"""
        
        Path(output_path).write_text(html)
        return output_path
    
    def _generate_summary_section(self) -> str:
        """Generate summary statistics"""
        stats = self._calculate_statistics()
        
        return f"""
        <div class="summary">
            <div class="summary-card critical">
                <h3>Critical</h3>
                <div class="value">{stats['by_severity']['critical']}</div>
            </div>
            <div class="summary-card high">
                <h3>High</h3>
                <div class="value">{stats['by_severity']['high']}</div>
            </div>
            <div class="summary-card medium">
                <h3>Medium</h3>
                <div class="value">{stats['by_severity']['medium']}</div>
            </div>
            <div class="summary-card low">
                <h3>Low</h3>
                <div class="value">{stats['by_severity']['low']}</div>
            </div>
            <div class="summary-card">
                <h3>Total Files</h3>
                <div class="value">{stats['total_files']}</div>
            </div>
            <div class="summary-card">
                <h3>Languages</h3>
                <div class="value">{stats['total_languages']}</div>
            </div>
        </div>
        """
    
    def _generate_severity_chart(self) -> str:
        """Generate vulnerability type breakdown"""
        type_counts = Counter(v.get('type', 'unknown') for v in self.vulnerabilities)
        
        rows = []
        for vuln_type, count in type_counts.most_common(10):
            rows.append(f"""
                <tr>
                    <td>{vuln_type}</td>
                    <td><strong>{count}</strong></td>
                </tr>
            """)
        
        return f"""
        <div class="chart">
            <h2>Top Vulnerability Types</h2>
            <table style="width: 100%; margin-top: 20px;">
                <thead>
                    <tr style="border-bottom: 2px solid #e2e8f0;">
                        <th style="text-align: left; padding: 10px;">Type</th>
                        <th style="text-align: right; padding: 10px;">Count</th>
                    </tr>
                </thead>
                <tbody>
                    {''.join(rows)}
                </tbody>
            </table>
        </div>
        """
    
    def _generate_vulnerabilities_section(self) -> str:
        """Generate detailed vulnerability listings"""
        html_parts = ['<div class="vulnerabilities">']
        html_parts.append('<h2 style="margin-bottom: 20px;">Vulnerabilities</h2>')
        
        for vuln in self.vulnerabilities:
            severity = vuln.get('severity', 'medium').lower()
            html_parts.append(f"""
                <div class="vulnerability {severity}">
                    <div class="vuln-header">
                        <div class="vuln-title">{vuln.get('type', 'Unknown')}</div>
                        <span class="severity-badge {severity}">{severity}</span>
                    </div>
                    <div class="vuln-meta">
                        πŸ“„ {vuln.get('file', 'Unknown')} β€’ Line {vuln.get('line', '?')}
                    </div>
                    <div class="vuln-details">
                        <p>{vuln.get('message', 'No description available')}</p>
                        {f'<pre>{vuln.get("code", "")}</pre>' if vuln.get('code') else ''}
                        {self._generate_recommendation(vuln)}
                    </div>
                </div>
            """)
        
        html_parts.append('</div>')
        return ''.join(html_parts)
    
    def _generate_recommendation(self, vuln: Dict[str, Any]) -> str:
        """Generate recommendation for vulnerability"""
        if 'remediation' in vuln:
            return f"""
                <div class="recommendation">
                    <strong>πŸ’‘ Recommendation:</strong> {vuln['remediation']}
                </div>
            """
        return ''
    
    def generate_json_report(self, output_path: str) -> str:
        """Generate JSON report"""
        report = {
            'generated_at': datetime.now().isoformat(),
            'project': self.scan_results.get('project_name', 'Unknown'),
            'statistics': self._calculate_statistics(),
            'vulnerabilities': self.vulnerabilities,
            'summary': {
                'total': len(self.vulnerabilities),
                'by_severity': self._count_by_severity(),
                'by_type': dict(Counter(v.get('type') for v in self.vulnerabilities))
            }
        }
        
        Path(output_path).write_text(json.dumps(report, indent=2))
        return output_path
    
    def generate_csv_report(self, output_path: str) -> str:
        """Generate CSV report"""
        with open(output_path, 'w', newline='', encoding='utf-8') as f:
            writer = csv.writer(f)
            writer.writerow(['File', 'Line', 'Severity', 'Type', 'Message', 'Code'])
            
            for vuln in self.vulnerabilities:
                writer.writerow([
                    vuln.get('file', ''),
                    vuln.get('line', ''),
                    vuln.get('severity', ''),
                    vuln.get('type', ''),
                    vuln.get('message', ''),
                    vuln.get('code', '')
                ])
        
        return output_path
    
    def generate_sarif_report(self, output_path: str) -> str:
        """Generate SARIF format for GitHub Code Scanning"""
        sarif = {
            "version": "2.1.0",
            "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
            "runs": [{
                "tool": {
                    "driver": {
                        "name": "Vibe Security",
                        "version": "1.0.0",
                        "informationUri": "https://github.com/vibe-security"
                    }
                },
                "results": []
            }]
        }
        
        for vuln in self.vulnerabilities:
            result = {
                "ruleId": vuln.get('type', 'unknown'),
                "level": self._map_severity_to_sarif(vuln.get('severity', 'warning')),
                "message": {
                    "text": vuln.get('message', 'Security vulnerability detected')
                },
                "locations": [{
                    "physicalLocation": {
                        "artifactLocation": {
                            "uri": vuln.get('file', 'unknown')
                        },
                        "region": {
                            "startLine": vuln.get('line', 1)
                        }
                    }
                }]
            }
            
            sarif["runs"][0]["results"].append(result)
        
        Path(output_path).write_text(json.dumps(sarif, indent=2))
        return output_path
    
    def _calculate_statistics(self) -> Dict[str, Any]:
        """Calculate report statistics"""
        files = set(v.get('file') for v in self.vulnerabilities if v.get('file'))
        languages = set(v.get('language') for v in self.vulnerabilities if v.get('language'))
        
        return {
            'total_vulnerabilities': len(self.vulnerabilities),
            'total_files': len(files),
            'total_languages': len(languages),
            'by_severity': self._count_by_severity(),
            'by_type': dict(Counter(v.get('type') for v in self.vulnerabilities)),
            'by_language': dict(Counter(v.get('language') for v in self.vulnerabilities))
        }
    
    def _count_by_severity(self) -> Dict[str, int]:
        """Count vulnerabilities by severity"""
        counts = Counter(v.get('severity', 'medium').lower() for v in self.vulnerabilities)
        return {
            'critical': counts.get('critical', 0),
            'high': counts.get('high', 0),
            'medium': counts.get('medium', 0),
            'low': counts.get('low', 0)
        }
    
    def _map_severity_to_sarif(self, severity: str) -> str:
        """Map severity to SARIF level"""
        severity_map = {
            'critical': 'error',
            'high': 'error',
            'medium': 'warning',
            'low': 'note'
        }
        return severity_map.get(severity.lower(), 'warning')


def main():
    """CLI interface"""
    import argparse
    
    parser = argparse.ArgumentParser(description='Generate security reports')
    parser.add_argument('input', help='Input scan results (JSON)')
    parser.add_argument('--format', choices=['html', 'json', 'csv', 'sarif'], default='html')
    parser.add_argument('--output', '-o', required=True, help='Output file path')
    
    args = parser.parse_args()
    
    # Load scan results
    with open(args.input, 'r') as f:
        scan_results = json.load(f)
    
    reporter = SecurityReporter(scan_results)
    
    if args.format == 'html':
        output = reporter.generate_html_report(args.output)
    elif args.format == 'json':
        output = reporter.generate_json_report(args.output)
    elif args.format == 'csv':
        output = reporter.generate_csv_report(args.output)
    elif args.format == 'sarif':
        output = reporter.generate_sarif_report(args.output)
    
    print(f"βœ… Report generated: {output}")


if __name__ == '__main__':
    main()
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall