A FastAPI-based static code scanning tool for detecting secrets and other patterns in codebases.
- Scans codebases for secrets and other user-defined patterns.
- Extensible pattern system using JSON files.
- Simple REST API for integration.
app/- Main application codemain.py- FastAPI app and API endpointsconfig.py- Configuration and pattern loadingfile_walker.py- Codebase file traversalmatch_engine.py- Pattern matching logicschemas.py- Pydantic models for APIutils.py- Utility functions
patterns/- JSON pattern files (e.g.,secrets.json)test/- Test suitetest-repos/- Sample repositories for testing
POST /static/scan
Request Body:
{
"path": "relative/path/to/codebase",
"types": ["secrets"]
}path: Path to the codebase to scan (relative toSTORAGE_PATH)types: List of scan types (corresponds to pattern JSON files)
Response:
{
"matches": [
{
"pattern": "regex_pattern",
"file": "file/path",
"line": 42,
"snippet": "matched line",
"scan_type": "secrets"
}
]
}- Set environment variables in
.envor.env.sample:STORAGE_PATH: Base directory for codebases (default:/mnt/shared/codebases)PATTERN_DIR: Directory for pattern JSON files (default:app/patterns)
Add new JSON files in the patterns/ directory. Each file should contain regex patterns for a scan type.
- Install dependencies:
pip install -r requirements.txt - Set up your
.envfile. - Start the server:
uvicorn app.main:app --reload