Production-grade AI security scanner with plugin-based detections
Project description
AI Guard
AI Guard is a CLI-first AI security scanner for codebases and GitHub repositories.
For a full beginner step-by-step walkthrough, see docs/user-guide.md.
It detects:
- Prompt injection risk patterns
- Sensitive data exposure
- API key leakage
- Unsafe AI output handling
Install (Global Users)
Install CLI globally:
npm install -g @scan5/ai-guard
Run without global install:
npx @scan5/ai-guard --help
Install SDK in an application:
npm install @scan5/ai-guard
SDK import path:
import { AIGuardSDK } from "@scan5/ai-guard/sdk";
60-Second Quickstart
npm install
npm run build
node dist/cli.js scan ./src
Optional HTML audit report:
node dist/cli.js scan ./src --html reports/scan-report.html
Optional JSON and SARIF outputs:
node dist/cli.js scan ./src --json reports/scan-report.json --sarif reports/scan-report.sarif
# Enterprise pipeline outputs
node dist/cli.js scan ./src \
--gitlab-sast reports/gl-sast-report.json \
--siem-json reports/siem-findings.ndjson
CI delta mode against a baseline report:
node dist/cli.js scan ./src --baseline reports/baseline.json --ci-delta
CLI Basics
Subscription plans and enforcement
AI Guard enforces plan-based access locally.
free: local scans only, no GitHub scan commands, no--ci-deltapro: GitHub scanning and--ci-deltaenabledteam: higher monthly quotaenterprise: unlimited quota
Check and set plan:
ai-guard subscription status
ai-guard subscription set --plan pro
Main command
ai-guard scan <path>
<path> can be:
- Local file path
- Local directory path
- GitHub repository URL
Examples
Local scan:
ai-guard scan ./src
Scan only a subdirectory:
ai-guard scan ./repo --subdir packages/security
GitHub scan (public repository):
ai-guard scan https://github.com/owner/repo
GitHub scan with ref and subdirectory:
ai-guard scan https://github.com/owner/repo --ref main --subdir src
GitHub scan with a custom token env var:
ai-guard scan https://github.com/owner/private-repo --github-token-env TEAM_GH_TOKEN
Authenticated GitHub workflow (recommended):
ai-guard auth login
ai-guard repo list
ai-guard scan-github
This flow limits repository selection to repositories accessible by the authenticated user.
Verbose mode:
ai-guard --verbose scan ./src
Help Commands
Show top-level help:
ai-guard --help
Show help for scan command:
ai-guard help scan
Show quickstart guide:
ai-guard quickstart
Show practical usage examples:
ai-guard examples
Output
CLI output includes
- Total issues
- Severity breakdown
- File and line references
- Fix suggestions
HTML output includes
- Professional audit-style UI
- Color-coded severity
- Grouped issues
- Fix suggestions and evidence
Generate HTML report:
ai-guard scan ./src --html reports/scan-report.html
## Enterprise Integrations
### GitHub Advanced Security
- CI workflow includes SARIF upload via `github/codeql-action/upload-sarif@v3`.
- Generated SARIF carries OWASP/NIST/EU compliance metadata per rule.
### GitLab SAST
- Generate GitLab SAST report:
```bash
ai-guard scan ./src --gitlab-sast gl-sast-report.json
- Use
.gitlab-ci.ymltemplate in repository root.
SIEM (Splunk / Datadog / Elastic ECS)
- Generate ECS-compatible NDJSON events:
ai-guard scan ./src --siem-json reports/siem-findings.ndjson
Pre-commit hook (staged-only)
- Package:
packages/ai-guard-pre-commit - Scope: local workspace helper (not published as a standalone npm package)
- Hook command (published CLI):
npx @scan5/ai-guard scan ./src - Scans staged snapshot only for fast feedback.
Semgrep export
- Rules file:
rules/semgrep/ai-guard-rules.yml - Load directly in existing Semgrep pipelines.
VS Code Language Server extension
- Package:
packages/vscode-ai-guard-extension - Inline diagnostics for:
- hardcoded system prompts
- missing input sanitization
- unvalidated tool args
- Quick fixes included for common remediation paths.
## Private GitHub Repositories
AI Guard supports private repositories via token authentication.
Supported defaults:
- `AI_GUARD_GITHUB_TOKEN`
- `GITHUB_TOKEN`
Custom token env variable:
```bash
ai-guard scan https://github.com/owner/private-repo --github-token-env TEAM_GH_TOKEN
Reliability and Testing
Run all tests:
npm test
Run only unit tests:
npm run test:unit
Run only integration tests:
npm run test:integration
Benchmarking
Run scanner benchmark on src with default iterations:
npm run benchmark
Run benchmark on a custom path with explicit iterations:
npm run benchmark -- ./src 10
Unified Findings and Correlation APIs
AI Guard now includes a unified findings layer for combining static and dynamic results.
Capabilities:
- Ingestion paths for static and dynamic findings
- Fingerprint-based deduplication with stable identifiers across rescans
- Cross-plane correlation by rule family, location, and service path
- Severity promotion when both planes confirm risk
- Queryable triage views for prioritization workflows
Core modules:
src/unified/finding-ingestion-service.tssrc/unified/correlation-engine.tssrc/unified/triage-query-api.tssrc/contracts/unified-findings.ts
Typical usage flow:
- Ingest static findings from scan output.
- Ingest dynamic findings from runtime SDK output.
- Query correlated and promoted findings using triage APIs.
- Use triage view summary for dedupe reduction and cross-plane confirmation.
Exit Codes
0: Scan completed successfully1: Runtime failure2: Validation/config/input error
Troubleshooting
If a scan fails:
- Re-run with
--verbose - Check path/ref/subdir inputs
- For private GitHub repos, confirm your token variable is set
- Use
ai-guard examplesfor working command patterns
Scale and Operations (Phase 6)
Operational docs:
- docs/operations/phase6-capacity-planning.md
- docs/operations/phase6-load-test-results.json
- docs/operations/phase6-failure-runbook.md
- docs/operations/phase7-compliance-configuration.md
Run the Phase 6 load benchmark:
npm run benchmark:phase6
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scan5-0.1.0.tar.gz.
File metadata
- Download URL: scan5-0.1.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aefbedf04d96fa1fb96b0cab88ab81a01bdf8b0754d186f8f9f6812bef39552f
|
|
| MD5 |
03c9f0d5b98b1a1391d913721ac853c2
|
|
| BLAKE2b-256 |
06e74ea28ff648077335ac17ace00ce017bbfb0f143a9bf38f9a83c0837c9fd0
|
File details
Details for the file scan5-0.1.0-py3-none-any.whl.
File metadata
- Download URL: scan5-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad2e2019f5637f740ce3ad064b07139e1af7c56454fa600439a2f2fc26b702af
|
|
| MD5 |
b58579d52c0d5dbcb0e9007016846540
|
|
| BLAKE2b-256 |
00bec8f43f03c6220f765cb3f0b68998c8fa606ededb9cb68b151cecb8cf7057
|