Documentation
Guides
Zero-Config Setup (nat init)

Zero-Config Setup (nat init)

nat init inspects your project and generates a .natrc configuration file automatically — no manual editing required.

Quick use: Run nat init in your project root. NAT detects your framework, finds your OpenAPI spec, and writes .natrc — one command, zero config.


What it does

nat init performs three steps automatically:

  1. Detects your framework — scans package.json, requirements.txt, pom.xml, Gemfile, etc.
  2. Finds your OpenAPI spec — searches common locations (openapi.yaml, swagger.json, docs/api.yaml, etc.)
  3. Generates .natrc — writes a ready-to-use configuration file in the current directory

Usage

nat init [flags]

Flags

FlagDescription
--ciGenerate a CI-optimized config (adds --fail-on high, SARIF output, --no-color)
--forceOverwrite an existing .natrc
--template <name>Use a starter template (express, fastapi, django, spring, rails)

Framework detection

nat init recognizes the following frameworks automatically:

FrameworkDetection signal
Express / Nodepackage.json with express dependency
FastAPIrequirements.txt or pyproject.toml with fastapi
Djangomanage.py or django in requirements
Spring Bootpom.xml or build.gradle with spring-boot
RailsGemfile with rails
Go (chi / gin)go.mod with chi or gin
Laravelcomposer.json with laravel/framework

If your framework is not detected automatically, use --template to select the closest match:

nat init --template express

OpenAPI spec detection

nat init searches these locations in order:

  1. ./openapi.yaml / ./openapi.json
  2. ./swagger.yaml / ./swagger.json
  3. ./docs/openapi.yaml
  4. ./api/openapi.yaml
  5. ./src/openapi.yaml
  6. Running server at http://localhost:<port>/openapi.json (common FastAPI/Springdoc endpoint)

If a spec is found, the path is written to .natrc automatically. If none is found, a placeholder is written and a warning is shown.


Generated .natrc example

Running nat init on a FastAPI project produces something like:

# .natrc — generated by nat init v1.5.0
# Edit this file to customize your NAT configuration.
 
mode: saas
spec: ./openapi.yaml
base_url: http://localhost:8000
 
auth:
  type: bearer
  token: "${NAT_API_TOKEN}"
 
scan:
  fail_on: medium
  output_format: text
  max_findings: 50
 
export:
  type: none

CI-optimized .natrc

Running nat init --ci generates an extended config ready for pipeline use:

# .natrc — generated by nat init --ci v1.5.0
 
mode: saas
spec: ./openapi.yaml
base_url: "${BASE_URL}"
 
auth:
  type: bearer
  token: "${NAT_API_TOKEN}"
 
scan:
  fail_on: high
  output_format: sarif
  no_color: true
  max_findings: 100
 
export:
  type: github
  github_token: "${GITHUB_TOKEN}"
  github_repo: "${GITHUB_REPOSITORY}"
  export_min_severity: high

CI/CD integration

Run nat init --ci locally

nat init --ci

This creates a .natrc tuned for CI: SARIF output, high severity threshold, no color codes.

Commit .natrc to your repository

git add .natrc
git commit -m "chore: add NAT zero-config CI setup"
git push

Use in GitHub Actions

Because .natrc is committed, the nat-action picks it up automatically — no workflow inputs required:

- name: Run NAT scan
  uses: nat-testing/nat-action@v1
  with:
    api-key: ${{ secrets.NAT_API_KEY }}

The action reads fail_on, output_format, and all other settings from .natrc.


Troubleshooting

ProblemFix
nat init says "framework not detected"Use --template <name> to specify manually
nat init says "spec not found"Pass --spec <path> or edit the placeholder in .natrc after generation
.natrc already exists and nat init refuses to overwriteAdd --force to overwrite the existing file
Generated base_url is wrongEdit .natrc directly or re-run with --force after updating your env

Related

Was this helpful?