Skip to content

Commit 1483437

Browse files
committed
feat(engine): upgrade to inter-procedural flow-sensitive taint analysis
- Implemented global fixed-point iteration and function summaries for cross-boundary tracking. - Refactored core engine to be flow-sensitive via new CFG implementation. - Fixed critical call-graph bug and updated README with v0.1.5 architecture deep-dives.
1 parent 23e85ee commit 1483437

6 files changed

Lines changed: 501 additions & 87 deletions

File tree

README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@
22

33

44

5-
# High-Performance Python and Rust SAST Framework
5+
# High-Performance Python/Rust Graph-Based SAST Framework
66

77
[![POWERED BY](https://img.shields.io/badge/POWERED%20BY-SecurityCert-purple)](https://www.securitycert.it/)
88
[![Total PyPI Downloads](https://static.pepy.tech/badge/pyspector)](https://pepy.tech/project/pyspector)
99
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/pyspector?period=weekly&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=BLUE&left_text=downloads%2Fweek)](https://pepy.tech/projects/pyspector)
10-
[![latest release](https://img.shields.io/badge/latest%20release-v0.1.4--beta-blue)](https://github.com/ParzivalHack/PySpector/releases/tag/v0.1.4-beta-hotfix)
10+
[![latest release](https://img.shields.io/badge/latest%20release-v0.1.5--beta-blue)](https://github.com/ParzivalHack/PySpector/releases/tag/v0.1.4-beta-hotfix)
1111
[![PyPI version](https://img.shields.io/pypi/v/pyspector?color=blue&label=pypi%20package)](https://pypi.org/project/pyspector/)
1212
[![Python version](https://img.shields.io/badge/Python-3.9%2B-blue?logo=python&logoColor=white)](https://www.python.org/)
1313
[![Rust version](https://img.shields.io/badge/Rust-stable-orange?logo=rust&logoColor=white)](https://www.rust-lang.org/)
1414

1515

16-
PySpector is a Static Application Security Testing (SAST) framework for modern Python projects.
17-
It combines a high-performance Rust analysis engine with a developer-friendly Python CLI to deliver fast and accurate vulnerability scanning.
16+
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.
1817

1918
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.
2019

21-
The tool 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 application.
20+
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.
2221

2322
## Table of Contents
2423
- [Getting Started](#getting-started)
@@ -46,6 +45,7 @@ It is **highly recommended** to install PySpector in a dedicated Python 3.12 ven
4645

4746
- **Linux (Bash)**:
4847
```bash
48+
# Download Python 3.12
4949
python3.12 -m venv venv
5050
source venv/bin/activate
5151
```
@@ -66,19 +66,32 @@ pip install pyspector
6666

6767
## Key Features
6868

69-
* **Multi-Layered Analysis Engine:** PySpector employs a sophisticated, multi-layered approach to detect a broad spectrum of vulnerabilities:
69+
* **Flow-Sensitive Analysis:** Utilizes a Control Flow Graph (CFG) to track variable states sequentially, accurately distinguishing between safe and vulnerable code paths.
7070

71-
- **Regex-Based Pattern Matching:** Scans all files for specific patterns, ideal for identifying hardcoded secrets, insecure configurations in Dockerfiles, and weak settings in framework files.
71+
* **Inter-Procedural Taint Tracking:** Propagates untrusted data across function boundaries using global fixed-point iteration and function summaries.
7272

73-
- **Abstract Syntax Tree (AST) Analysis:** For Python files, the tool parses the code into an AST to analyze its structure. This enables precise detection of vulnerabilities tied to code constructs, such as the use of eval(), insecure deserialization with pickle, or weak hashing algorithms.
73+
* **Context-Aware Summaries:** Sophisticated mapping of which function parameters flow to return values, allowing for high-precision tracking through complex utility functions.
7474

75-
- **Inter-procedural Taint Analysis:** The engine builds a comprehensive call graph of the entire application to perform taint analysis. It tracks the flow of data from input sources (like web requests) to dangerous sinks (like command execution functions), allowing it to identify complex injection vulnerabilities with high accuracy.
75+
* **Multi-Engine Hybrid Scanning:**
76+
77+
* **Regex Engine:** High-speed scanning for secrets, hardcoded credentials, and configuration errors.
7678

77-
* **Comprehensive and Customizable Ruleset:** PySpector comes with 241 built-in rules that cover common vulnerabilities, including those from the OWASP Top 10. The rules are defined in a simple TOML format, making them easy to understand and extend.
79+
* **AST Engine:** Deep structural pattern matching to find Python-specific anti-patterns.
7880

79-
* **Versatile Reporting:** Generates clear and actionable reports in multiple formats, including a developer-friendly console output, JSON, HTML, and SARIF for seamless integration with other security tools and platforms.
81+
* **Graph Engine:** Advanced CFG and Call-Graph-based data flow analysis for complex vulnerability chains.
8082

81-
* **Efficient Baselining:** The interactive triage mode simplifies the process of establishing a security baseline, allowing teams to focus on new and relevant findings in each scan.
83+
* **Fastest Market Performances:** Core analysis engine implemented in Rust with `Rayon` for multi-threaded parallelization (allowing PySpector to scan 71% faster than Bandit, and 16.6x faster than Semgrep).
84+
85+
* **AI-Agent Security:** Specialized rulesets designed to identify prompt injection, insecure tool use, and data leakage in LLM-integrated Python applications.
86+
87+
## Core Engine Architecture
88+
89+
PySpector v0.1.5 represents a shift from partially-static pattern matching, to a full graph-based analysis engine:
90+
91+
1. **AST Parsing:** Python source is converted into a structured JSON AST, for semantic analysis.
92+
2. **Call Graph Construction:** PySpector builds a project-wide map of function definitions, and call sites to enable cross-file analysis.
93+
3. **CFG Generation:** Each function is decomposed into a Control Flow Graph (CFG), allowing the engine to understand the order of operations and conditional Python logic.
94+
4. **Fixed-Point Taint Propagation:** Using a Worklist Algorithm, the engine propagates "taint" from defined **Sources** to **Sinks**, while respecting **Sanitizers** that clean the data along the way.
8295

8396
## How It Works
8497

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = pyspector
3-
version = 0.1.4-hotfix
3+
version = 0.1.5
44

55
[options]
66
package_dir=

src/pyspector/_rust_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "_rust_core"
3-
version = "0.1.4-1"
3+
version = "0.1.5"
44
edition = "2021"
55

66
[lib]

0 commit comments

Comments
 (0)