Metadata-Version: 2.5
Name: bearscan
Version: 0.2.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: rich>=13.7
Requires-Dist: typer>=0.12
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, and TLS, mapped to OWASP Top 10 2025 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, merges everything into one report with CWE
and OWASP Top 10 2025 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**.

<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)).
- **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.** osv-scanner checks your lockfiles and names the version that fixes each
  advisory.
- **Staging checks.** `--url` runs testssl.sh (or sslscan) and whatweb for protocols, ciphers,
  certificates, HSTS, and version disclosure.
- **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.
- **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 with one command, on macOS (Homebrew) or Kali, Debian, and Ubuntu (apt):

```bash
bearscan setup
```

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, triage with Claude Code
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 --no-review                          # deterministic checks only
bearscan scan --json > run.json                    # machine-readable output
bearscan scan --url https://staging.example.com    # TLS, certificate, and server checks
bearscan scan --docker                             # every tool, inside the Kali image
bearscan setup                                     # install the missing tools
```

| 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). |
| `--json` | Print the run as JSON instead of the report. |
| `--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. **Merge** duplicates: one finding per secret, and no semgrep repeats of built-in findings.
4. **Review** the findings that have code context with the LLM backend you chose.
5. **Report** in the terminal or as JSON, and save the run privately.

Deterministic checks decide what a finding is and how severe it is; the reviewer only adds a verdict and a
fix. 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 |
| [osv-scanner](https://github.com/google/osv-scanner) | `--path` | Known CVEs in lockfiles and manifests |
| [testssl.sh](https://github.com/testssl/testssl.sh) | `--url` | Protocols, ciphers, certificates, TLS vulnerabilities, HSTS |
| [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 |

### 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 never verifies secrets with their providers; semgrep runs with metrics off and never uploads
  code; osv-scanner sends only package names and versions.
- 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) ·
[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

- Built-in `--url` checks with Playwright: CSP, CORS, cookie flags, and data exposure in API responses
- `--fail-on <severity>` exit codes and SARIF output for CI pipelines
- `bearscan report --pdf` for an executive summary and `bearscan report --web` for a local dashboard
- A pre-commit hook and a GitHub Action

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, osv-scanner,
testssl.sh, sslscan, and whatweb. Its terminal output is built with [Rich](https://github.com/Textualize/rich)
and [Typer](https://github.com/fastapi/typer), 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).
