HawkScan Runner
VS Code extension for running StackHawk DAST security scans against any service with one click. Discovers services automatically via stackhawk.yml, manages credentials securely, and uses AI to suggest fixes for findings.
Features
- Auto-discovery — finds every service with a
stackhawk.yml in the workspace, no manual config needed
- Credential management — stores per-service credentials in a gitignored
.hawkscan.env file; prompts for missing ones before each scan
- Local scan mode — runs scans entirely on-machine when no StackHawk API key is set; results saved as JSON
- Cloud scan mode — set
hawkscan.hawkApiKey to upload results to app.stackhawk.com
- AI-assisted remediation — uses Databricks AI Gateway (Anthropic) to suggest code fixes for each finding
- IIS Express integration — auto-starts and stops IIS Express for .NET Framework services
- Any stack — works with .NET, Node.js, Java, Python, or any project that has a
stackhawk.yml
Requirements
- StackHawk CLI (
hawk.exe) installed
- Python 3.x (for local scan mode)
- IIS Express (for .NET Framework services) — optional
Installation
From VSIX (recommended for team members)
- Download
hawkscan-runner-1.0.0.vsix from the shared location
- In VS Code: Extensions panel →
... → Install from VSIX...
- Select the file and reload VS Code
Cursor IDE
Cursor is a VS Code fork and supports this extension natively — install using the same VSIX steps above.
First-Time Setup
- Open your project workspace in VS Code
- Click the HawkScan icon in the activity bar
- All services with a
stackhawk.yml are discovered automatically
- Click ▶ next to a service — if credentials are missing, the credential form opens automatically
- Fill in your credentials and click Save & Run Scan
Credentials are saved to .hawkscan.env at the workspace root and are never committed (the extension auto-adds the file to .gitignore).
Configuration
Open VS Code Settings (Ctrl+,) and search hawkscan:
| Setting |
Default |
Description |
hawkscan.hawkApiKey |
(empty) |
StackHawk org API key — leave blank for local-only scans |
hawkscan.hawkExePath |
C:\Program Files\StackHawk\hawk.exe |
Path to hawk.exe |
hawkscan.iisExpressPath |
C:\Program Files\IIS Express\iisexpress.exe |
Path to IIS Express |
hawkscan.iisStartTimeoutSeconds |
30 |
Seconds to wait for IIS Express to start |
hawkscan.anthropicApiKey |
(shared team key) |
Anthropic API key for AI remediation |
hawkscan.anthropicBaseUrl |
(shared gateway URL) |
Anthropic base URL (Databricks AI Gateway) |
hawkscan.hawkApiKey — each project has its own StackHawk API key. Set this per-workspace in .vscode/settings.json so different projects use different keys.
Credentials (.hawkscan.env)
The extension prompts for missing credentials before each scan and saves them to .hawkscan.env. The file format:
# Shared OAuth2 credentials (used by all OAuth2 services)
TenantId=your-azure-ad-tenant-id
ClientId=your-shared-client-id
ClientSecret=your-shared-client-secret
Scope=api://your-scope/.default
# Per-service credentials
# Service name must match the directory name shown in the sidebar
MyServiceApplicationId=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
MyServiceClientId=service-specific-client-id # only if different from shared
MyServiceClientSecret=service-specific-secret # only if different from shared
MyServiceScope=api://service-specific-scope # only if different from shared
MyServiceTestPath=/api/healthcheck # optional path override
Never commit .hawkscan.env — it contains secrets. The extension adds it to .gitignore automatically.
Scan Modes
Local scan (no API key)
Results are saved as security-scan-{ServiceName}.json in the workspace root and displayed in the VS Code Output panel.
[HawkScan] Mode: Local scan — results stay on this machine
[HawkScan] Tip: Set hawkscan.hawkApiKey in VS Code settings to upload results to app.stackhawk.com
Cloud scan (API key set)
Results are uploaded to app.stackhawk.com in real time. Use the Open Results button in the sidebar after the scan completes.
How Service Discovery Works
The extension recursively searches the workspace for stackhawk.yml files (up to 4 levels deep). Any directory containing one is treated as a scannable service — no hardcoded service list.
The service name is derived from the directory name with common prefixes stripped (LVIS.Services., com., org., etc.).
Port detection tries (in order):
.hawkscan-config.json in the service directory
Properties/launchSettings.json (ASP.NET Core)
.csproj <DevelopmentServerPort> (IIS Express / .NET Framework)
package.json start script PORT= (Node.js)
After a scan, choose Apply AI Fixes from the notification. The extension opens a terminal with the AI credentials pre-set and runs local-security-scan.py --autofix, which:
- Reads findings from the scan report
- Sends each finding to the Anthropic AI gateway with the relevant source file as context
- Suggests and applies code patches
The shared AI gateway credentials are pre-configured — no setup needed for team members.
Package for Distribution
npm install -g @vscode/vsce
cd path\to\hawkscan-runner
vsce package
# Produces: hawkscan-runner-1.0.0.vsix
Project Structure
hawkscan-runner/
├── out/ # Extension source (JavaScript)
│ ├── extension.js # Entry point, command registration
│ ├── ServiceDiscovery.js # stackhawk.yml auto-discovery
│ ├── CredentialManager.js # .hawkscan.env read/write
│ ├── CredentialWebview.js # Credential form UI
│ ├── HawkRunner.js # hawk scan execution
│ ├── IISRunner.js # IIS Express lifecycle
│ └── ServiceTreeProvider.js # VS Code sidebar tree
├── templates/
│ ├── local-security-scan.py # Local scan script (bootstrapped to workspace)
│ └── .hawkscan.env.template # Credential file template
├── resources/
│ └── hawk-icon.svg
└── package.json
Security Notes
.hawkscan.env is always gitignored — the extension enforces this automatically
- Credentials are stored only on the local machine
- The StackHawk API key and Anthropic key are never logged or included in scan output
- Scan results in local mode never leave the machine