🐛 👁️ Argus — Code Intelligence Scanner
Static analysis for your codebase — finds real bugs, security holes, and code smells before
they hit production. No external API needed. Works on Python and JavaScript files.
What you get:
- Hardcoded passwords, API keys, and tokens flagged as Critical
- SQL injection and prototype pollution detection
- Bare excepts, mutable defaults, wildcard imports, and 13 other patterns
- Severity-filtered output: focus on Critical first, drill down from there
bug_report_[DATE].md + bug_report_[DATE].json with full fix suggestions
Quick Start
SOURCE_PATH="./src" LANGUAGE="python" SEVERITY_FILTER="high" python skill.py
Security
Reads local files only. Nothing transmitted.
Step 1 — Install dependencies
import subprocess, sys
subprocess.run([sys.executable,"-m","pip","install","rich","--break-system-packages","--quiet"], check=True)
Step 2 — Scan for Bugs
import os, re, json
from pathlib import Path
from datetime import date
from rich.console import Console
from rich.table import Table
from rich.panel import Panel
from rich import box
console = Console()
SRC_PATH = os.environ.get("SOURCE_PATH", ".")
LANGUAGE = os.environ.get("LANGUAGE", "auto").lower()
SEV_FILTER = os.environ.get("SEVERITY_FILTER", "all").lower()
TODAY = date.today()
src = Path(SRC_PATH)
if not src.exists():
console.print(Panel(f"[red]Path not found: {SRC_PATH}[/red]", border_style="red")); raise SystemExit(1)
console.print(Panel.fit(f"[bold red]🐛 👁️ Argus — Code Intelligence Scanner[/bold red]\nScanning: [cyan]{SRC_PATH}[/cyan] | Language: [yellow]{LANGUAGE}[/yellow] | Filter: [green]{SEV_FILTER}[/green]", border_style="red"))
# Detect language
def detect_lang(path: Path) -> str:
py = len(list(path.rglob("*.py") if path.is_dir() else [path] if str(path).endswith(".py") else []))
js = len(list(path.rglob("*.js") if path.is_dir() else [path] if str(path).endswith(".js") else []))
if py == 0 and js == 0:
return "python" # default; user can override with LANGUAGE env var
return "python" if py >= js else "javascript"
lang = LANGUAGE if LANGUAGE != "auto" else detect_lang(src)
# Bug patterns
PYTHON_RULES = [
("PY001", "critical", "security", r"eval\s*\(", "eval() is dangerous — executes arbitrary code", "Use ast.literal_eval() for safe parsing"),
("PY002", "critical", "security", r"exec\s*\(", "exec() executes arbitrary strings", "Refactor to avoid dynamic code execution"),
("PY003", "critical", "security", r'password\s*=\s*["'][^"']{3,}', "Hardcoded password", "Use environment variables: os.environ.get('PASSWORD')"),
("PY004", "high", "security", r"pickle\.loads?\(", "pickle.load is unsafe with untrusted data", "Use json.loads() for safe deserialization"),
("PY005", "high", "bug", r"except\s*:", "Bare except catches ALL exceptions including KeyboardInterrupt", "Use except Exception: or catch specific exception types"),
("PY006", "high", "bug", r"==\s*None|None\s*==", "Use 'is None' not '== None' — can produce unexpected results", "Replace == None with is None"),
("PY007", "medium", "bug", r"def\s+\w+\(.*=\[\]", "Mutable default argument — shared across calls", "Use None as default: def f(x=None): x = x or []"),
("PY008", "medium", "security", r"shell\s*=\s*True", "subprocess with shell=True is a command injection risk", "Use shell=False and pass args as a list"),
("PY009", "medium", "smell", r"import \*", "Wildcard import pollutes namespace and hides dependencies", "Import only what you need: from module import func"),
("PY010", "low", "smell", r"print\s*\(", "print() left in code — likely debug statement", "Use logging module instead of print for production code"),
("PY011", "critical", "security", r"(?i)(api_key|api_secret|secret_key|access_token|auth_token)\s*=\s*[\x27\x22][^\x27\x22]{8,}", "Hardcoded API key or token", "Store in environment variable: os.environ.get('API_KEY')"),
("PY012", "high", "security", r"execute\s*\(.*%.*\)|execute\s*\(.*\.format\(|execute\s*\(.*f[\x22\x27]", "Possible SQL injection via string formatting", "Use parameterised queries: cursor.execute(sql, (value,))"),
("PY013", "medium", "security", r"open\s*\((?![^)\n]*\bencoding)[^)\n]*[\x27\x22]w[\x27\x22]", "File opened for write without encoding", "Add encoding='utf-8': open(path, 'w', encoding='utf-8')"),
]
JS_RULES = [
("JS001", "critical", "security", r"eval\s*\(", "eval() executes arbitrary code", "Remove eval — refactor logic"),
("JS002", "critical", "security", r"innerHTML\s*=", "innerHTML is an XSS vector if it contains user input", "Use textContent or sanitize input first"),
("JS003", "high", "bug", r"==\s*null|null\s*==", "Use === null for strict equality check", "Replace == null with === null"),
("JS004", "high", "bug", r"catch\s*\(\s*\)", "Empty catch silently swallows errors", "Log the error: catch(e) { console.error(e); }"),
("JS005", "medium", "bug", r"var\s+", "var has function scope and hoisting issues", "Use const or let instead of var"),
("JS006", "medium", "security", r"localStorage\.setItem.*password", "Storing passwords in localStorage is insecure", "Never store credentials in localStorage"),
("JS007", "critical", "security", r"(?i)(api_key|apikey|api_secret|access_token|auth_token)\s*[:=]\s*[\x27\x22][^\x27\x22]{8,}", "Hardcoded API key or token", "Use environment variable: process.env.API_KEY"),
("JS008", "high", "security", r"__proto__|constructor\.prototype", "Prototype pollution vulnerability", "Validate input keys; use Object.create(null) for safe maps"),
("JS009", "high", "security", r"\$\{.*\}.*query|query.*\$\{|db\.query\s*\(", "Possible SQL/NoSQL injection via template literal", "Use parameterised queries or an ORM"),
]
RULES = PYTHON_RULES if lang == "python" else JS_RULES
SEV_ORDER = {"critical": 0, "high": 1, "medium": 2, "low": 3}
SEV_SHOW = {"all": 4, "medium": 2, "high": 1, "critical": 0}.get(SEV_FILTER, 4)
# Get files
ext = "*.py" if lang == "python" else "*.js"
files = list(src.rglob(ext) if src.is_dir() else [src])
files = [f for f in files if ".git" not in str(f) and "node_modules" not in str(f) and "venv" not in str(f)][:50]
console.print(f"[dim]Scanning {len(files)} {lang} files…[/dim]")
# Scan
findings = []
for fpath in files:
try:
lines = fpath.read_text(encoding="utf-8", errors="ignore").splitlines()
for i, line in enumerate(lines, 1):
for rule_id, sev, category, pattern, message, fix in RULES:
if SEV_ORDER.get(sev, 3) <= SEV_SHOW and re.search(pattern, line):
findings.append({"id": rule_id, "severity": sev, "category": category,
"file": str(fpath.relative_to(src) if src.is_dir() else fpath),
"line": i, "code": line.strip()[:80], "message": message, "fix": fix})
except Exception: pass
# Dedupe and sort
seen = set(); unique = []
for f in findings:
key = (f["id"], f["file"], f["line"])
if key not in seen: seen.add(key); unique.append(f)
unique.sort(key=lambda x: (SEV_ORDER.get(x["severity"],3), x["file"], x["line"]))
# Stats
from collections import Counter
sev_counts = Counter(f["severity"] for f in unique)
cat_counts = Counter(f["category"] for f in unique)
console.print()
console.print(Panel(
f"Files scanned: [cyan]{len(files)}[/cyan] | Issues found: [bold]{len(unique)}[/bold]\n"
f"[red]Critical: {sev_counts['critical']}[/red] [yellow]High: {sev_counts['high']}[/yellow] [blue]Medium: {sev_counts['medium']}[/blue] [dim]Low: {sev_counts['low']}[/dim]\n"
f"Security: {cat_counts['security']} | Bugs: {cat_counts['bug']} | Smells: {cat_counts['smell']}",
title="[bold]📊 Scan Summary[/bold]", border_style="red" if sev_counts["critical"] > 0 else "yellow"
))
if unique:
console.print()
display_count = min(len(unique), 25)
title_suffix = f" — showing {display_count} of {len(unique)}" if len(unique) > 25 else ""
t = Table(title=f"🐛 Issues Found ({len(unique)}){title_suffix}", box=box.ROUNDED, show_lines=True, border_style="red")
t.add_column("ID", width=7, style="dim"); t.add_column("Sev", width=10); t.add_column("File:Line", style="cyan", width=28)
t.add_column("Issue", style="white", width=35); t.add_column("Fix", style="green", width=40)
SEV_COLOR = {"critical":"bold red","high":"yellow","medium":"blue","low":"dim"}
for f in unique[:25]:
col = SEV_COLOR.get(f["severity"],"white")
t.add_row(f["id"], f"[{col}]{f['severity']}[/{col}]", f"{f['file'][:22]}:{f['line']}", f["message"][:35], f["fix"][:40])
console.print(t)
else:
console.print(Panel("[green]✅ No issues found matching your filter criteria![/green]", border_style="green"))
# Save
out_path = f"bug_report_{TODAY}.json"
with open(out_path,"w", encoding="utf-8") as f:
json.dump({"scanned_files": len(files), "language": lang, "findings": unique, "generated": str(TODAY)}, f, indent=2)
md_path = f"bug_report_{TODAY}.md"
with open(md_path,"w", encoding="utf-8") as f:
f.write(f"# Bug Hunt Report — {TODAY}\n\n**Files:** {len(files)} | **Issues:** {len(unique)}\n\n")
f.write("| ID | Severity | File:Line | Issue | Fix |\n|-----|---------|-----------|-------|-----|\n")
for fi in unique: f.write(f"| {fi['id']} | {fi['severity']} | {fi['file'][:25]}:{fi['line']} | {fi['message'][:40]} | {fi['fix'][:40]} |\n")
console.print()
console.print(Panel(f"[bold green]✅ Scan complete![/bold green]\n\n📄 [cyan]{md_path}[/cyan]\n📄 [cyan]{out_path}[/cyan]\n\n[bold]What to do next:[/bold]\n1. [yellow]Fix Critical issues first[/yellow] — security and crash bugs\n2. [yellow]Fix High severity next[/yellow] — these will cause real problems\n3. [yellow]Run again after fixes[/yellow] to confirm clean\n4. [yellow]Add to CI/CD pipeline[/yellow] so every commit is scanned",title="[bold red]🐛 👁️ Argus — Code Intelligence Scanner — Done[/bold red]",border_style="red"))
1---2name: argus3description: "Argus — The Hundred-Eyed. Scan your Python or JavaScript codebase for bugs, security vulnerabilities, code smells, and common anti-patterns — get a prioritised fix list with line numbers, severity ratings, and suggested corrections for every issue found. Nothing escapes Argus."4version: "1.0.0"5metadata:6 source: https://skillmd.com/skills/luokai0/argus7 openclaw:8 requires:9 env: []10 bins: [python3, pip3]11 primaryEnv: "SOURCE_PATH"12 homepage: https://clawhub.ai/skills/argus13 emoji: "👁️"14 tags: [code, bugs, security, scanner, python, javascript, argus, debugging, linting]15 envVars:16 - name: SOURCE_PATH17 description: "File or directory to scan"18 required: true19 - name: LANGUAGE20 description: "Language to scan: python / javascript / auto"21 required: false22 default: "auto"23 - name: SEVERITY_FILTER24 description: "Minimum severity to show: critical / high / medium / all"25 required: false26 default: "all"27---2829# 🐛 👁️ Argus — Code Intelligence Scanner3031Static analysis for your codebase — finds real bugs, security holes, and code smells before32they hit production. No external API needed. Works on Python and JavaScript files.3334**What you get:**35- Hardcoded passwords, API keys, and tokens flagged as Critical36- SQL injection and prototype pollution detection37- Bare excepts, mutable defaults, wildcard imports, and 13 other patterns38- Severity-filtered output: focus on Critical first, drill down from there39- `bug_report_[DATE].md` + `bug_report_[DATE].json` with full fix suggestions4041## Quick Start42```bash43SOURCE_PATH="./src" LANGUAGE="python" SEVERITY_FILTER="high" python skill.py44```4546## Security47Reads local files only. Nothing transmitted.4849---5051## Step 1 — Install dependencies52```python53import subprocess, sys54subprocess.run([sys.executable,"-m","pip","install","rich","--break-system-packages","--quiet"], check=True)55```5657## Step 2 — Scan for Bugs58```python59import os, re, json60from pathlib import Path61from datetime import date62from rich.console import Console63from rich.table import Table64from rich.panel import Panel65from rich import box6667console = Console()68SRC_PATH = os.environ.get("SOURCE_PATH", ".")69LANGUAGE = os.environ.get("LANGUAGE", "auto").lower()70SEV_FILTER = os.environ.get("SEVERITY_FILTER", "all").lower()71TODAY = date.today()7273src = Path(SRC_PATH)74if not src.exists():75 console.print(Panel(f"[red]Path not found: {SRC_PATH}[/red]", border_style="red")); raise SystemExit(1)7677console.print(Panel.fit(f"[bold red]🐛 👁️ Argus — Code Intelligence Scanner[/bold red]\nScanning: [cyan]{SRC_PATH}[/cyan] | Language: [yellow]{LANGUAGE}[/yellow] | Filter: [green]{SEV_FILTER}[/green]", border_style="red"))7879# Detect language80def detect_lang(path: Path) -> str:81 py = len(list(path.rglob("*.py") if path.is_dir() else [path] if str(path).endswith(".py") else []))82 js = len(list(path.rglob("*.js") if path.is_dir() else [path] if str(path).endswith(".js") else []))83 if py == 0 and js == 0:84 return "python" # default; user can override with LANGUAGE env var85 return "python" if py >= js else "javascript"8687lang = LANGUAGE if LANGUAGE != "auto" else detect_lang(src)8889# Bug patterns90PYTHON_RULES = [91 ("PY001", "critical", "security", r"eval\s*\(", "eval() is dangerous — executes arbitrary code", "Use ast.literal_eval() for safe parsing"),92 ("PY002", "critical", "security", r"exec\s*\(", "exec() executes arbitrary strings", "Refactor to avoid dynamic code execution"),93 ("PY003", "critical", "security", r'password\s*=\s*["'][^"']{3,}', "Hardcoded password", "Use environment variables: os.environ.get('PASSWORD')"),94 ("PY004", "high", "security", r"pickle\.loads?\(", "pickle.load is unsafe with untrusted data", "Use json.loads() for safe deserialization"),95 ("PY005", "high", "bug", r"except\s*:", "Bare except catches ALL exceptions including KeyboardInterrupt", "Use except Exception: or catch specific exception types"),96 ("PY006", "high", "bug", r"==\s*None|None\s*==", "Use 'is None' not '== None' — can produce unexpected results", "Replace == None with is None"),97 ("PY007", "medium", "bug", r"def\s+\w+\(.*=\[\]", "Mutable default argument — shared across calls", "Use None as default: def f(x=None): x = x or []"),98 ("PY008", "medium", "security", r"shell\s*=\s*True", "subprocess with shell=True is a command injection risk", "Use shell=False and pass args as a list"),99 ("PY009", "medium", "smell", r"import \*", "Wildcard import pollutes namespace and hides dependencies", "Import only what you need: from module import func"),100 ("PY010", "low", "smell", r"print\s*\(", "print() left in code — likely debug statement", "Use logging module instead of print for production code"),101 ("PY011", "critical", "security", r"(?i)(api_key|api_secret|secret_key|access_token|auth_token)\s*=\s*[\x27\x22][^\x27\x22]{8,}", "Hardcoded API key or token", "Store in environment variable: os.environ.get('API_KEY')"),102 ("PY012", "high", "security", r"execute\s*\(.*%.*\)|execute\s*\(.*\.format\(|execute\s*\(.*f[\x22\x27]", "Possible SQL injection via string formatting", "Use parameterised queries: cursor.execute(sql, (value,))"),103 ("PY013", "medium", "security", r"open\s*\((?![^)\n]*\bencoding)[^)\n]*[\x27\x22]w[\x27\x22]", "File opened for write without encoding", "Add encoding='utf-8': open(path, 'w', encoding='utf-8')"),104]105JS_RULES = [106 ("JS001", "critical", "security", r"eval\s*\(", "eval() executes arbitrary code", "Remove eval — refactor logic"),107 ("JS002", "critical", "security", r"innerHTML\s*=", "innerHTML is an XSS vector if it contains user input", "Use textContent or sanitize input first"),108 ("JS003", "high", "bug", r"==\s*null|null\s*==", "Use === null for strict equality check", "Replace == null with === null"),109 ("JS004", "high", "bug", r"catch\s*\(\s*\)", "Empty catch silently swallows errors", "Log the error: catch(e) { console.error(e); }"),110 ("JS005", "medium", "bug", r"var\s+", "var has function scope and hoisting issues", "Use const or let instead of var"),111 ("JS006", "medium", "security", r"localStorage\.setItem.*password", "Storing passwords in localStorage is insecure", "Never store credentials in localStorage"),112 ("JS007", "critical", "security", r"(?i)(api_key|apikey|api_secret|access_token|auth_token)\s*[:=]\s*[\x27\x22][^\x27\x22]{8,}", "Hardcoded API key or token", "Use environment variable: process.env.API_KEY"),113 ("JS008", "high", "security", r"__proto__|constructor\.prototype", "Prototype pollution vulnerability", "Validate input keys; use Object.create(null) for safe maps"),114 ("JS009", "high", "security", r"\$\{.*\}.*query|query.*\$\{|db\.query\s*\(", "Possible SQL/NoSQL injection via template literal", "Use parameterised queries or an ORM"),115]116RULES = PYTHON_RULES if lang == "python" else JS_RULES117SEV_ORDER = {"critical": 0, "high": 1, "medium": 2, "low": 3}118SEV_SHOW = {"all": 4, "medium": 2, "high": 1, "critical": 0}.get(SEV_FILTER, 4)119120# Get files121ext = "*.py" if lang == "python" else "*.js"122files = list(src.rglob(ext) if src.is_dir() else [src])123files = [f for f in files if ".git" not in str(f) and "node_modules" not in str(f) and "venv" not in str(f)][:50]124console.print(f"[dim]Scanning {len(files)} {lang} files…[/dim]")125126# Scan127findings = []128for fpath in files:129 try:130 lines = fpath.read_text(encoding="utf-8", errors="ignore").splitlines()131 for i, line in enumerate(lines, 1):132 for rule_id, sev, category, pattern, message, fix in RULES:133 if SEV_ORDER.get(sev, 3) <= SEV_SHOW and re.search(pattern, line):134 findings.append({"id": rule_id, "severity": sev, "category": category,135 "file": str(fpath.relative_to(src) if src.is_dir() else fpath),136 "line": i, "code": line.strip()[:80], "message": message, "fix": fix})137 except Exception: pass138139# Dedupe and sort140seen = set(); unique = []141for f in findings:142 key = (f["id"], f["file"], f["line"])143 if key not in seen: seen.add(key); unique.append(f)144unique.sort(key=lambda x: (SEV_ORDER.get(x["severity"],3), x["file"], x["line"]))145146# Stats147from collections import Counter148sev_counts = Counter(f["severity"] for f in unique)149cat_counts = Counter(f["category"] for f in unique)150151console.print()152console.print(Panel(153 f"Files scanned: [cyan]{len(files)}[/cyan] | Issues found: [bold]{len(unique)}[/bold]\n"154 f"[red]Critical: {sev_counts['critical']}[/red] [yellow]High: {sev_counts['high']}[/yellow] [blue]Medium: {sev_counts['medium']}[/blue] [dim]Low: {sev_counts['low']}[/dim]\n"155 f"Security: {cat_counts['security']} | Bugs: {cat_counts['bug']} | Smells: {cat_counts['smell']}",156 title="[bold]📊 Scan Summary[/bold]", border_style="red" if sev_counts["critical"] > 0 else "yellow"157))158159if unique:160 console.print()161 display_count = min(len(unique), 25)162 title_suffix = f" — showing {display_count} of {len(unique)}" if len(unique) > 25 else ""163 t = Table(title=f"🐛 Issues Found ({len(unique)}){title_suffix}", box=box.ROUNDED, show_lines=True, border_style="red")164 t.add_column("ID", width=7, style="dim"); t.add_column("Sev", width=10); t.add_column("File:Line", style="cyan", width=28)165 t.add_column("Issue", style="white", width=35); t.add_column("Fix", style="green", width=40)166 SEV_COLOR = {"critical":"bold red","high":"yellow","medium":"blue","low":"dim"}167 for f in unique[:25]:168 col = SEV_COLOR.get(f["severity"],"white")169 t.add_row(f["id"], f"[{col}]{f['severity']}[/{col}]", f"{f['file'][:22]}:{f['line']}", f["message"][:35], f["fix"][:40])170 console.print(t)171else:172 console.print(Panel("[green]✅ No issues found matching your filter criteria![/green]", border_style="green"))173174# Save175out_path = f"bug_report_{TODAY}.json"176with open(out_path,"w", encoding="utf-8") as f:177 json.dump({"scanned_files": len(files), "language": lang, "findings": unique, "generated": str(TODAY)}, f, indent=2)178md_path = f"bug_report_{TODAY}.md"179with open(md_path,"w", encoding="utf-8") as f:180 f.write(f"# Bug Hunt Report — {TODAY}\n\n**Files:** {len(files)} | **Issues:** {len(unique)}\n\n")181 f.write("| ID | Severity | File:Line | Issue | Fix |\n|-----|---------|-----------|-------|-----|\n")182 for fi in unique: f.write(f"| {fi['id']} | {fi['severity']} | {fi['file'][:25]}:{fi['line']} | {fi['message'][:40]} | {fi['fix'][:40]} |\n")183184console.print()185console.print(Panel(f"[bold green]✅ Scan complete![/bold green]\n\n📄 [cyan]{md_path}[/cyan]\n📄 [cyan]{out_path}[/cyan]\n\n[bold]What to do next:[/bold]\n1. [yellow]Fix Critical issues first[/yellow] — security and crash bugs\n2. [yellow]Fix High severity next[/yellow] — these will cause real problems\n3. [yellow]Run again after fixes[/yellow] to confirm clean\n4. [yellow]Add to CI/CD pipeline[/yellow] so every commit is scanned",title="[bold red]🐛 👁️ Argus — Code Intelligence Scanner — Done[/bold red]",border_style="red"))186```