Unique-AG/ai / .claude/skills/security-maintenance
security-maintenance
FlaggedTriage and fix Dependabot alerts, CodeQL findings and Trivy image scan alerts (search-proxy image CVEs, uv audit findings) in the ai repository. Use when the user asks to address security vulnerabilities, fix Dependabot alerts, resolve CodeQL or code scanning alerts, handle a failed Trivy image scan or uv audit run, or do security maintenance.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.5 KB |
| references/codeql-patterns.md | markdown | 2.2 KB |
| references/exclude-newer.md | markdown | 2.1 KB |
| references/gh-commands.md | markdown | 3.2 KB |
references/codeql-patterns.md
View on GitHub# Common CodeQL Fix Patterns
CodeQL fixes require code changes — there is no config shortcut. Below are common vulnerability classes and their remediation patterns.
## SQL injection
**Problem**: User input interpolated into SQL strings.
**Fix**: Use parameterized queries.
```python
# Bad
cursor.execute(f"SELECT * FROM users WHERE id = '{user_id}'")
# Good
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
```
## Path traversal
**Problem**: User-controlled input used in file paths without validation.
**Fix**: Validate and resolve paths, ensure they stay within allowed directories.
```python
# Bad
open(os.path.join(base_dir, user_input))
# Good
resolved = os.path.realpath(os.path.join(base_dir, user_input))
if not resolved.startswith(os.path.realpath(base_dir)):
raise ValueError("Path traversal detected")
open(resolved)
```
## Hardcoded credentials
**Problem**: Secrets, API keys, or passwords in source code.
**Fix**: Move to environment variables or a secret manager.
```python
# Bad
api_key = "sk-1234567890"
# Good
api_key = os.environ["API_KEY"]
```
## Unsafe deserialization
**Problem**: Loading untrusted data with `pickle`, `yaml.load`, or similar.
**Fix**: Use safe loaders or validate input.
```python
# Bad
data = yaml.load(content)
data = pickle.loads(payload)
# Good
data = yaml.safe_load(content)
data = json.loads(payload) # prefer JSON over pickle for untrusted data
```
## Command injection
**Problem**: User input passed to shell commands via string concatenation.
**Fix**: Use subprocess with argument lists, never `shell=True` with user input.
```python
# Bad
os.system(f"grep {query} /var/log/app.log")
subprocess.run(f"grep {query} /var/log/app.log", shell=True)
# Good
subprocess.run(["grep", query, "/var/log/app.log"], check=True)
```
## Server-side request forgery (SSRF)
**Problem**: User-controlled URLs passed to HTTP requests without validation.
**Fix**: Validate URLs against an allowlist, block internal/private ranges.
```python
# Bad
response = requests.get(user_provided_url)
# Good
from urllib.parse import urlparse
parsed = urlparse(user_provided_url)
if parsed.hostname not in ALLOWED_HOSTS:
raise ValueError("URL not allowed")
response = requests.get(user_provided_url)
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 471k | Updated | Claude CodeCodex | Verified | Install |
| 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: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |