Metadata-Version: 2.5
Name: bearscan
Version: 0.4.0
Summary: Defensive AppSec scanner for code and staging environments you own, mapped to OWASP Top 10 2025 and triaged by an LLM.
Project-URL: Homepage, https://github.com/cristhianzl/bearscan
Project-URL: Documentation, https://github.com/cristhianzl/bearscan/tree/main/docs
Project-URL: Repository, https://github.com/cristhianzl/bearscan
Project-URL: Issues, https://github.com/cristhianzl/bearscan/issues
Project-URL: Changelog, https://github.com/cristhianzl/bearscan/blob/main/CHANGELOG.md
Author: Cristhian Zanforlin Lousa
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: appsec,claude-code,devsecops,kali-linux,llm,owasp,sast,secret-scanning,security
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Quality Assurance
Requires-Python: >=3.12
Requires-Dist: httpx>=0.27
Requires-Dist: platformdirs>=4.2
Requires-Dist: pydantic>=2.7
Requires-Dist: reportlab>=4.2
Requires-Dist: rich>=13.7
Requires-Dist: typer>=0.12
Provides-Extra: browser
Requires-Dist: playwright>=1.48; extra == 'browser'
Description-Content-Type: text/markdown

<p align="center">
  <img src="https://raw.githubusercontent.com/cristhianzl/bearscan/main/docs/assets/banner.jpg" alt="bearscan" width="640">
</p>

<p align="center">
  <strong>Defensive AppSec scanner for the code and staging environments you own.</strong><br>
  Secrets, insecure code, vulnerable dependencies, IaC, and live web exposure, mapped to OWASP and triaged by an LLM.
</p>

<p align="center">
  <a href="https://github.com/cristhianzl/bearscan/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/cristhianzl/bearscan/ci.yml?branch=main&label=CI"></a>
  <a href="https://pypi.org/project/bearscan/"><img alt="PyPI" src="https://img.shields.io/pypi/v/bearscan"></a>
  <img alt="Python 3.12 | 3.13 | 3.14" src="https://img.shields.io/badge/python-3.12%20%7C%203.13%20%7C%203.14-3776AB">
  <img alt="OWASP Top 10 2025" src="https://img.shields.io/badge/OWASP%20Top%2010-2025-1f6feb">
  <a href="https://github.com/cristhianzl/bearscan/blob/main/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/github/license/cristhianzl/bearscan"></a>
</p>

<p align="center">
  <a href="#quick-start">Quick start</a> ·
  <a href="https://github.com/cristhianzl/bearscan/blob/main/docs/README.md">Documentation</a> ·
  <a href="https://github.com/cristhianzl/bearscan/blob/main/docs/kali-linux.md">Kali Linux guide</a> ·
  <a href="https://github.com/cristhianzl/bearscan/blob/main/CHANGELOG.md">Changelog</a>
</p>

---

bearscan audits a repository or a staging URL with one command. It runs its own rules, drives the
open-source security tools already installed on your machine (or all of them from a Kali container), merges
everything into one report with CWE and OWASP labels, and asks an LLM to separate real problems from noise.
The reviewer runs on your existing **Claude Code** or **Codex** login, or fully locally with **Ollama**.
Results go to your terminal, JSON, SARIF for GitHub code scanning, or an executive PDF.

<p align="center">
  <img src="https://raw.githubusercontent.com/cristhianzl/bearscan/main/docs/assets/demo-scan-path.svg" alt="bearscan terminal report: summary panel, findings table with LLM verdicts, and detail panels for a leaked AWS key and a Stripe key in git history" width="900">
</p>

<p align="center"><sub>Real output: a demo repository scanned on Kali Linux with all four code tools installed, triaged by Claude Code.</sub></p>

## Highlights

- **Secrets, now and in history.** 15 secret detectors with masking everywhere, plus
  [gitleaks and trufflehog](https://github.com/cristhianzl/bearscan/blob/main/docs/external-tools.md#tools-for---path) to find keys in commits you deleted
  long ago. A key found by several tools is reported once.
- **Mapped to every relevant OWASP list.** [47 built-in rules](https://github.com/cristhianzl/bearscan/blob/main/docs/rules.md) for secrets,
  JavaScript/TypeScript, Python, and LLM and AI agent applications, plus semgrep's security rulesets. Each
  finding carries its CWE, its OWASP Top 10 2025 category, and, where it applies, the OWASP API Security
  Top 10 2023, LLM Top 10 2025 and 2026, and Agentic Top 10 2026 labels
  ([coverage](https://github.com/cristhianzl/bearscan/blob/main/docs/rules.md#standards-coverage)).
- **Reads your code like a security engineer.** [Deep analysis](https://github.com/cristhianzl/bearscan/blob/main/docs/deep-analysis.md)
  maps every route (FastAPI, Flask, Express, Next.js, Supabase Edge Functions) with its full URL, its guards,
  and the functions it calls across files, then has the reviewer trace each handler for missing ownership
  checks (IDOR), missing authentication, injection, SSRF, and logic flaws that line-based rules miss. Every
  finding must quote the exact line it is about, or bearscan discards it, and comes with counterevidence, a
  fix, and the test that proves it.
- **AI apps and agents.** Catches model output executed as code or rendered as HTML, agents with shell
  tools, `trust_remote_code=True`, pickled models and vector stores, LLM keys shipped to browsers, and user
  input in system prompts.
- **Vulnerable dependencies and IaC.** osv-scanner checks your lockfiles and names the version that fixes
  each advisory; trivy checks Dockerfiles, Kubernetes manifests, Helm charts, Terraform, and
  CloudFormation.
- **Staging checks with a real browser.** `--url` maps the site with headless Chromium, records the API
  calls each page makes, and checks security headers, cookie flags, CORS, and secrets or sensitive fields
  (`password_hash`, tokens) in API responses. testssl.sh, whatweb, and nuclei's read-only exposure
  templates add TLS, version disclosure, and exposed files such as `.env` and `.git/config`.
- **Less noise before any LLM.** The same statement flagged by several rules or tools is one finding;
  tests, migrations, fixtures, docs, and examples drop a severity level; and a committed
  [`.bearscanignore`](https://github.com/cristhianzl/bearscan/blob/main/docs/usage.md#cutting-noise) keeps
  accepted findings quiet, with `bearscan ignore --dismissed` to accept what the reviewer dismissed.
- **Triage, not noise.** An [LLM reviewer](https://github.com/cristhianzl/bearscan/blob/main/docs/llm-triage.md) labels each finding *likely real*,
  *false positive*, or *uncertain*, with a confidence, a rationale, and a fix. It can never change a
  severity or hide a finding from the JSON.
- **Built for CI and audits.** `--sarif` for code scanning, `--fail-on high` for failing builds, a
  [GitHub Action](https://github.com/cristhianzl/bearscan/blob/main/docs/ci.md), and `bearscan report --pdf`
  with OWASP coverage and the related ISO 27001 and SOC 2 controls.
- **Everything in one command.** Every supported tool found on `PATH` is used automatically,
  `bearscan setup` installs the missing ones (Homebrew on macOS, apt on [Kali Linux](https://github.com/cristhianzl/bearscan/blob/main/docs/kali-linux.md)),
  and `bearscan scan --docker` runs all of them inside the official [Kali image](https://github.com/cristhianzl/bearscan/blob/main/docs/docker.md) with
  nothing to install but Docker.
- **Private by design.** Secrets are masked before anything is printed, saved, or sent, and you can see
  [exactly what leaves your machine](https://github.com/cristhianzl/bearscan/blob/main/docs/security-model.md#what-leaves-your-machine).

## Quick start

1. **Install** bearscan (Python 3.12+):

   ```bash
   pipx install bearscan
   ```

2. **Scan** the repository you are in. Without a reviewer installed, add `--no-review`:

   ```bash
   cd my-repo
   bearscan scan
   ```

3. **Go full:** let bearscan install the [external tools](https://github.com/cristhianzl/bearscan/blob/main/docs/external-tools.md) for git history,
   semgrep, dependency, and TLS checks, or run them all from the Kali image instead:

   ```bash
   bearscan setup             # installs what is missing, after asking
   bearscan scan              # now with every tool

   bearscan scan --docker     # or: no installs, every tool runs inside Kali
   ```

## Installation

```bash
pipx install bearscan
# or
uv tool install bearscan
```

Then add the external tools and the browser for `--url` with one command, on macOS (Homebrew) or Kali,
Debian, and Ubuntu (apt), and stay current with `bearscan update`:

```bash
bearscan setup
bearscan update
```

Prefer containers? `bearscan scan --docker` uses `ghcr.io/cristhianzl/bearscan`, a Kali image with every
tool, for amd64 and arm64. Manual installs, reviewers, and upgrades are covered in the
[installation guide](https://github.com/cristhianzl/bearscan/blob/main/docs/installation.md).

## Usage

```bash
bearscan scan                                      # scan the current directory, deep analysis and triage
bearscan scan --path ./my-repo                     # scan another repository
bearscan scan --llm codex                          # triage with Codex
bearscan scan --llm ollama                         # triage with a local model
bearscan scan --deep-budget 60                     # deep analysis over more of a large application
bearscan scan --no-review                          # deterministic checks only
bearscan scan --json > run.json                    # machine-readable output
bearscan scan --sarif out.sarif --fail-on high     # CI: SARIF, and exit code 3 on high or critical
bearscan scan --url https://staging.example.com    # browser crawl, headers, CORS, API exposure, TLS
bearscan scan --docker                             # every tool, inside the Kali image
bearscan ignore --dismissed                        # accept what the reviewer dismissed
bearscan report --pdf report.pdf                   # executive PDF of the last run
bearscan setup                                     # install the missing tools
bearscan update                                    # upgrade bearscan
```

| Option | Description |
|---|---|
| `--path DIR` / `--url URL` | What to scan: a repository (default: the current directory) or a URL. |
| `--review / --no-review` | Triage findings with an LLM (default: on). |
| `--llm` | `claude-code` (default), `codex`, `ollama`, or `litellm`. |
| `--model`, `--llm-base-url` | Model and endpoint for the reviewer. |
| `--max-review N` | Most findings sent to the reviewer (default: 60). |
| `--deep/--no-deep`, `--deep-budget N` | Deep analysis of routes and auth code (default: on, 20 units). |
| `--json` | Print the run as JSON instead of the report. |
| `--sarif FILE` | Also write SARIF 2.1.0 for code scanning. |
| `--fail-on SEVERITY` | Exit with code 3 when an open finding is this severe or worse. |
| `--verify-secrets` | Let trufflehog confirm candidate secrets with their providers (sends them). |
| `--docker` | Run the tools inside the Kali image; the review still runs on your machine. |

Every option, environment variable, and exit code is in the [usage guide](https://github.com/cristhianzl/bearscan/blob/main/docs/usage.md).

## How it works

1. **Collect** the files git tracks (or walk the tree outside git), skipping binaries, lockfiles, and
   anything in `.gitignore`.
2. **Detect** with the built-in rules and every installed tool, then normalize each result to one severity
   scale with CWE and OWASP Top 10 2025 labels.
3. **Refine:** one finding per secret and per statement, a severity step down outside production code,
   and the `.bearscanignore` suppressions.
4. **Review** with the LLM backend you chose: deep analysis reads every route, the code it calls, and its
   guards to find what rules miss, and triage labels the open findings, production code first.
5. **Report** in the terminal, JSON, SARIF, or PDF, and save the run privately.

For rule and tool findings, deterministic checks decide what a finding is and how severe it is, and the
reviewer only adds a verdict and a fix. Deep analysis findings come from the reviewer, but each must quote
the exact line it is about, or bearscan discards it. See the [architecture](https://github.com/cristhianzl/bearscan/blob/main/docs/architecture.md) for the details.

### External tools

| Tool | Target | Adds |
|---|---|---|
| [gitleaks](https://github.com/gitleaks/gitleaks) | `--path` | Secrets anywhere in git history |
| [trufflehog](https://github.com/trufflesecurity/trufflehog) | `--path` | Hundreds of extra secret detectors over git history |
| [semgrep](https://github.com/semgrep/semgrep) | `--path` | AST-based analysis with the `p/default` and `p/owasp-top-ten` rulesets |
| [trivy](https://github.com/aquasecurity/trivy) | `--path` | Misconfigurations in Dockerfiles, Kubernetes, Helm, Terraform, and CloudFormation |
| [osv-scanner](https://github.com/google/osv-scanner) | `--path` | Known CVEs in lockfiles and manifests |
| [Playwright](https://github.com/microsoft/playwright-python) | `--url` | Browser crawl that maps pages and API calls for the built-in web checks |
| [testssl.sh](https://github.com/testssl/testssl.sh) | `--url` | Protocols, ciphers, certificates, TLS vulnerabilities |
| [sslscan](https://github.com/rbsec/sslscan) | `--url` | Fast TLS fallback when testssl.sh is unavailable |
| [whatweb](https://github.com/urbanadventurer/WhatWeb) | `--url` | Server and framework version disclosure |
| [nuclei](https://github.com/projectdiscovery/nuclei) | `--url` | Exposed files and misconfigurations, read-only templates only |

### LLM reviewers

| `--llm` | Runs on | How bearscan calls it |
|---|---|---|
| `claude-code` | your Claude Code login | Headless, no tools, restricted mode, empty working directory |
| `codex` | your Codex login | `codex exec` in a read-only sandbox, shell and web search off |
| `ollama` | your machine | Local API with a JSON schema, temperature 0 |
| `litellm` | any OpenAI-compatible endpoint | Chat completions with a JSON schema |

Only the flagged line and two lines of context on each side are sent, with secrets masked and repository
text fenced as untrusted data. Details in [LLM triage](https://github.com/cristhianzl/bearscan/blob/main/docs/llm-triage.md).

## Privacy and security

- The built-in scan sends nothing anywhere; `--no-review` with no tools installed is fully offline.
- trufflehog verifies secrets with their providers only when you pass `--verify-secrets`; semgrep runs
  with metrics off and never uploads code; osv-scanner sends only package names and versions.
- `--url` sends ordinary requests to the target: page loads, a few GET requests with a test `Origin`
  header to check CORS, and nuclei's read-only templates, with no fuzzing, brute force, exploit payloads,
  or out-of-band callbacks.
- Saved runs are written with `0600` permissions, because they map your weaknesses.

The full picture is in the [security model](https://github.com/cristhianzl/bearscan/blob/main/docs/security-model.md).

## Documentation

[Installation](https://github.com/cristhianzl/bearscan/blob/main/docs/installation.md) · [Kali Linux](https://github.com/cristhianzl/bearscan/blob/main/docs/kali-linux.md) · [Docker](https://github.com/cristhianzl/bearscan/blob/main/docs/docker.md) · [Usage](https://github.com/cristhianzl/bearscan/blob/main/docs/usage.md) · [CI](https://github.com/cristhianzl/bearscan/blob/main/docs/ci.md) ·
[LLM triage](https://github.com/cristhianzl/bearscan/blob/main/docs/llm-triage.md) · [External tools](https://github.com/cristhianzl/bearscan/blob/main/docs/external-tools.md) · [Rules](https://github.com/cristhianzl/bearscan/blob/main/docs/rules.md) ·
[Output format](https://github.com/cristhianzl/bearscan/blob/main/docs/output-format.md) · [Security model](https://github.com/cristhianzl/bearscan/blob/main/docs/security-model.md) ·
[Architecture](https://github.com/cristhianzl/bearscan/blob/main/docs/architecture.md) · [Troubleshooting](https://github.com/cristhianzl/bearscan/blob/main/docs/troubleshooting.md)

## Roadmap

- Authenticated `--url` crawling (login once, then scan behind it)
- `bearscan report --web` for a local dashboard
- A pre-commit hook

Ideas and votes are welcome in [issues](https://github.com/cristhianzl/bearscan/issues).

## Contributing

Contributions are welcome, from rule reports to new tool adapters. Read [CONTRIBUTING.md](https://github.com/cristhianzl/bearscan/blob/main/CONTRIBUTING.md)
to set up the project, and follow the [Code of Conduct](https://github.com/cristhianzl/bearscan/blob/main/CODE_OF_CONDUCT.md).

## Security

Found a vulnerability in bearscan itself? Please report it privately as described in
[SECURITY.md](https://github.com/cristhianzl/bearscan/blob/main/SECURITY.md).

## Responsible use

bearscan is a defensive tool. Scan only code and systems you own or are explicitly authorized to test.

## Acknowledgements

bearscan stands on the shoulders of the tools it drives: gitleaks, trufflehog, semgrep, trivy, osv-scanner,
Playwright, testssl.sh, sslscan, whatweb, and nuclei. Its terminal output is built with
[Rich](https://github.com/Textualize/rich) and [Typer](https://github.com/fastapi/typer), its PDF with
[ReportLab](https://www.reportlab.com/), and its reviewer design borrows ideas from open-source AI security
agents such as Strix, Shannon, and PentAGI.

## License

Licensed under the [Apache License 2.0](https://github.com/cristhianzl/bearscan/blob/main/LICENSE).
