Skip to content

CLI Options Reference

Commands

CommandSyntaxDescription
setupcsp-analyser setupInstall Playwright Chromium browser and verify system dependencies
crawlcsp-analyser crawl <url>Headless auto-crawl with violation capture
interactivecsp-analyser interactive <url>Headed manual browsing with violation capture
generatecsp-analyser generate [session-id]Regenerate policy from an existing session
exportcsp-analyser export [session-id]Export policy in a deployment-ready format
diffcsp-analyser diff <id-a> <id-b>Compare policies from two sessions
scorecsp-analyser score [session-id]Score policy against best practices
permissionscsp-analyser permissions [session-id]Show captured Permissions-Policy headers
sessionscsp-analyser sessionsList analysis sessions for the current project
startcsp-analyser startRun the MCP server over stdio (for AI agents)
hash-staticcsp-analyser hash-static <path>...Hash inline content in static HTML files (no browser)

Options

FlagTypeDefaultCommandsDescription
--depth <n>integer (0+)1crawlCrawl depth. 0 = single page, 1 = target + linked pages, etc.
--max-pages <n>integer (1+)10crawlMaximum number of pages to visit during crawl
--strictness <level>strict | moderate | permissivemoderatecrawl, generate, export, diff, scoreControls how specific source expressions are. See strictness levels.
--format <fmt>header | meta | nginx | apache | cloudflare | cloudflare-pages | azure-frontdoor | helmet | jsonheadercrawl, generate, exportOutput format for the generated policy. See export formats.
--storage-state <path>string (file path)--crawl, interactivePath to a Playwright storage state JSON file for authenticated sessions. Must have .json extension.
--save-storage-state <path>string (file path)--interactiveExport browser cookies and storage state to a JSON file when the session ends. See authentication guide.
--violation-limit <n>integer (0+)10000crawl, interactiveMaximum violations to accept per session. 0 for unlimited.
--report-onlybooleanfalsecrawl, generate, exportGenerate Content-Security-Policy-Report-Only instead of Content-Security-Policy
--project <name>stringauto-detectedcrawl, interactive, generate, export, score, permissions, sessionsOverride auto-detected project name. Also settable via CSP_ANALYSER_PROJECT env var.
--allbooleanfalsesessionsShow sessions from all projects instead of only the current one
--no-colorbooleanfalseallDisable coloured terminal output. Also respects the NO_COLOR environment variable.
--help, -h----allShow help text
--version, -v----allShow version number

Output behaviour

  • Policy output goes to stdout (pipeable to files or other tools)
  • Progress messages and errors go to stderr
  • Exit code 0 on success, 1 on error

This means you can pipe policy output directly:

bash
# Save nginx config
csp-analyser crawl https://example.com --format nginx > csp.conf

# Pipe JSON to jq
csp-analyser export --format json | jq '.directives'

Environment variables

VariableDescription
CSP_ANALYSER_PROJECTOverride auto-detected project name. Equivalent to --project <name> but useful in CI or Docker where the working directory may not have a package.json. The --project flag takes precedence if both are set.
NO_COLORWhen set (to any value), disables coloured terminal output. Equivalent to --no-color.
LOG_LEVELSet logging verbosity: debug, info, warn, error. Defaults to info.


Released under the MIT License.