Skip to main content
This command is in beta. Review all patches before applying to production code.

Overview

The /patch command generates secure patches to fix identified vulnerabilities. It analyzes findings and creates production-ready patch files with fix recommendations.

Syntax

Parameters

string
required
Absolute path to the code repository
string
SARIF file from previous scan (optional if scanning first)
boolean
Skip exploit generation (patch generation only)
integer
Maximum number of patches to generate

What It Does

  1. Analyzes vulnerabilities from SARIF findings
  2. Identifies root causes and insecure patterns
  3. Generates secure code replacements
  4. Creates unified diff patch files
  5. Provides fix recommendations and best practices
  6. Saves patches to out/*/patches/

Workflow

Step 1: Find Vulnerabilities

Step 2: Generate Patches

Step 3: Review and Apply

Examples

Generate Patches for All Findings

Generates patches for all discovered vulnerabilities.

Generate Limited Patches

Generates patches for the first 5 findings.

From Existing SARIF

Generates patches from previous scan results.

Patch Types

SQL Injection Fix

Command Injection Fix

Buffer Overflow Fix

XSS Fix

Patch Quality Features

Secure Coding Best Practices

  • Input validation and sanitization
  • Parameterized queries for SQL
  • Safe API usage (subprocess instead of os.system)
  • Output encoding for XSS prevention
  • Bounds checking for buffer operations

Defense in Depth

  • Multiple layers of protection
  • Fail-safe defaults
  • Principle of least privilege
  • Input validation at trust boundaries

Code Quality

  • Maintains existing code style
  • Minimal changes for maximum security
  • Preserves functionality
  • Includes explanatory comments

Output Structure

Patch README Format

Apply Safely

Best Practices

  1. Review Every Patch: Understand the changes before applying
  2. Test Thoroughly: Run full test suite after applying
  3. Apply Incrementally: One patch at a time
  4. Version Control: Use branches for security fixes
  5. Peer Review: Have team members review patches
  6. Document Changes: Update security documentation

/scan

Find vulnerabilities to patch

/validate

Validate vulnerabilities before patching

/exploit

Generate exploits instead of patches

/agentic

Full workflow including patch generation

Notes

  • Does NOT generate exploits (use /exploit for that)
  • Patches are saved to out/*/patches/
  • Nothing is applied to your code automatically
  • All patches require manual review and testing
  • Maintains code style and functionality
  • For security hardening and compliance