@scan5/ai-guard
v0.1.1
Published
CLI-first AI security scanner
Readme
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-guardRun without global install:
npx @scan5/ai-guard --helpInstall SDK in an application:
npm install @scan5/ai-guardSDK import path:
import { AIGuardSDK } from "@scan5/ai-guard/sdk";60-Second Quickstart
npm install
npm run build
node dist/cli.js scan ./srcOptional HTML audit report:
node dist/cli.js scan ./src --html reports/scan-report.htmlOptional JSON and SARIF outputs:
node dist/cli.js scan ./src --json reports/scan-report.json --sarif reports/scan-report.sarifCI delta mode against a baseline report:
node dist/cli.js scan ./src --baseline reports/baseline.json --ci-deltaCLI Basics
Main command
ai-guard scan <path><path> can be:
- Local file path
- Local directory path
- GitHub repository URL
Examples
Local scan:
ai-guard scan ./srcScan only a subdirectory:
ai-guard scan ./repo --subdir packages/securityGitHub scan (public repository):
ai-guard scan https://github.com/owner/repoGitHub scan with ref and subdirectory:
ai-guard scan https://github.com/owner/repo --ref main --subdir srcGitHub scan with a custom token env var:
ai-guard scan https://github.com/owner/private-repo --github-token-env TEAM_GH_TOKENAuthenticated GitHub workflow (recommended):
ai-guard auth login
ai-guard repo list
ai-guard scan-githubThis flow limits repository selection to repositories accessible by the authenticated user.
Verbose mode:
ai-guard --verbose scan ./srcHelp Commands
Show top-level help:
ai-guard --helpShow help for scan command:
ai-guard help scanShow quickstart guide:
ai-guard quickstartShow practical usage examples:
ai-guard examplesOutput
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.htmlPrivate GitHub Repositories
AI Guard supports private repositories via token authentication.
Supported defaults:
AI_GUARD_GITHUB_TOKENGITHUB_TOKEN
Custom token env variable:
ai-guard scan https://github.com/owner/private-repo --github-token-env TEAM_GH_TOKENReliability and Testing
Run all tests:
npm testRun only unit tests:
npm run test:unitRun only integration tests:
npm run test:integrationBenchmarking
Run scanner benchmark on src with default iterations:
npm run benchmarkRun benchmark on a custom path with explicit iterations:
npm run benchmark -- ./src 10Unified 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