Browse by type
Need more from PySpector? Contact us!
PySpector is a State-of-the-Art Static Analysis Security Testing (SAST) framework, built in Rust for next-gen performances, made for modern Python projects and large codebases. Unlike traditional linters, PySpector utilizes a Flow-Sensitive, Inter-Procedural Taint Engine to track untrusted data across complex function boundaries and control flow structures.
By compiling the core analysis engine to a native binary, PySpector avoids the performance limitations of traditional Python-only tools. This makes it well-suited for CI/CD pipelines and local development environments where speed and scalability matter.
PySpector is designed to be both comprehensive and intuitive, offering a multi-layered analysis approach that goes beyond simple pattern matching to understand the structure and data flow of your Python application.
https://github.com/user-attachments/assets/d91b9d8a-4411-4f90-84bd-69852d27a5b5
rustc) and Cargo package manager are required. You can easily install the Rust toolchain via rustup and verify your installation by running cargo --version.It is highly recommended to install PySpector in a dedicated Python 3.14 venv.
bash
# Download Python 3.14
python3.14 -m venv venv
source venv/bin/activate
powershell
# Download Python 3.14 from the Microsoft Store and run:
python3.14 -m venv venv
.\venv\Scripts\Activate.ps1
# or, depending on the Python 3.14 installation source:
.\venv\bin\Activate.ps1
With PySpector being on PyPI, installation is as simple as running:
pip install pyspector
Flow-Sensitive Analysis: Utilizes a Control Flow Graph (CFG) to track variable states sequentially, accurately distinguishing between safe and vulnerable code paths.
Inter-Procedural Taint Tracking: Propagates untrusted data across function boundaries using global fixed-point iteration and function summaries.
Context-Aware Summaries: Sophisticated mapping of which function parameters flow to return values, allowing for high-precision tracking through complex utility functions.
Multi-Engine Hybrid Scanning:
Regex Engine: High-speed scanning for secrets, hardcoded credentials, and configuration errors.
AST Engine: Deep structural pattern matching to find Python-specific anti-patterns.
Graph Engine: Advanced CFG and Call-Graph-based data flow analysis for complex vulnerability chains.
Fastest Market Performances: Core analysis engine implemented in Rust with Rayon for multi-threaded parallelization.
AI-Agent Security: Specialized rulesets designed to identify prompt injection, insecure tool use, and data leakage in LLM-integrated Python applications.
PySpector v0.1.5 represents a shift from partially-static pattern matching, to a full graph-based analysis engine:
PySpector's hybrid architecture is key to its performance and effectiveness.
Python CLI Orchestration: The process begins with the Python-based CLI. It handles command-line arguments, loads the configuration and rules, and prepares the target files for analysis. For each Python file, it uses the native ast module to generate an Abstract Syntax Tree, which is then serialized to JSON.
Invocation of the Rust Core: The serialized ASTs, along with the ruleset and configuration, are passed to the compiled Rust core. The handoff from Python to Rust is managed by the pyo3 library.
Parallel Analysis in Rust: The Rust engine takes over and performs the heavy lifting. It leverages the rayon crate to execute file scans and analysis in parallel, maximizing the use of available CPU cores. It builds a complete call graph of the application to understand inter-file function calls, which is essential for the taint analysis module.
Results and Reporting: Once the analysis is complete, the Rust core returns a structured list of findings to the Python CLI. The Python wrapper then handles the final steps of filtering the results based on the severity threshold and the baseline file, and generating the report in the user-specified format.
This architecture combines the best of both worlds: a flexible, user-friendly interface in Python and a high-performance, memory-safe analysis engine in Rust :)
Performance benchmarks demonstrate PySpector's competitive advantages in SAST scanning speed while maintaining comprehensive security analysis.
Performance benchmarks were executed in a deterministic and controlled environment, ensuring repeatable and unbiased measurements
You can read and download for free the full technical whitepaper here: PySpector Performance Benchmark: A Comparative Speed and Resource-Efficiency Analysis Against Bandit and Semgrep Across Eight Open-Source Python Codebases.pdf
| Metric | PySpector | Bandit | Semgrep |
|---|---|---|---|
| Average Throughput | 18,448 lines/sec | 8,891 lines/sec | 5,039 lines/sec |
| Relative to PySpector | Fastest (reference) | 2.1x slower | 3.7x slower |
| Peak Memory Usage | 973 MB average | Not measured in this benchmark | Not measured in this benchmark |
| CPU Utilization | 4.09 of 16 cores average (multi-core, scales with codebase size) | Not measured in this benchmark | Not measured in this benchmark |
Note on throughput figures: the numbers above reflect this specific, controlled benchmark's average across eight repositories under identical, dedicated resource allocation, and are the figures we stand behind as objective and reproducible. Under more favorable, less constrained conditions, PySpector has independently been observed exceeding 50,000 to 55,000 lines of code per second on large codebases such as Django. That figure was not produced under the controlled methodology described here, so it is not included in the comparison table above, but we can confirm we have measured it multiple times, on different large codebases, in unrelated tests.
$ claude mcp add PySpector \
-- python -m otcore.mcp_server <graph>