Scan your code
in one minute.
Trojan runs on your machine and reports security issues in plain English. This guide gets you from zero to your first report — no security background needed.
Install & run
You don't need an account. From the root of any project, run:
$ npx trojan scan
Trojan detects your stack automatically and scans secrets, dependencies and code. Prefer a window over a terminal? Install the desktop app and point it at a folder:
# macOS $ brew install --cask trojan # Windows / Linux curl -fsSL https://trojancli.com/install.sh | sh
Supported: JavaScript / TypeScript, Python, Go, Ruby, Rust, Java, PHP and more. Node 18+ required for the CLI.
Understanding results
Every finding answers three questions in plain language: what is wrong, why it matters, and the exact fix. Here's a typical entry:
Why it matters: Anyone who can read this file — or your git history — can use this key to access your AWS account and run up a bill or steal data.
Fix: Move the key to an environment variable, rotate it in the AWS console, and add .env to your .gitignore.
Severity levels
Trojan ranks every finding on five levels — by how likely it is to be exploited and how much damage it would do. Work top to bottom; stop when it's safe to ship.
Config file
Drop a trojan.config.json at your project root to set defaults. Everything is optional.
{
"minSeverity": "medium",
"scan": ["secrets", "deps", "code"],
"ignore": ["vendor/**", "*.min.js"]
}Ignoring findings
Sometimes a finding is a false positive or an accepted risk. Silence a single line with a comment — Trojan records who ignored it and why:
// trojan-ignore: test fixture, not a real key
const SAMPLE_KEY = "AKIA...EXAMPLE";CI/CD Pro
Fail a build when a scan finds anything above your threshold. Trojan exits non-zero so your pipeline stops. Here's a GitHub Actions step:
- name: Trojan security scan
run: trojan ci --output trojan.sarif
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trojan.sarifCI mode and private org rules require a Pro plan. See pricing →
Pre-commit hook
Block commits that introduce Critical or High severity findings. Install from your project root:
trojan hook install
This writes a pre-commit hook that runs a fast, headless scan before each commit. If Critical or High findings are detected, the commit is blocked. To remove:
trojan hook uninstall
CLI commands
| Command | What it does |
|---|---|
| trojan scan | Scan the current directory |
| trojan scan --fix | Apply safe automatic fixes (Pro) |
| trojan scan --watch | Re-scan on every file save |
| trojan dast <url> | Scan a running local server for runtime vulnerabilities |
| trojan ci | CI mode — outputs SARIF 2.1.0, exits non-zero on findings above threshold |
| trojan ci --severity <level> | Set the exit threshold (default: high) |
| trojan hook install | Install a pre-commit hook that blocks Critical/High commits |
| trojan hook uninstall | Remove the Trojan pre-commit hook |
| trojan report | Open the last report in your browser |
| trojan watch | Re-scan on every file save |
| trojan login | Connect your Pro account |
| trojan mcp install | Configure AI editors to use the Trojan MCP server (Pro) |
| trojan update | Check for and install a newer version |
| trojan version | Print the installed version |
FAQ
Does my code get uploaded?
No. Scanning runs entirely on your machine. See the privacy policy for exactly what a Pro account syncs.
How long does a scan take?
A few seconds for most projects — about 4 seconds on a 100,000-line repository. Large monorepos scan incrementally.
Will it break my build?
Only if you ask it to. Locally it just reports; in CI it fails only above the threshold you set with --severity.