ai-code-sec-audit
ai-code-sec-audit is a lightweight Python package and CLI that runs Bandit and Semgrep,
normalizes findings into a stable JSON schema, computes a deterministic score, and writes a
reproducible report.
Install
pip install ai-code-sec-audit
CLI usage
ai-code-sec-audit audit path/to/file.py -o report.json
ai-code-sec-audit audit path/to/dir -o report.json -f high
Options use short flags:
-o: output JSON path (required)-p: profile (default:default)-f: fail threshold (critical|high|medium|low|info)-P: pretty-print JSON
Python API
from ai_code_sec_audit import audit_path
report = audit_path("path/to/file.py", profile="default", fail_on="high")
print(report.summary.score)
Output schema
Canonical JSON report fields:
meta: tool_version, timestamp, target, profile, how_to_reproducesummary: score, total_findings, counts, should_failfindings[]: tool, rule_id, title, description, severity, confidence, cwe, file, start_line, end_line, fingerprint, references
Reproducible command
meta.how_to_reproduce contains the exact command with resolved target/output paths and selected
flags to reproduce the same report.
Sample JSON snippet
{
"meta": {
"tool_version": "0.1.0",
"target": "/abs/path/examples/vuln_python/app.py",
"profile": "default",
"how_to_reproduce": "ai-code-sec-audit audit /abs/path/examples/vuln_python/app.py -o /abs/path/report.json -p default"
},
"summary": {
"score": 86,
"total_findings": 2,
"counts": {
"critical": 0,
"high": 1,
"medium": 1,
"low": 0,
"info": 0
},
"should_fail": true
}
}
Scoring
Score starts at 100 and deducts:
- critical:
20 - high:
10 - medium:
4 - low:
1 - info:
0
Final score is clamped to 0..100.
Fail-on behavior
critical: fail if any critical findingshigh: fail if any critical/highmedium: fail if any critical/high/mediumlow: fail if any critical/high/medium/lowinfo: fail if any finding exists
CLI exits with status code 2 when threshold is met.
Scanner behavior
- Bandit command:
- directory:
bandit -r <target> -f json - file:
bandit <target> -f json
- directory:
- Semgrep command:
semgrep --config auto --json <target> - If scanner binaries are missing, warnings are printed and scanning continues.
Limitations (v0.1.0)
- No HTML reports
- No SARIF output
- Only Bandit + Semgrep are supported
- No advanced configuration system
Roadmap
- Additional scanner integrations
- Config file support
- Optional report enrichments and diff mode
Sample run artifacts
This repository includes sample-run inputs and outputs:
- Vulnerable input:
examples/vuln_python/app.py - Safer input:
examples/safe_python/app.py - Reproducible run script:
examples/sample_runs/run_samples.sh - Captured run logs:
examples/sample_runs/vuln_run.txt,examples/sample_runs/safe_run.txt - Generated reports:
examples/sample_runs/vuln_report.json,examples/sample_runs/safe_report.json
Run from repo root:
./examples/sample_runs/run_samples.sh
Publish to PyPI
This project is now configured for PyPI publishing with:
- package metadata in
pyproject.toml - reproducible
sdist+wheelbuilds viahatchling - a GitHub Actions workflow at
.github/workflows/publish.ymlthat uploads on release
One-time setup
- Create a project on PyPI named
ai-code-sec-audit. - In the PyPI project settings, enable Trusted Publishing for your GitHub repository
and the workflow file
.github/workflows/publish.yml. - Update
project.urlsinpyproject.tomlif your repository URL differs.
Release flow (recommended)
- Bump
src/ai_code_sec_audit/version.py. - Commit and tag a release in GitHub.
- Publish a GitHub Release (or run the workflow manually).
- The workflow builds, validates, and uploads the package to PyPI.
Manual upload (fallback)
python -m pip install --upgrade build twine
python -m build
twine check dist/*
twine upload dist/*
Development
ruff check .
ruff format .
mypy src
pytest
python -m build
twine check dist/*
License
MIT.
Metadata
Release files for ai-code-sec-audit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ai_code_sec_audit-0.1.0.tar.gz | 9.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ai_code_sec_audit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / ai_code_sec_audit-0.1.0.tar.gz
| Download URL | ai_code_sec_audit-0.1.0.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2f1b126589502fa1121a6166f0fd7543699e093f8446dd7f7fbdac6bfd62ba6
|
|
BLAKE2b-256 checksum How to use checksums |
81b10b39adca697a6ecd7fdb91bee8ce08e93fe6e4d5ff1e5aea86b3afa90a95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 14, 2026.
Transparency logRelease files / ai_code_sec_audit-0.1.0-py3-none-any.whl
| Download URL | ai_code_sec_audit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16ef7c9594e1ba6e59e8a2fed41a5bbc9490e843a6bdd44b59584be43ef7639a
|
|
BLAKE2b-256 checksum How to use checksums |
cf441010f30731f78b9983c329246cd27b806d22d56c506e7b29e1605b189b70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 14, 2026.
Transparency logSecurity for ai-code-sec-audit 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ai_code_sec_audit-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.