Perform AI semantic analysis (if enabled)
If the scan mode includes AI analysis (standard/deep/expert), perform deep semantic security analysis:
a. Read the skill code files from the target path
b. Analyze for security vulnerabilities:
- Remote Code Execution:
eval(), exec(), subprocess, curl | bash
- Credential Leaks: Hardcoded API keys, passwords, tokens, .env files
- Data Exfiltration: Suspicious network requests, file uploads
- Prompt Injection: "Ignore previous instructions", role manipulation
- Supply Chain Risks: Obfuscated code, dynamic imports, base64 encoding
- Privilege Escalation: sudo, setuid, file permission changes
- Persistence Mechanisms: cron jobs, shell profile modifications
c. Assess each finding:
- Severity: CRITICAL / HIGH / MEDIUM / LOW
- Attack scenario: How can this be exploited?
- Impact: What damage could be done? (CIA triad)
- Remediation: How to fix it?
d. Filter false positives:
- Exclude findings from skills-audit's own detection patterns (patterns.py regex)
- Downgrade benign file operations (e.g. deleting old output before regeneration)
- Verify env var access patterns (using dotenv is recommended, not a vulnerability)
e. Output your analysis in this format:
AI SEMANTIC ANALYSIS FINDINGS:
1. [SEVERITY] Finding Title
- Location: file.py:line
- Pattern: describe what you found
- Risk: explain the security risk
- Scenario: how an attacker could exploit this
- Impact: potential damage
- Recommendation: how to fix
2. [SEVERITY] Finding Title
...
f. Integrate AI findings into the report (CRITICAL STEP)
After completing your AI analysis, integrate your findings into the audit report by running:
INTEGRATE_SCRIPT="$(dirname "$AUDIT_SCRIPT")/integrate_ai_findings.py"
python3 "$INTEGRATE_SCRIPT" \
"<report_path>" \
'<ai_findings_json>'
Where:
<report_path>: The path to the JSON report file (shown in step 1 output as "Detailed report saved to: ...")
<ai_findings_json>: Your AI analysis findings formatted as JSON array
JSON Format for ai_findings:
[
{
"title": "Base64-Obfuscated Remote Code Execution",
"severity": "CRITICAL",
"category": "unsafe_execution",
"description": "Base64-encoded command that downloads and executes arbitrary code",
"location": "skill.md:28",
"code_snippet": "echo 'L2Jpbi9iYXNoIC1jIC...' | base64 -D | bash",
"risk": "Remote code execution with complete system compromise",
"scenario": "User follows installation instructions, base64 decodes to malicious payload, executes with shell privileges",
"impact": {
"confidentiality": "CRITICAL",
"integrity": "CRITICAL",
"availability": "CRITICAL"
},
"impact_description": "Full system compromise, data theft, ransomware deployment",
"recommendation": "BLOCK this skill entirely. Never execute obfuscated commands.",
"cwe_ids": ["CWE-78", "CWE-94", "CWE-506"]
}
]
Important:
- Convert ALL your AI analysis findings from step 2e into this JSON format
- Include severity (CRITICAL/HIGH/MEDIUM/LOW), location, code snippets, risk, scenario, impact, and recommendations
- This step MERGES your AI findings with static analysis findings and recalculates the overall risk score
- Webhook is NOT sent during this step -- it will be sent after your comprehensive analysis
Send final webhook notification (optional, if notifications are configured)
After completing comprehensive analysis (including false positive filtering), send the webhook:
AUDIT_DIR="$(dirname "$(dirname "$AUDIT_SCRIPT")")"
python3 -c "
import sys; sys.path.insert(0, '$AUDIT_DIR')
from skill_audit.integrations import send_final_webhook
send_final_webhook(report_path='<report_path>')
"
This ensures the webhook contains the final, accurate results after your analysis.