Loading...
Loading...
Generate security fixes from detect-dev findings with regression tests. Use when remediating security vulnerabilities.
npx skill4agent add parhumm/jaan-to sec-audit-remediateGenerate targeted security fixes from detect-dev SARIF findings with regression tests.
$JAAN_LEARN_DIR/jaan-to:sec-audit-remediate.learn.md$JAAN_TEMPLATES_DIR/jaan-to:sec-audit-remediate.template.md$JAAN_CONTEXT_DIR/tech.md#current-stack#frameworks#constraints#patterns${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md${CLAUDE_PLUGIN_ROOT}/docs/research/73-dev-sarif-security-remediation-automation.md${CLAUDE_PLUGIN_ROOT}/docs/research/72-dev-secure-backend-scaffold-hardening.md$JAAN_OUTPUTS_DIR/sec/remediate/{id}-{slug}/$JAAN_OUTPUTS_DIR/detect/dev/security.md.sarifbackend-scaffoldfrontend-scaffold$JAAN_OUTPUTS_DIR/detect/dev/security*.md$JAAN_OUTPUTS_DIR/detect/dev/summary*.md${CLAUDE_PLUGIN_ROOT}/docs/extending/pre-execution-protocol.mdsec-audit-remediate$JAAN_CONTEXT_DIR/tech.md${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.mdlanguage_sec-audit-remediateLanguage exception: Generated code output (fix files, test files, code blocks, schemas) is NOT affected by this setting and remains in the project's programming language.
FINDINGS PARSED
---------------
Critical: {n} | High: {n} | Medium: {n} | Low: {n}
ID Severity CWE File Description
E-DEV-001 Critical CWE-89 src/api/users.ts:42 SQL injection in query
E-DEV-003 High CWE-79 src/views/profile.tsx:18 XSS in user content
...Reference: Seesection "CWE-to-Fix Category Mapping" for CWE categories, fix strategies, complexity, and auto-fix eligibility.${CLAUDE_PLUGIN_ROOT}/docs/extending/sec-audit-remediate-reference.md
| Field | Description |
|---|---|
| Finding ID | From detect-dev output |
| Fix Type | Code replacement / New middleware / Config change / Dependency update |
| Fix File | Path to the fix file to generate |
| Test File | Path to the regression test to generate |
| Dependencies | New packages needed (e.g., dompurify, csurf) |
| Breaking Changes | Whether the fix changes API behavior |
| Complexity | Low / Medium / High |
Reference: Seesection "Triage Matrix" for severity/confidence decision grid.${CLAUDE_PLUGIN_ROOT}/docs/extending/sec-audit-remediate-reference.md
REMEDIATION PLAN
----------------
Total findings: {n}
Auto-fix eligible: {n} (Critical/High + Confirmed/Firm confidence)
Manual review needed: {n} (Medium confidence or complex fixes)
Skipped: {n} (Low confidence or informational)
FINDINGS TO REMEDIATE:
[x] E-DEV-001 Critical CWE-89 SQL injection -> parameterized query [auto-fix]
[x] E-DEV-003 High CWE-79 XSS vulnerability -> DOMPurify sanitize [auto-fix]
[x] E-DEV-007 High CWE-352 Missing CSRF -> csrf middleware [auto-fix]
[x] E-DEV-012 High CWE-327 Weak hash (MD5) -> SHA-256 replacement [auto-fix]
[ ] E-DEV-015 Medium CWE-862 Missing auth check -> RBAC guard [needs design]
[ ] E-DEV-018 Low CWE-798 Hardcoded API key -> env variable [manual]
New dependencies needed: dompurify, @types/dompurify, csurf
Estimated fix files: {n}
Estimated test files: {n}"Which findings should I remediate? [all-auto / select / all]"
REMEDIATION SUMMARY
-------------------
Findings to fix: {n}
Fix files to generate: {n}
Test files to generate: {n}
New dependencies: {list}
Breaking changes: {yes/no, details}
OUTPUT STRUCTURE:
$JAAN_OUTPUTS_DIR/sec/remediate/{id}-{slug}/
{id}-{slug}.md <- Remediation report
{id}-{slug}-readme.md <- Integration instructions
fixes/
auth-middleware.ts <- Fix: missing auth
rate-limiter.ts <- Fix: rate limiting
csrf-protection.ts <- Fix: CSRF
sanitize-input.ts <- Fix: XSS/injection
...
tests/
auth-security.test.ts <- Test: auth fixes
rate-limit.test.ts <- Test: rate limiting
csrf.test.ts <- Test: CSRF
xss-prevention.test.ts <- Test: XSS
..."Proceed with generating {n} fix files and {n} test files? [y/n]"
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/id-generator.sh"SUBDOMAIN_DIR="$JAAN_OUTPUTS_DIR/sec/remediate"
mkdir -p "$SUBDOMAIN_DIR"
NEXT_ID=$(generate_next_id "$SUBDOMAIN_DIR")
OUTPUT_FOLDER="${SUBDOMAIN_DIR}/${NEXT_ID}-${slug}"
MAIN_FILE="${OUTPUT_FOLDER}/${NEXT_ID}-${slug}.md"mkdir -p "$OUTPUT_FOLDER/fixes"
mkdir -p "$OUTPUT_FOLDER/tests"Output Configuration
- ID: {NEXT_ID}
- Folder: $JAAN_OUTPUTS_DIR/sec/remediate/{NEXT_ID}-{slug}/
- Main file: {NEXT_ID}-{slug}.md
- Fixes dir: fixes/
- Tests dir: tests/
fixes/Reference: Seesection "Per-CWE Fix Generation Patterns" for CWE-specific fix generation instructions (CWE-79 through CWE-862).${CLAUDE_PLUGIN_ROOT}/docs/extending/sec-audit-remediate-reference.md
{vulnerability-type}.tssql-injection-fix.tscsrf-protection.tsxss-sanitizer.tstests/${CLAUDE_PLUGIN_ROOT}/docs/research/73-dev-sarif-security-remediation-automation.md{vulnerability-type}.test.tssql-injection.test.tsxss-prevention.test.tsReference: Seesection "CWE-Specific Test Patterns" for per-CWE test payloads and verification patterns.${CLAUDE_PLUGIN_ROOT}/docs/extending/sec-audit-remediate-reference.md
{id}-{slug}.md$JAAN_TEMPLATES_DIR/jaan-to:sec-audit-remediate.template.md{{title}}{{date}}{{executive_summary}}{{findings_table}}{{fixes_generated}}{{tests_generated}}{{new_dependencies}}{{risk_reduction}}{{remaining_findings}}{id}-{slug}-readme.mdOUTPUT FILES
------------
$JAAN_OUTPUTS_DIR/sec/remediate/{id}-{slug}/
{id}-{slug}.md (remediation report)
{id}-{slug}-readme.md (integration instructions)
fixes/
{fix-file-1}.ts (CWE-89: SQL injection fix)
{fix-file-2}.ts (CWE-79: XSS sanitization)
...
tests/
{test-file-1}.test.ts (SQL injection regression)
{test-file-2}.test.ts (XSS prevention regression)
...
Total: {n} files"Write all {n} files to $JAAN_OUTPUTS_DIR/sec/remediate/{id}-{slug}/? [y/n]"
fixes/tests/source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/index-updater.sh"
add_to_index \
"$SUBDOMAIN_DIR/README.md" \
"$NEXT_ID" \
"${NEXT_ID}-${slug}" \
"{Title}" \
"{Executive summary text}"Output written to: $JAAN_OUTPUTS_DIR/sec/remediate/{NEXT_ID}-{slug}/ Index updated: $JAAN_OUTPUTS_DIR/sec/remediate/README.md Fix files: {n} | Test files: {n} | Report: 1 | Readme: 1
"Any feedback on the security remediation? [y/n]"
"[1] Fix now [2] Learn for future [3] Both"
/jaan-to:learn-add sec-audit-remediate "{feedback}"