Open-Source Static Analysis for Privacy Data Flows
Project description
truScanner from truConsent
Open-Source Static Analysis for Privacy Data Flows
truScanner is a static code analysis tool designed to discover and analyze personal data elements in your source code. It helps developers and security teams identify privacy-related data flows and generate comprehensive reports.
๐ฆ PyPI Project โข ๐ App Dashboard
๐ Features
- Comprehensive Detection: Identifies 300+ personal data elements (PII, financial data, device identifiers, etc.)
- Full Catalog Coverage: Loads and scans against all configured data elements from
data_elements/(not a truncated subset) - Interactive Menu: Arrow-key navigable menu for selecting output formats
- Real-time Progress: Visual progress indicator during scanning
- Multiple Report Formats: Generate reports in TXT, Markdown, or JSON format
- Separate Regex and AI Scans: Regex/static scanning and AI-enhanced scanning now run as distinct paths
- AI-Powered Enhancement: Optional integration with Ollama, OpenAI, or AWS Bedrock for deeper context
- Backend Integration: Optional upload to backend API for centralized storage
- Auto-incrementing Reports: Automatically manages report file naming to prevent overwrites
truScanner CLI
๐ฆ Installation
Prerequisites
- Python 3.9 or higher
- ollama (optional, for local AI scanning)
- OpenAI or AWS Bedrock credentials if you want a hosted AI provider
Quick Install
Using pip:
pip install truscanner
Using uv:
uv pip install truscanner
Verify installation:
truscanner --help
๐ ๏ธ Usage
Basic Usage
Scan a directory with the interactive menu:
truscanner scan <directory_path>
Example
truscanner scan ./src
truscanner scan ./my-project
truscanner scan C:\Users\username\projects\my-app
Python API Usage
Use truScanner directly from Python:
import truscanner
# Local path
check = truscanner("/path/to/project")
# file:// URL also works
check = truscanner("file:///Users/username/project")
# Optional explicit call style
check = truscanner.scan("/path/to/project", with_ai=False)
# Run regex and AI scans separately
regex_only = truscanner.scan_regex("/path/to/project")
ai_only = truscanner.scan_ai("/path/to/project", ai_provider="bedrock")
# Run both scans together
full_check = truscanner.scan(
"/path/to/project",
with_ai=True,
ai_provider="openai",
)
# API metadata: total configured catalog size
print(check["configured_data_elements"])
Minimal script style:
import truscanner
scan = truscanner("folder_path")
Runnable root example:
python3 simple_truscanner_usage.py ./src
Quick smoke check script:
uv run python scripts/check_truscanner_api.py ./src
Interactive Workflow
-
Select Output Format:
- Use arrow keys (โโ) to navigate
- Press Enter to select
- Options:
txt,md,json, orAll(generates all three formats)
-
Scanning Progress:
- Real-time progress bar shows file count and percentage
- Prints configured definition count at start (example:
Loaded data element definitions: 380) - Example:
Scanning: 50/200 (25%) [โโโโโโโโโโโโโโโโโโโโ] filename.js
-
AI Enhanced Scan (Optional):
- After the regex scan, you'll get a dropdown for the AI-only scan provider:
Skip AI scan,Ollama,OpenAI, orAWS Bedrock - This AI pass is separate from the regex scan and is used to find context that regex may miss.
- If
Ollamais selected, you can choose the local model from a second dropdown. - Live scanning timer:
AI Scanning: filename.js... (5.2s taken)
- After the regex scan, you'll get a dropdown for the AI-only scan provider:
-
Report Generation:
- Reports are saved in
reports/{directory_name}/folder - Files are named:
truscan_report.txt,truscan_report.md,truscan_report.json - Subsequent scans auto-increment:
truscan_report1.txt,truscan_report2.txt, etc. - AI findings are saved with
_llmsuffix.
- Reports are saved in
-
Backend Upload (Optional):
- After reports are saved, you'll be prompted:
Do you want to upload the scan report for the above purpose? (Y, N): - Enter
Yto upload scan results to backend API - View your uploaded scans and analytics at app.truconsent.io
- After reports are saved, you'll be prompted:
Command Options
truscanner scan <directory> [OPTIONS]
Options:
--with-ai Enable the separate AI scan after the regex scan
--ai-provider AI provider: ollama, openai, or bedrock
--ai-mode AI scan mode: fast, balanced, or full (default: balanced)
--personal-only Only report personal identifiable information (PII)
--help Show help message
Examples:
truscanner scan ./src --with-ai --ai-provider openai
truscanner scan ./src --with-ai --ai-provider bedrock
truscanner scan ./src --with-ai --ai-provider ollama
AI Speed vs Coverage Modes
Use --ai-mode to control AI scan behavior:
fast: Small prompts, fastest runtime, may skip very large low-signal filesbalanced(default): Good speed while keeping broad file coveragefull: Largest context and highest coverage, slowest runtime
Examples:
truscanner scan ./src --ai-mode fast
truscanner scan ./src --ai-mode balanced
truscanner scan ./src --ai-mode full
๐ Report Output
Report Location
Reports are saved in: reports/{sanitized_directory_name}/
Report Formats
- TXT Report (
truscan_report.txt): Plain text format, easy to read - Markdown Report (
truscan_report.md): Formatted markdown with headers and code blocks - JSON Report (
truscan_report.json): Structured JSON data for programmatic access
Report Contents
Each report includes:
- Scan Report ID: Unique 32-bit hash identifier
- Summary: Configured data elements, distinct detected elements, total findings, and time taken
- Findings by File: Detailed list of data elements found in each file
- Summary by Category: Aggregated statistics by data category
JSON reports also include:
configured_data_elementsdistinct_detected_elements
Report ID
Each scan generates a unique Scan Report ID (32-bit MD5 hash) that:
- Appears in the terminal after scanning
- Is included at the top of all generated report files
- Can be used to track and reference specific scans
๐ง Configuration
The truscanner package is pre-configured with the live backend URL for seamless scan uploads.
AI Provider Credentials
truScanner loads environment variables from .env and from your exported shell environment.
Start by copying the sample file in the repo root:
cp .env.example .env
OpenAI:
OPENAI_KEY=your-openai-key
Shell export:
export OPENAI_KEY=your-openai-key
AWS Bedrock:
TRUSCANNER_ACCESS_KEY_ID=your-access-key
TRUSCANNER_SECRET_ACCESS_KEY=your-secret-key
TRUSCANNER_REGION=us-east-1
TRUSCANNER_MODEL_ID=anthropic.claude-3-haiku-20240307-v1:0
Shell export:
export TRUSCANNER_ACCESS_KEY_ID=your-access-key
export TRUSCANNER_SECRET_ACCESS_KEY=your-secret-key
export TRUSCANNER_REGION=us-east-1
export TRUSCANNER_MODEL_ID=anthropic.claude-3-haiku-20240307-v1:0
Notes:
- If you do not set
TRUSCANNER_MODEL_ID,truScannerdefaults toanthropic.claude-3-haiku-20240307-v1:0. - Legacy environment variable names such as
TRUSCANNER_OPENAI_KEY,OPENAI_API_KEY, andAWS_*are still accepted as fallback.
๐ Project Structure
truscanner/
โโโ src/
โ โโโ main.py # CLI entry point
โ โโโ regex_scanner.py # Core scanning engine
โ โโโ ai_scanner.py # AI/LLM scanning engine
โ โโโ report_utils.py # Report utilities
โ โโโ utils.py # Utilities
โโโ data_elements/ # Data element definitions
โโโ reports/ # Generated reports
โโโ pyproject.toml # Project configuration
โโโ README.md
๐ Change Policy
For this repository, every code or behavior change must include a matching README update in the same change.
This includes:
- CLI flags, prompts, defaults, scan behavior, output format changes
- Python API changes (
import truscanner, return schema, parameters) - Dependency/runtime requirements
- Report format/location updates
๐ค Support
For issues, questions, or contributions, please contact: hello@truconsent.io
MIT License - see LICENSE file for details
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 truscanner-0.2.8.tar.gz.
File metadata
- Download URL: truscanner-0.2.8.tar.gz
- Upload date:
- Size: 42.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
258cf1aa489789c89ebee2da97eae40fcbdc49a69013ffcf41b0965269b39d23
|
|
| MD5 |
1c28a15b2d864bf847cb1d37e2391d6c
|
|
| BLAKE2b-256 |
b336dbd5eda25246fa07786320bfbfb38643e16a479c20160dd7d9547a07f1f8
|
File details
Details for the file truscanner-0.2.8-py3-none-any.whl.
File metadata
- Download URL: truscanner-0.2.8-py3-none-any.whl
- Upload date:
- Size: 56.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3cde387c548960e90d2252b3058c22ee0c3797e2d9c2a0ffa3d997761087349
|
|
| MD5 |
921135cd3e867dce5c8c2825f7f32e7a
|
|
| BLAKE2b-256 |
4b293e98f0b7b158bbe5c6432ca3d8fa089f25af029dde184e006b38bdc7df59
|