A tool that finds the minimum number of code fixes needed to eliminate vulnerabilities from SARIF output
Project description
Codeflow Solver
Overview
A tool that finds the optimal minimum number of code fixes needed to eliminate all vulnerabilities from SARIF scan results. Uses the set cover problem optimization to determine the most efficient fix strategy - guaranteeing the absolute minimum number of code changes required to address all security issues.
๐ For detailed algorithm explanation, mathematical formulation, and implementation details, see src/codeflow_solver/docs/MATHEMATICAL_DETAILS.md
Installation
pip install codeflow-solver
From Source
git clone https://github.com/thomsonreuters/codeflow-solver.git
cd codeflow-solver
uv sync
uv pip install -e .
Usage
CLI Options
# Basic usage
codeflow-solver vulnerabilities.sarif
# Choose solver
codeflow-solver vulnerabilities.sarif --solver cp-sat
# Filtering options
codeflow-solver vulnerabilities.sarif --severity-filter high medium
codeflow-solver vulnerabilities.sarif --rule-filter java/XSS java/PT
# Export options
codeflow-solver vulnerabilities.sarif --export # Detailed solution with vulnerability details
codeflow-solver vulnerabilities.sarif --minimal-export # Optimal path with fix locations only
# Quiet mode
codeflow-solver vulnerabilities.sarif --quiet --minimal-export
Using as Package
from codeflow_solver import SarifSetCoverSolver
# Basic usage
optimizer = SarifSetCoverSolver("vulnerabilities.sarif")
optimizer.solve_mathematical_optimization()
# With filtering and export
optimizer = SarifSetCoverSolver(
"vulnerabilities.sarif",
severity_filter=["high", "medium"],
rule_filter=["java/XSS"],
export_detailed=True
)
optimizer.solve_mathematical_optimization()
CLI After Cloning
cd codeflow-solver
uv run python -m codeflow_solver.cli.main vulnerabilities.sarif
# Available options:
# --severity-filter {high,medium,low,info} Filter by severity
# --rule-filter RULE_ID [RULE_ID ...] Filter by rule IDs
# --export Export detailed solution
# --minimal-export Export minimal solution
# --quiet Suppress console output
Package Structure
src/
โโโ codeflow_solver/
โโโ __init__.py
โโโ cli/
โ โโโ __init__.py
โ โโโ main.py # CLI entry point
โโโ utils/
โ โโโ __init__.py
โ โโโ sarif_parser.py # SARIF parsing
โ โโโ severity_mapper.py # Severity mapping
โ โโโ data_structures.py # Data classes
โโโ solver/
โ โโโ __init__.py
โ โโโ set_cover_solver.py # Main solver implementation
โ โโโ optimizer.py # Optimization algorithms
โโโ set_cover/
โ โโโ __init__.py
โ โโโ initializer.py # Set cover initialization
โโโ docs/ # Documentation
tests/ # Test files
Tests
# Run tests
uv run pytest
# Format and lint
uv run ruff format .
uv run ruff check .
uv run mypy .
License
MIT License
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codeflow_solver-1.0.2.tar.gz.
File metadata
- Download URL: codeflow_solver-1.0.2.tar.gz
- Upload date:
- Size: 129.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7b9716f76aec9ccdb98697a8ed357145e0a9843f755d35bdd25b7adbd2dc3e3
|
|
| MD5 |
14828bd5c8cebcfb9d42bd8724d2be0f
|
|
| BLAKE2b-256 |
2e053efce71d5a4328f112b79d6a16d41aaf7157b3bec46c582e90c74e720072
|
File details
Details for the file codeflow_solver-1.0.2-py3-none-any.whl.
File metadata
- Download URL: codeflow_solver-1.0.2-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa25dcf8b10aeb38547a07b62ac62a984f24814d60261863430529d57df541aa
|
|
| MD5 |
fbfe065b54155b06c72d91b608a9ac60
|
|
| BLAKE2b-256 |
155f684e0500a109cb65e8288c56daff0d6e373a12c0725784f6afef95d2e61a
|