Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

PatchPro Bot Example

This directory contains example files and data for testing the PatchPro bot.

Structure

  • src/ - Example Python files with various code issues
  • artifact/analysis/ - Sample JSON output from Ruff and Semgrep analyzers

Sample Issues

The example files contain various types of issues that PatchPro can detect and fix:

Security Issues (Semgrep)

  • Shell Injection (CWE-78): Using subprocess.call() with shell=True
  • Weak Cryptography (CWE-327): Using MD5 hash algorithm
  • Exception Handling: Catching broad exceptions before specific ones

Code Quality Issues (Ruff)

  • F401: Unused imports
  • F841: Unused variables
  • E501: Line too long
  • B007: Loop control variable not used

Running the Example

To test the PatchPro bot with this example:

  1. Set your OpenAI API key:

    export OPENAI_API_KEY="your-api-key-here"
  2. Run the agent core:

    cd examples
    python -m patchpro_bot.agent_core

Or use the example as a test case in your development workflow.

Expected Output

The bot should generate:

  • Unified diff patches for each file
  • A comprehensive report in artifact/report.md
  • Individual or combined patch files in artifact/

File Descriptions

src/example.py

Main example file containing:

  • Unused import (os)
  • Long line (E501)
  • Security vulnerability (shell injection)
  • Insecure hash usage

src/utils.py

Utility functions with:

  • Unused variables
  • Loop control issues
  • Bad exception handling order
  • More security issues

Analysis Files

  • ruff_output.json: Sample Ruff analyzer output
  • semgrep_output.json: Sample Semgrep analyzer output

These JSON files represent what would typically be generated by running:

ruff check --output-format json examples/src/ > artifact/analysis/ruff_output.json
semgrep --config=auto --json examples/src/ > artifact/analysis/semgrep_output.json