Skip to main content

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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Release files for codeflow-solver 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codeflow-solver 1.0.2
File Size Uploaded
codeflow_solver-1.0.2.tar.gz 129.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codeflow-solver 1.0.2
File Interpreter ABI Platform
codeflow_solver-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 156.9 kB

Release files / codeflow_solver-1.0.2.tar.gz

Download URL codeflow_solver-1.0.2.tar.gz
Size 129.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e7b9716f76aec9ccdb98697a8ed357145e0a9843f755d35bdd25b7adbd2dc3e3
BLAKE2b-256 checksum
How to use checksums
2e053efce71d5a4328f112b79d6a16d41aaf7157b3bec46c582e90c74e720072
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / codeflow_solver-1.0.2-py3-none-any.whl

Download URL codeflow_solver-1.0.2-py3-none-any.whl
Size 27.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa25dcf8b10aeb38547a07b62ac62a984f24814d60261863430529d57df541aa
BLAKE2b-256 checksum
How to use checksums
155f684e0500a109cb65e8288c56daff0d6e373a12c0725784f6afef95d2e61a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page