PluginWorks in Claude CodeCurrent
Nightvision
Skills for working with NightVision, a DAST and API Discovery platform that finds exploitable vulnerabilities in web applications and REST APIs
0
Try it
See what this would do for you. No sign-up needed.
Install in Claude Code
Run these in Claude Code, in order. The first adds the marketplace, the second installs the plugin.
Step 1
/plugin marketplace add anthropics/claude-plugins-official
Step 2
/plugin install nightvision@claude-plugins-official
Review commands before running them. Promptu never runs code on your machine or pushes changes to your repo.
What's inside
5 skills
- api-discovery
- app-security-scan
- ci-cd-integration
- scan-configuration
- scan-triage
Security scan
Flagged
Promptu's text scan flagged something in this plugin. Read its files before you install it.
sudo in skills/ci-cd-integration/SKILL.md:87
Details
<div align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/nv-icon-dark.png">
<img alt="NightVision" src="assets/nv-icon.png">
</picture>
# NightVision Agent Skills
**Your best defense is a good offense: give your coding agent NightVision skills.**
<br>
[](LICENSE)
[](https://agentskills.io)
[](https://docs.anthropic.com/en/docs/claude-code)
[](https://nightviz.ai)
</div>
---
[NightVision](https://nightviz.ai) is a developer-first DAST and API security platform. It dynamically tests running web applications and APIs, discovers REST endpoints from supported source code, and connects validated findings to source locations when that context is available.
These [Agent Skills](https://agentskills.io) give your coding agent the ability to run NightVision scans, triage results, and integrate security testing into your CI/CD pipelines, all from natural language. Agent Skills are an open format supported by Claude Code, OpenAI Codex, Cursor, and other agentic tools, so the same skill folders work across whichever agent you use.
## Installation
The skills live in `skills/` as portable Agent Skills folders. Install them into whichever agent you use.
### Claude Code
From the terminal:
```bash
claude plugin marketplace add nvsecurity/claude-marketplace
claude plugin install nightvision@nvsecurity
claude
```
Or from inside Claude Code:
```
/plugin marketplace add nvsecurity/claude-marketplace
/plugin install nightvision@nvsecurity
```
> You may need to restart Claude Code for the plugin to load.
### Codex, Cursor, and other Agent Skills tools
The `skills/` folders are standard Agent Skills, so any compatible agent can load them. The method that works across tools is to copy or symlink the folders into a skills directory your agent scans. `~/.agents/skills/` is read by both Codex and Cursor at the user level:
```bash
git clone https://github.com/nvsecurity/nightvision-skills.git
mkdir -p ~/.agents/skills
cp -R nightvision-skills/skills/* ~/.agents/skills/
```
Use a project-level `.agents/skills/` instead to scope the skills to one repository.
Tool-specific shortcuts:
- **Codex**: `$skill-installer` installs skills by name and can be prompted to fetch from a GitHub repository. Codex also reads `.agents/skills/` and `~/.agents/skills/` directly.
- **Cursor**: add via Settings -> Rules -> Project Rules -> Add Rule -> Remote Rule (GitHub) with this repository's URL, or use the directory method above (Cursor also reads `.cursor/skills/`).
## Skills
| Skill | What it does |
|:------|:-------------|
| **`app-security-scan`** | Run the DAST-first app scan harness for local, private, staging, and internal apps. Uses MCP `run-app-security-scan` when available to preflight, discover APIs, create/update targets, start scans, return scan IDs, poll status, summarize findings, export SARIF/CSV, and write a manifest |
| **`scan-configuration`** | Set up DAST scans — create targets, configure authentication (Playwright, headers, cookies), manage projects, define scope exclusions, and prepare private network scans |
| **`scan-triage`** | Interpret scan results — read SARIF/CSV findings, understand vulnerabilities, locate the vulnerable code, validate with curl, prioritize by severity, suggest fixes, and mark false positives |
| **`api-discovery`** | Extract OpenAPI specs from source code via static analysis, troubleshoot extraction issues, compare specs across versions, and leverage Code Traceback |
| **`ci-cd-integration`** | Wire NightVision into your pipeline — GitHub Actions, GitLab CI, Azure DevOps, Jenkins, BitBucket, and JFrog with SARIF/CSV export and breaking-change detection |
### Example Usage
Just ask your agent what you need:
```
> Set up a NightVision scan for my API running on localhost:8080
> Run a NightVision app security scan for this local service
> Triage the results from my last scan and suggest fixes
> Add NightVision to my GitHub Actions workflow
> Extract an OpenAPI spec from this Django project
```
In Claude Code, invoke skills directly with slash commands:
```
/app-security-scan
/scan-configuration
/scan-triage
/api-discovery
/ci-cd-integration
```
## Enterprise agent-instructions block
For organization-wide agent instructions, use a block like this and pair it with a configured NightVision MCP server. Put it in the instructions file your agent actually reads: `CLAUDE.md` for Claude Code, `AGENTS.md` for Codex and Cursor. Claude Code does not read `AGENTS.md`, so if you already keep one, add `@AGENTS.md` inside `CLAUDE.md` rather than maintaining the text twice. Do not put shared NightVision credentials in this block.
This block is written for **unattended enforcement**: a population of developers (including non-technical ones) who build apps with an AI agent and will not think to run security testing themselves. It is phrased as a completion gate, not a suggestion, and it closes the loop so results reach a person even though nobody will ask for them. Pre-set `NIGHTVISION_DEFAULT_PROJECT` (and the CLI auth) in the managed MCP server config so the agent never has to ask the developer a NightVision question.
```md
## NightVision Security Workflow (required)
Whenever you create or materially change a web app, API, backend service, route handler, or deployable application, you MUST run a NightVision security scan as part of finishing that work. This is not optional and does not require the developer to ask for it.
Use the NightVision MCP. Prefer `run-app-security-scan`: it handles preflight, API Discovery, target create/update, DAST start, scan-ID return, and manifest writing in one call. DAST is the expected outcome; API Discovery alone is not enough.
To make the scan actually run, do the work the developer will not:
1. Start the app you just built or changed (use its own run command) so it is reachable locally, then pass that URL as `target_url`. If you cannot start it, say so as a concrete blocker.
2. Let `run-app-security-scan` detect the language, discover APIs from source, create/update the target, and start DAST. Most apps are local or internal; rely on NightVision Smart Proxy behavior rather than assuming the app is public.
3. Do not end your turn on an unfinished scan. Because the developer will not come back to check, either wait for the scan to reach a terminal status, or poll `wait-for-scan`/`get-scan-status` until it does, then `summarize-scan-findings` and export SARIF. Keep the MCP server running for local/private scans so the relay stays alive while the scan runs.
Auth: every NightVision action runs under the developer's own NightVision account configured in the managed MCP server. Never use shared tokens and never ask the developer to paste a token anywhere. For target-application login: use a NightVision app auth profile via `auth`/`auth_id`; for username/password or expiring sessions use Playwright script auth; use header/cookie auth only for stable, non-expiring credentials; otherwise run `no_auth: true` and note that coverage may be limited.
Completion contract: work on a new or materially changed app is not complete until either `.nightvision/manifest.json` exists with a NightVision DAST scan ID, or you have stated the exact blocker that prevented DAST (app would not start, no project, not authenticated, target unreachable). A terminal `FAILED` scan can still contain valid findings, so check issue counts and export/summarize before treating a run as unusable. Report the scan ID, the top findings, and the artifact paths to the developer. Never claim an app was scanned, secured, or free of vulnerabilities unless NightVision results support it.
```
> Trigger reliability note: an agent-instructions rule makes the agent scan reliably in the common case, but it is probabilistic, not guaranteed, on every single turn. For hard enforcement across a fleet, pair this block with a harness-level gate (for example a Stop/PreCompact hook or a CI check) that fails the turn/build when a new or changed app has no `.nightvision/manifest.json` with a scan ID. The block above is what makes the agent do the right thing; the hook is what guarantees it.
## Structure
```
nightvision-skills/
├── .claude-plugin/
│ └── plugin.json
├── skills/
│ ├── app-security-scan/
│ │ └── SKILL.md
│ ├── api-discovery/
│ │ ├── SKILL.md
│ │ └── references/
│ ├── ci-cd-integration/
│ │ ├── SKILL.md
│ │ └── references/
│ ├── scan-configuration/
│ │ └── SKILL.md
│ └── scan-triage/
│ ├── SKILL.md
│ └── references/
├── README.md
└── LICENSE
```
The `skills/` directory is the portable, tool-neutral asset. `.claude-plugin/plugin.json` is the Claude Code plugin manifest; other agents ignore it and load the skill folders directly.
## Contributing
Contributions are welcome! Please open an [issue](https://github.com/nvsecurity/nightvision-skills/issues) or submit a pull request.
## License
Apache License 2.0 — see [LICENSE](LICENSE) for details.
## skills/api-discovery/SKILL.md
---
name: api-discovery
description: Guide for agents to help users extract OpenAPI specs from source code using NightVision API Discovery. Use when running swagger extract, identifying framework support, troubleshooting extraction, handling unresolved variables, comparing API specs, or understanding Code Traceback.
allowed-tools: Bash
---
# NightVision API Discovery
Use this skill when helping users generate OpenAPI specifications from their source code using `nightvision swagger extract`. API Discovery performs static analysis — no running application or compilation needed — and annotates the spec with source file paths and line numbers (Code Traceback) so that vulnerabilities found during DAST scans trace back to exact code locations.
## Agent workflow
When a user asks to extract or document their API:
1. **Check prerequisites** — verify the NightVision CLI is available (`nightvision --help`)
2. **Examine the repo** — identify the backend language and web framework to determine the `--lang` flag and whether the framework is supported (see [references/framework-support.md](references/framework-support.md))
3. **Run extraction** — execute `nightvision swagger extract` with the appropriate flags. On success, the CLI prints `"Swagger file extracted successfully."` and writes the spec to the output path (default: `openapi-spec.yml`)
4. **Review the output** — read the generated spec to check completeness. Handle unresolved variables if `nv.config` was created alongside the spec
5. **Compare coverage** — if the user has an existing spec, run `nightvision swagger diff` to show what was discovered vs. what was documented
6. **Upload to target** — attach the spec to a NightVision target for scanning
**Related skills:** Use `scan-configuration` for target/auth setup, `ci-cd-integration` for pipeline integration, `scan-triage` for interpreting scan results.
## Language flags
| Language | Flag | Frameworks |
|----------|------|------------|
| Python | `--lang python` | Django, DRF, Flask, Flask-RESTful, FastAPI |
| Java | `--lang java` | Spring Boot, JAX-RS/Jersey, Micronaut, Java EE/Jakarta EE |
| JavaScript | `--lang js` | Express, NestJS, Fastify |
| C# | `--lang dotnet` | ASP.NET Core (controllers, minimal APIs) |
| Go | `--lang go` | Gin, httprouter, net/http (experimental) |
| Ruby | `--lang ruby` | Rails, Grape |
See [references/framework-support.md](references/framework-support.md) for detailed component coverage per framework.
## Running extraction
```bash
# Basic extraction (output defaults to openapi-spec.yml)
nightvision swagger extract . --lang python
# Specify output file and format
nightvision swagger extract . --lang java -o api-spec.json --file-format json
# Extract and upload directly to a NightVision target
nightvision swagger extract . -t my-api -p my-project --lang python
# Extract without uploading
nightvision swagger extract . -o openapi-spec.yml --lang java --no-upload
# Scan multiple source directories
nightvision swagger extract ./service-a ./service-b --lang python
# Extend an existing spec (add discovered endpoints to it)
nightvision swagger extract . --lang python --extend existing-spec.yml
# Exclude directories from analysis
nightvision swagger extract . --lang python --exclude vendor,generated
# Include code snippets in the spec (useful for debugging)
nightvision swagger extract . --lang python --dump-code
```
### Extraction fallback for CI
Extraction can fail if language detection fails or the framework isn't supported. Always guard against this in pipelines:
```bash
nightvision swagger extract . -t $TARGET --lang java || true
if [ ! -e openapi-spec.yml ]; then cp backup-openapi-spec.yml openapi-spec.yml; fi
```
## Handling unresolved variables
When static analysis can't resolve a variable (e.g., an API prefix read from an environment variable), it appears as a literal placeholder in the spec. NightVision generates an `nv.config` file to fix this.
**Steps:**
1. Run extraction — if unresolved variables exist, `nv.config` is created alongside the spec (in the first source directory passed to the command)
2. Open `nv.config` — find the `replacements` object with `null` values
3. Replace `null` with the actual values (check the app's config files, environment vars, etc.)
4. Re-run extraction — the tool reads `nv.config` and substitutes the values. You can also use `-c` / `--config` to explicitly specify the config file path: `nightvision swagger extract . --lang python -c path/to/nv.config`
```json
// nv.config example
{
"replacements": {
"Microsoft.AspNetCore.Builder.WebApplication.Services...ApiPrefix": null
}
}
```
The agent should help the user find the actual value by searching their config files (`appsettings.json`, `.env`, `settings.py`, etc.) and updating `nv.config`.
## Comparing API specs
Use `swagger diff` to measure coverage or detect breaking changes:
```bash
# Summary diff (paths and schemas counts)
nightvision swagger diff original-spec.yml discovered-spec.yml
# Show only path-level changes (endpoints added/removed/modified)
nightvision swagger diff original-spec.yml discovered-spec.yml --paths
# Show only schema changes
nightvision swagger diff original-spec.yml discovered-spec.yml --schemas
# Show the full diff (paths and schemas together, with details)
nightvision swagger diff original-spec.yml discovered-spec.yml --full-diff
# Save diff output to file
nightvision swagger diff original-spec.yml discovered-spec.yml -o diff-report.txt
```
Common use cases:
- **Coverage analysis** — compare a hand-written spec against the discovered one to find undocumented shadow APIs
- **PR checks** — diff specs from the base branch vs. PR branch to detect breaking API changes
- **Audit** — verify that all endpoints are documented
## Detecting existing specs
Search the codebase for existing OpenAPI/Swagger files. The `detect` command takes no positional arguments — use `-p` to specify the root folder:
```bash
# Detect project roots in the current directory
nightvision swagger detect
# Detect in a specific directory
nightvision swagger detect -p ./path/to/code
# Save detection results as JSON
nightvision swagger detect -o detection-results.json
```
## Code Traceback
The generated spec includes `x-source` annotations on each endpoint with the file path and line number where the route is declared. When this spec is used for DAST scanning:
- Vulnerabilities found by NightVision link directly to the source code
- GitHub Security Alerts, Azure Boards work items, and Jenkins Warnings show the exact file and line
- Developers see where to fix, not just what to fix
This is why using NightVision-generated specs (vs. hand-written ones) significantly improves the triage experience.
## Troubleshooting
| Issue | Cause | Fix |
|-------|-------|-----|
| No endpoints found | Wrong `--lang` flag, or unsupported framework | Verify the framework is supported, check `--lang` value |
| Unresolved variables in paths | Config values read from env vars without defaults | Fill in `nv.config` replacements and re-run |
| Incomplete routes | Custom routing, non-standard framework usage | NightVision relies on standard framework patterns; custom routing may not be detected |
| Extraction fails entirely | Syntax errors in source, missing files | Use `--diagnostics` to get language-level error details |
| Spec missing sub-routes | Code in subdirectories not scanned | Pass multiple paths: `nightvision swagger extract ./src ./lib` |
For unsupported frameworks or components, contact support@nightviz.ai.
## skills/app-security-scan/SKILL.md
---
name: app-security-scan
description: DAST-first NightVision scan for an app you just built or changed. Use when a user, or a project or org agent-instructions rule, wants a local, private, staging, or internal web app/API security-scanned. Drives the NightVision MCP `run-app-security-scan` harness.
allowed-tools: Bash, Read, Grep, mcp__nightvision__auth-status, mcp__nightvision__preflight-app, mcp__nightvision__run-app-security-scan, mcp__nightvision__wait-for-scan, mcp__nightvision__get-scan-status, mcp__nightvision__summarize-scan-findings, mcp__nightvision__export-sarif
---
# NightVision App Security Scan
Run a real DAST scan against an app you just built or changed. API Discovery runs first when the backend language is supported, because it improves coverage and lets findings trace back to a source file and line (Code Traceback). DAST is the expected outcome on every run, not just a generated spec.
Requirements: this skill drives the NightVision MCP server's app-security-scan harness, so it needs a server build that provides `run-app-security-scan`, `preflight-app`, `wait-for-scan`, `summarize-scan-findings`, and `export-sarif` with the `project_path` argument. On an older server these tools are missing (the call returns an unknown-tool error) or `export-sarif` ignores `project_path` and silently drops source-linking. If any of the listed tools is unavailable, update the NightVision MCP server before using this skill; running `preflight-app` first is the cheapest way to confirm the harness is present.
## Best-supported languages and frameworks
API Discovery uses deterministic static analysis to generate an OpenAPI spec for supported codebases. Source-linked results are strongest for the empirically verified languages and frameworks below:
- Python: Django, Django REST Framework, Flask, Flask-RESTful, FastAPI
- JavaScript/TypeScript: Express, NestJS, Fastify
- Java: Spring Boot, JAX-RS/Jersey, Micronaut, Java EE/Jakarta EE
- C#: ASP.NET Core controllers and minimal APIs
- Go: Gin, httprouter, and experimental `net/http` support
- Ruby: Rails and Grape
Treat frameworks outside this list, including PHP frameworks, as verify-first for source discovery. Still run DAST against reachable web apps and APIs as a WEB target when discovery is unsupported or produces no spec, but report that findings may not include source `file:line` traceback. Source-based discovery is REST/OpenAPI only.
## Workflow
1. Locate the app's source directory and pass it as `project_path`. Do not rely on the current working directory: a developer usually launches you from their home directory, not the repo, and API Discovery reads `project_path` to generate the spec that links findings to source. If you are not already in the repo, find it (the app's git root / where its source lives) and pass that absolute path. Running against the home directory is refused with `project_path_not_app_source`.
2. Know the app's URL. You are running on the developer's machine with the app's source in front of you, so you know how it serves. If it is not already running, start it with its own command (`npm run dev`, `docker compose up`, the framework dev server). Pass that URL as `target_url`. Do not ask the harness to guess it.
3. Call `run-app-security-scan` with `project_path`, `target_url`, the NightVision project, and the app-auth mode (see Auth). One call does preflight, API Discovery, target create/update, DAST start, and writes `.nightvision/manifest.json`. Always route the scan through this one harness call, even when the user already has a NightVision target or credential set up: pass their existing project and `auth`/`auth_id`, and the harness reuses and updates that target and refreshes API Discovery so its spec is not stale. Do not hand-assemble a scan from `create-target` / `start-scan` / `list-targets`; that path skips the fresh discovery and is how a scan silently exercises a stale spec.
4. Report the discovery result before you poll, so the user can see API Discovery ran and what it produced. The single harness call runs API Discovery, updates the target, and starts DAST in that order, but all of it is invisible from the outside: the user sees one tool call and then a long scan, which reads as "it skipped discovery and went straight to DAST". Do not let a 10+ minute scan be the first thing the user hears about. Read these fields off the result and state them in one or two sentences before the first poll:
- `api_discovery.status` (`success`, `no_spec`, `skipped`, or `failed`) and `api_discovery.attached_spec_file` (the spec that was pushed to the target).
- The endpoint count in that spec. Count the entries under `paths:` in the spec file (for example `grep -c '^ /' <attached_spec_file>`) and say how many endpoints DAST will exercise.
- `target.action` (`created`, `updated`, or `reused`) and the resolved target's `type`, nested at `target.target.type` (the `target` block wraps the action and the resolved target object). Any non-`WEB` type means the spec is attached and findings can carry source `file:line` (the backend echoes a spec-attached target as `API` or `OPENAPI`, so do not match on `API` alone); type `WEB` means it is scanning without a spec. Prefer `api_discovery.status` for the coverage judgment; treat the target `type` as confirmation only.
- The `scan_id`.
Anything other than `api_discovery.status: success` producing a spec-attached (non-`WEB`) target is a coverage problem: say so now, not after the scan burns 15 minutes against a stale or absent spec. This is the same failure the coverage floor in Reporting catches, only caught earlier.
5. It returns a `scan_id` quickly (`wait` defaults to false). DAST commonly runs longer than 10 minutes, so do not assume it finished.
6. Poll `wait-for-scan` or `get-scan-status` until a terminal status.
7. Export SARIF and summarize: call `export-sarif` with the SAME `project_path` you passed to the scan (it resolves the discovered spec from that repo's `.nightvision`, so findings carry endpoint + source file:line; without it the spec is looked up in the shell cwd and source-linking is silently lost) and `summarize-scan-findings`. Report the scan id, target, project, finding counts, and the top findings with endpoint, source file:line, evidence, and a suggested fix. If SARIF comes back `source_linked: false` but discovery produced a spec, you passed the wrong `project_path`. In a multi-language repo with several per-language specs and no canonical `openapi.yml`, `export-sarif` attaches the first spec and returns a warning; if the source-linking is for the wrong language, pass the right spec explicitly with `swagger_file`.
8. The manifest is the local record and stays in the repo. Treat the work as incomplete until `.nightvision/manifest.json` holds a `scan_id`, or you have reported a concrete blocker.
Resolve blockers the harness reports rather than working around them: `not_authenticated` / `invalid_or_expired_token` (auth), `target_url_required` (you did not pass the URL), `runtime_url_not_reachable` (the app is not up, start it), `nightvision_project_required`, `project_path_not_app_source` (you passed the home/root directory; pass the app's source directory). Use `dry_run: true` when the user only wants a readiness check without creating targets or starting a scan.
## Unattended mode
When a project agent-instructions rule triggers this after an app is built (no human watching): start the app yourself, rely on `NIGHTVISION_DEFAULT_PROJECT` and the environment's NightVision token (never prompt for them; a missing one is a blocker to report), and close the loop before ending your turn. Do not leave a scan running with nobody watching: poll to a terminal status, then export SARIF and summarize. If you cannot start the app or auth is missing, report that as the concrete blocker instead of silently skipping the scan.
## Auth
Two different things. NightVision account auth is the user's own NightVision token; never paste a shared token into your agent-instructions file (CLAUDE.md, AGENTS.md), a repo file, or a team config, each user authenticates as themselves. Target-app auth is how DAST logs into the app under test, passed to the scan as:
- `no_auth: true` to scan unauthenticated (say so; it may miss authenticated functionality).
- `auth` (named profile) or `auth_id` (credential UUID) for an existing NightVision app-auth credential.
- `app_auth` with `type: "playwright_script"` for any username/password, OAuth, MFA, or expiring-session login. Do not turn an expiring cookie or bearer token into a header/cookie credential.
- `app_auth` with `type: "headers"` or `"cookies"` only for stable, non-expiring credentials such as a service API key; set `credential_lifetime: "stable"`.
## Reporting
A terminal `FAILED` scan can still contain valid findings: check the finding count and summarize what it found before calling a run unusable. Never claim the app is secure or scanned unless NightVision results support it. If DAST could not run, report the blocker and the manifest path.
Coverage floor: a scan that "succeeded" but exercised no endpoints is a setup failure, not a clean bill of health. If a full scan returns zero findings, or only the "target is online" informational check, or the harness sets `coverage_suspect: true` on the scan result, treat it as suspect: the spec was stale, API Discovery did not run against current source, or the target was scanned as a bare WEB target. Do not report the app as secure. Re-run `run-app-security-scan` with `project_path` set to the app's source directory so discovery regenerates the spec, confirm the scan tested real endpoints, and only then report. A known-featureful app returning nothing is the tell.
## Remediation (find-to-fix)
When the user wants findings fixed and not just reported, use what each finding actually carries. It varies by class, so do not assume every finding gives you a source line or a parameter:
- Request-level findings (SQL injection, XSS, command injection, and similar) carry a source `file:line`, the endpoint, the vulnerable parameter, and the proof-of-concept payload. The `file:line` is the DAST-observable entry point (the endpoint handler), not always the sink: open it, follow the named parameter into the service or repository that uses it, find the sink, and apply the standard fix for the class (a parameterized query for SQL injection, output encoding for reflected XSS), matching the codebase's existing patterns.
- Response/config-level findings (missing security headers, weak authentication method, error or stack-trace disclosure) either have no source location, or the line they carry points at whatever handler the response was observed through, which is not where the fix goes. Fix these in the app's security configuration (the header/filter/security config), not at the reported line.
NightVision does not hand you a patch (`fixes`/`codeFlows` in the SARIF are empty), and not every finding maps to source, so treat this as a locate-and-fix aid. Always re-scan with `run-app-security-scan` and confirm the finding is gone before calling it fixed. Remediation is a follow-on to the scan, not a replacement: scan first, and only change code when the user asks for fixes.
## skills/ci-cd-integration/SKILL.md
---
name: ci-cd-integration
description: Guide for agents to help users integrate NightVision DAST scanning into CI/CD pipelines. Use when setting up security scans in GitHub Actions, GitLab CI, Azure DevOps, Jenkins, BitBucket, or JFrog pipelines, configuring NightVision tokens, creating targets, running scans, exporting results as SARIF/CSV, or detecting API breaking changes.
allowed-tools: Bash
---
# NightVision CI/CD Integration
Use this skill when helping users add NightVision security scanning to their CI/CD pipelines. NightVision is a white-box-assisted DAST tool that finds exploitable vulnerabilities in web applications and REST APIs. It combines API Discovery (static analysis to extract OpenAPI specs from source code) with dynamic scanning (ZAP + Nuclei engines), and traces vulnerabilities back to exact source code locations (Code Traceback).
## Agent workflow
When a user asks to set up NightVision in their pipeline:
1. **Check prerequisites** — verify the NightVision CLI is available (`nightvision --help`). If not installed, see the Installation section below.
2. **Examine the repo** — look for existing CI configs (`.github/workflows/`, `.gitlab-ci.yml`, `Jenkinsfile`, `bitbucket-pipelines.yml`, `azure-pipelines.yml`) to understand the CI platform and existing pipeline structure
3. **Ask the user** what you can't determine from the repo:
- Target URL (staging/production endpoint to scan)
- Target type — web app or API?
- Does the app require authentication to scan?
- What language is the backend? (needed for API Discovery)
- Have they already created a NightVision project, target, and token?
4. **Tell the user what they must do locally** — some steps require interactive browser sessions that the agent cannot perform (see Prerequisites below)
5. **Generate the pipeline config** — adapt the patterns below and the platform-specific examples in [references/ci-platforms.md](references/ci-platforms.md) to the user's repo, substituting their target name, language, app startup method, and CI platform conventions
**Related skills:** Use `scan-configuration` for detailed target/auth setup, `api-discovery` for spec extraction details, `scan-triage` for interpreting results.
## Pipeline structure
Every NightVision CI pipeline follows this pattern:
```
1. Install the NightVision CLI
2. Extract API spec from source code (API targets only)
3. Start the application (private/local targets only)
4. Run the scan (CLI polls until completion, ~5-15 min)
5. Export results (SARIF / CSV / GitLab DAST)
6. Upload to CI platform (GitHub Security, GitLab DAST, Azure Boards, Jenkins Warnings)
```
## Prerequisites the user must complete
These steps require interactive sessions (browser login, GUI) that the agent cannot perform. Instruct the user to run these locally before the pipeline will work.
**1. Create an API token** — requires browser-based login:
```bash
nightvision login
nightvision token create # no expiry
nightvision token create --expiry-date 2026-12-31 # with expiry
```
Tokens can also be created in the NightVision web UI: Profile > Settings > Tokens. The user must store the token as a CI secret named `NIGHTVISION_TOKEN`.
**2. Record authentication** (if the target requires login) — Playwright recording opens a browser:
```bash
nightvision auth playwright create my-auth https://myapp.example.com
# A Chrome window opens — user completes login, then closes the window
```
For API key / bearer token auth, the agent can help construct the command:
```bash
nightvision auth headers create my-auth \
-H "Authorization: Bearer <token>"
```
**3. Create the target** — the agent can help with this if `NIGHTVISION_TOKEN` is available:
```bash
# Web target
nightvision target create my-web-app https://staging.example.com --type WEB -p my-project
# API target with local spec
nightvision target create my-api https://api.example.com --type API -p my-project \
--spec-file openapi-spec.yml
# API target with remote spec URL
nightvision target create my-api https://api.example.com --type API -p my-project \
--spec-url https://api.example.com/docs/openapi.json
# Idempotent create-or-update (useful in pipelines)
nightvision target create my-api $URL --type API -p my-project --spec-file spec.yml \
|| nightvision target update my-api -p my-project --spec-file spec.yml
```
## Installation (in the pipeline)
```bash
# Linux Intel (standard for most CI runners)
curl -L https://downloads.nightvision.net/binaries/latest/nightvision_latest_linux_amd64.tar.gz | tar -xz
sudo mv nightvision /usr/local/bin/
```
For Linux ARM runners, substitute `linux_arm64` in the URL.
## Environment variables
| Variable | Required | Purpose |
|----------|----------|---------|
| `NIGHTVISION_TOKEN` | Yes | API token (store as CI secret) |
| `NIGHTVISION_API_URL` | No | API endpoint (default: `https://api.nightvision.net/api/v1/`) |
All config keys accept env vars with the `NIGHTVISION_` prefix (hyphens become underscores).
## CLI output format
Most `list` and `get` commands default to text output. Use `--format json` (or `-F json`) for machine-parseable output, or `--format table` for tabular display.
## API Discovery (spec extraction from source code)
For API targets, extract OpenAPI specs via static analysis. Supports Go, Python, Java, Ruby, C#, JavaScript.
```bash
# Extract and upload to a target
nightvision swagger extract . -t my-api -p my-project --lang python
# Extract locally without uploading
nightvision swagger extract . -o openapi-spec.yml --lang java --no-upload
# Compare specs for breaking changes (useful in PR checks)
nightvision swagger diff old-spec.yml new-spec.yml
```
**Important CI pattern — extraction fallback:** Extraction can fail if language detection fails. Always use:
```bash
nightvision swagger extract . -t $TARGET --lang java || true
if [ ! -e openapi-spec.yml ]; then cp backup-openapi-spec.yml openapi-spec.yml; fi
```
### Code Traceback
When API Discovery generates the spec, it annotates endpoints with file paths and line numbers. Vulnerabilities found during scanning trace back to exact source locations. This powers the file/line links in GitHub Security Alerts, Azure Boards work items, and similar CI integrations.
## Running scans
```bash
# Basic scan
nightvision scan my-target -p my-project
# Authenticated scan
nightvision scan my-target -p my-project --auth my-auth
# Unauthenticated (explicit, skip any stored credentials)
nightvision scan my-target -p my-project --no-auth
# Extended duration (default 30 min, max 480 min / 8 hours)
nightvision scan my-target -p my-project --max-duration-minutes 120
# Engine selection
nightvision scan my-target -p my-project --no-nuclei # ZAP only
nightvision scan my-target -p my-project --no-zap # Nuclei only
# Verbose logging (recommended for CI debugging)
nightvision scan my-target -p my-project --verbose
```
### Capturing the scan ID
In CI (non-interactive), the CLI prints the scan ID as the first line of stdout. Use this pattern:
```bash
nightvision scan $TARGET --auth $AUTH > scan-results.txt
SCAN_ID=$(head -n 1 scan-results.txt)
```
### Exit codes
| Code | Meaning |
|------|---------|
| 0 | Scan completed successfully (`SUCCEEDED`). Vulnerabilities may still have been found. |
| 1 | Scan failed (`FAILED`, `ABORTED`, `TIMED_OUT`), or other error. |
**Exit code 0 does not mean "no vulnerabilities."** Use export commands to inspect findings.
On failure (exit code 1), the CLI prints a status-specific error message:
- **TIMED_OUT** — includes the configured `--max-duration-minutes` value and suggests increasing it
- **ABORTED** — indicates the scan was aborted (by user or system)
- **FAILED** — includes a link to the dashboard for investigation
When the API provides a failure reason, it is included in the error message and displayed in the TUI dashboard.
### Private / internal targets (Smart Proxy)
NightVision's Smart Proxy automatically tunnels scan traffic through the CLI when the target is not publicly reachable (localhost, Docker, Kubernetes, corporate networks). No configuration needed — it's built into the CLI.
Use `--force-private-scan` to force tunneling when the target appears publicly accessible but isn't from the scanner's perspective.
## Exporting results
```bash
# SARIF with Code Traceback (API targets — provide the spec used for the scan)
nightvision export sarif -s "$SCAN_ID" --swagger-file openapi-spec.yml -o results.sarif
# SARIF without Code Traceback (WEB targets, or when no spec is available)
nightvision export sarif -s "$SCAN_ID" -o results.sarif
# CSV (for reports, spreadsheets, custom processing)
nightvision export csv -s "$SCAN_ID" -o results.csv
# GitLab DAST report (for the GitLab Vulnerability dashboard)
nightvision export gitlab -s "$SCAN_ID" --swagger-file openapi-spec.yml -o gl-dast-report.json
# Jira tickets (one per finding; severity sets priority; status changes sync back to findings)
# --jira-token is a classic user API token. For an Atlassian service-account token
# (always scoped), pass --jira-cloud-id <id> instead of --base-url (scopes: read:jira-work, write:jira-work).
nightvision export jira -s "$SCAN_ID" --project-key SEC \
--base-url https://your-org.atlassian.net --user-email you@example.com --jira-token "$JIRA_TOKEN"
```
`--swagger-file` is optional. When provided, SARIF output includes Code Traceback source annotations (file paths and line numbers linking findings to source code). When omitted, the SARIF is still valid but won't contain source locations. Always provide `--swagger-file` for API targets when the spec is available.
## CI platform quick reference
See [references/ci-platforms.md](references/ci-platforms.md) for complete, copy-pasteable pipeline configs.
| Platform | Results surface | Upload mechanism |
|----------|----------------|-----------------|
| GitHub Actions | Security tab (Code Scanning) | `github/codeql-action/upload-sarif@v3` (needs `permissions: contents: read, security-events: write`) |
| GitLab CI | Vulnerability dashboard | `nightvision export gitlab`, `artifacts.reports.dast` |
| Azure DevOps | Azure Boards work items | `sarif-manager azure create-work-items` |
| Jenkins | Warnings Next Generation | `recordIssues tool: sarif(pattern: 'results.sarif')` |
| BitBucket | Pipeline artifacts | SARIF as artifact |
| JFrog | Evidence on Docker packages | `jf evd create` with SARIF predicate |
## Troubleshooting
| Symptom | Cause | Fix |
|---------|-------|-----|
| "login authentication token has expired" | Token expired or invalid | `nightvision token create`, update CI secret |
| "API is unreachable" | Network/firewall issue | Check `NIGHTVISION_API_URL`, network connectivity |
| "SSL certificate error" | TLS verification failed | Fix certs, or `--skip-tls-verify` (not for production) |
| Scan `TIMED_OUT` | Exceeded max duration | CLI error message shows the current limit; increase `--max-duration-minutes` (up to 480) |
| Scan `ABORTED` | Scan was cancelled by user or system | Check the failure reason in the CLI output or dashboard |
| Scan `FAILED` | Engine error or target unreachable | CLI error includes a dashboard link; also use `--verbose` and verify target is up |
| 401 Unauthorized during scan | Auth credentials expired | Re-record authentication locally |
| "Repository not found" in checkout | `permissions` block missing `contents: read` | Add `contents: read` alongside `security-events: write` in the workflow permissions |
## skills/scan-configuration/SKILL.md
---
name: scan-configuration
description: Guide for agents to help users configure NightVision DAST scans. Use when creating t

