Documentation

CLI reference

Commands, options and exit codes of the ngbastion command-line interface.

Run any command with npx ngbastion <command>, or install ngbastion as a dev dependency. See Installation.

The help texts on this page are captured from the CLI at build time.

Text
NgBastion 0.3.0 — Angular-aware, local-first security scannerUsage: ngbastion <command> [options]Commands:  scan [dir]        Analyze an Angular workspace (default: current directory)  report compare    Compare two saved JSON reports  init              Create an NgBastion configuration file  explain <rule>    Show detailed documentation for a rule  rules             List available security rules  doctor            Check the environment, workspace and configurationGlobal options:  -h, --help        Show help  -v, --version     Show version  --no-color        Disable colors (also: NO_COLOR=1)Exit codes: 0 success · 1 security gate failed · 2 configuration or execution errorDocs: https://ngbastion.web.app/docs

ngbastion scan

Analyze an Angular workspace. Without a directory argument the current directory is scanned. Angular workspaces are discovered through angular.json; otherwise tsconfig.json, otherwise every .ts file in the directory.

Text
Usage: ngbastion scan [dir] [options]Options:  -f, --format <terminal|json|sarif|html>   Output format (default: terminal)  -o, --output <file>                  Write the report to a file  --diff <revision>                    Associate findings and trace locations with local Git changes  --baseline <file>                    Compare with a local baseline  --create-baseline                    Create baseline (default .ngbastion-baseline.json)  --update-baseline                    Explicitly replace an existing comparable baseline  --fail-on-status <all|new>           Gate all or new and uncertain findings  --fail-on-confidence <level>         Minimum confidence for the gate only  --redact-source                      Omit snippets and free-text scan evidence from HTML  -c, --config <file>                  Config file (default: ngbastion.config.{json,ts,…} in dir)  --fail-on <severity|none>            Gate threshold: critical|high|medium|low|info|none  --min-confidence <high|medium|low>   Hide findings below this confidence  -p, --project <name>                 Angular project to scan (repeatable)  --show-suppressed                    Also print suppressed findings (terminal)  -q, --quiet                          Only print the summary  --verbose                            Print evidence and informational diagnostics

ngbastion report

Compare two completed local JSON scans and inspect changes to findings and coverage.

Text
Usage: ngbastion report compare <previous.json> <current.json> [--format terminal|json] [--output file]

ngbastion init

Create a configuration file. In an interactive terminal without --format you are asked for the format; in CI it defaults to JSON. Existing configuration is never overwritten without --force.

Text
Usage: ngbastion init [dir] [options]Options:  --format <json|ts>          Config format (prompted in interactive terminals; default json)  --preset <name>             recommended | strict | enterprise | payments (default: recommended)  --force                     Overwrite an existing config file

ngbastion explain

Print the full documentation of a rule: description, rationale, detected patterns, unsafe and safe examples, remediation, limitations and false-positive considerations.

Text
Usage: ngbastion explain <RULE_ID>

ngbastion rules

List the available rules, optionally filtered.

Text
Usage: ngbastion rules [options]Options:  --category <name>           Filter by category  --severity <severity>       Filter by default severity  --json                      Machine-readable output

ngbastion doctor

Check Node.js compatibility, configuration validity, Angular workspace detection, TypeScript project resolution, plugin compatibility and file accessibility. Doctor never modifies the project and exits with 2 when it finds a problem.

Text
Usage: ngbastion doctor [dir] [-c <config>]Read-only checks; never modifies the project.

Exit codes

Code Meaning
0 Scan completed and the security gate passed (or --fail-on none). Other commands: success.
1 Security gate failed: at least one finding from a rule at level error has a severity at or above failOn. Findings from warn rules never fail the gate.
2 Configuration or execution error: invalid options or configuration, unloadable plugin, unknown project, a rule that crashed, or an error-level diagnostic. Treat it as "the scan result cannot be trusted".

Examples

Shell
ngbastion scan                                  # terminal report, gate on high+ngbastion scan --format sarif --output results.sarifngbastion scan --format json --fail-on criticalngbastion scan apps/web --project admin --min-confidence low --verbosengbastion init --format ts --preset strictngbastion explain NGB013ngbastion rules --category cross-window

Colors follow the terminal: they are disabled when output is not a TTY, with --no-color or NO_COLOR, and forced with --color or FORCE_COLOR.