Back to agents
Agent #8
š Security Vulnerability Scanning Agent
This agent scans code for security vulnerabilities including SQL injection, XSS, insecure dependencies, hardcoded secrets, and authentication issues. It provides fixes and prevention strategies. python 08_security_scan.py /path/to/code.py python 08_security_scan.py /path/to/requirements.txt
Key Features
- āOWASP Top 10 detection
- āSQL injection prevention
- āXSS vulnerability scanning
- āSecret detection
- āDependency CVE analysis
Implementation
Download .py08_security_scan.py
#!/usr/bin/env python3
"""
Security Vulnerability Scanning Agent
This agent scans code for security vulnerabilities including SQL injection,
XSS, insecure dependencies, hardcoded secrets, and authentication issues.
It provides fixes and prevention strategies.
Usage:
python 08_security_scan.py /path/to/code.py
python 08_security_scan.py /path/to/requirements.txt
"""
import sys
from anthropic import Anthropic
def main():
if len(sys.argv) < 2:
print("Usage: python 08_security_scan.py <file_path>")
sys.exit(1)
target = " ".join(sys.argv[1:])
client = Anthropic()
system_prompt = """You are a security expert. Your job is to:
1. Identify OWASP Top 10 vulnerabilities
2. Detect insecure coding patterns
3. Find hardcoded secrets and credentials
4. Analyze dependency vulnerabilities
5. Check authentication/authorization issues
6. Provide secure code fixes
7. Recommend security best practices
Be thorough and provide severity ratings for each issue."""
task = f"""Scan the following for security vulnerabilities:
{target}
Provide:
1. Vulnerability identification with:
- Type (SQL Injection, XSS, CSRF, etc.)
- Severity (Critical, High, Medium, Low)
- Location in code
- Impact description
2. For each vulnerability:
- Detailed explanation
- Proof of concept / attack scenario
- Secure code fix
- Testing approach
3. Dependency analysis:
- Known CVEs
- Recommended updates
4. Authentication review:
- Password handling
- Session management
- API key usage
5. Hardcoded secrets detection
6. Compliance considerations (GDPR, etc.)
7. Prevention checklist for the team"""
print("š Starting Security Scan Agent...\n")
print("=" * 60)
try:
with client.messages.stream(
model="claude-opus-4-7",
max_tokens=3500,
system=system_prompt,
messages=[{"role": "user", "content": task}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
print("\n" + "=" * 60)
print("\nā
Security scan complete!")
except Exception as e:
print(f"\nā Error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()
How to Use
This agent is designed to be run from the command line:
python 08_security_scan.py <input>The agent will stream its response to the console as it works through the task. Use Ctrl+C to interrupt at any time.
Quick Download
08_security_scan.pyFile
08_security_scan.py
Language
Python 3.8+
Dependencies
anthropic
Setup
- 1. Install:
pip install anthropic - 2. Download the .py file
- 3. Set ANTHROPIC_API_KEY
- 4. Run:
python 08_security_scan.py