Source intelligence
Hardcoded credentials
When nightvision openapi extract reads your code, it also looks for credentials written into the repository: a signing key in a settings file, a database password in a connection string, a private key committed by mistake. It writes what it finds to a report next to the spec.
The analysis is on by default and runs on your machine. The report never contains a credential’s value, so it is as safe to share as the spec.
What is found
Section titled “What is found”Credentials in code
Section titled “Credentials in code”A string literal is reported when it reaches an API that takes a credential. The analysis follows the value through assignments, attributes, configuration objects and string concatenation, the same way it follows a route’s path. This means it reports a credential by what the code does with it, not by what the value looks like, so a short or ordinary-looking password is found and a random-looking string that is never used as a credential is not.
It covers all seven languages: C#, Go, Java, JavaScript and TypeScript, PHP, Python and Ruby. The kinds of credential it recognizes:
| Kind | Examples |
|---|---|
signing-key |
A JWT signing secret, a Flask or Django secret key, a session or cookie signing key |
password |
A database password, in a connection URL or a client call. An SMTP password. A password that basic-auth middleware checks requests against |
api-key |
An OpenAI or Anthropic API key, a Stripe key, a key sent in a request header |
access-key |
An AWS secret access key, an Azure storage account key |
token |
A bearer token in an Authorization header, a GitHub or GitLab token in a URL |
private-key |
A private key passed to a signer or a TLS configuration |
encryption-key |
A cipher key, a Rails master key |
A default counts. In os.environ.get("SECRET_KEY", "dev-secret"), the literal is reported, and the finding names the environment variable it is the default for. The deployment may set the variable, so the literal may not be the production value. It is still in the repository.
Credentials in application configuration
Section titled “Credentials in application configuration”Settings in the configuration files your framework reads are reported where they are written, with the setting’s name. This covers files such as Spring’s application*.properties and application*.yml, ASP.NET’s appsettings*.json and Web.config, Rails’ config/*.yml and Laravel’s config files.
A setting in a profile or environment variant, such as application-dev.yml or appsettings.Development.json, is reported too, and the finding names the profile.
Committed credential files
Section titled “Committed credential files”Every repository is checked for these files, whatever language it is written in:
| Rule | Files | Reported |
|---|---|---|
file.dotenv |
.env, .env.*, *.env |
Variables whose name holds a credential, such as PASSWORD, SECRET, TOKEN or API_KEY, and any connection string that carries a password |
file.private-key |
*.pem, *.key, id_rsa and the other SSH key names |
Each private key block. A key protected by a passphrase is marked as encrypted |
file.private-key |
*.jwk, *.jwks, jwks.json |
Each JSON Web Key that holds its private part |
file.private-key |
*.p12, *.pfx, *.jks, *.keystore |
The private keys of a PKCS #12 file or Java keystore that opens with no password or a default one. The password is never reported |
file.rails-master-key |
config/master.key, config/credentials/<environment>.key |
The key that decrypts Rails’ encrypted credentials |
file.npmrc |
.npmrc, .yarnrc.yml |
Registry tokens and passwords |
file.pypirc |
.pypirc |
The password for each package index |
file.aws-credentials |
.aws/credentials |
The secret access key for each profile |
file.git-credentials |
.git-credentials |
URLs that carry a password |
file.netrc |
.netrc, _netrc |
The password for each machine |
file.agent-settings |
.claude/settings.json, .claude/settings.local.json |
Credentials saved in a coding agent’s settings. See below |
Template files such as .env.example and application.sample.yml are skipped for their variables.
Private keys in any file
Section titled “Private keys in any file”A private key is as often pasted into a file that hands it to a program as it is saved in a key file. The analysis looks through every text file for a private key block: a YAML value, a JSON string, a multi-line string in source code, an environment variable with its line breaks written as \n, or a .crt file that holds a server’s key beside its certificate.
Outside a file named as a key, a block is reported only when it decodes to a real key. This keeps out placeholders and the truncated examples that documentation shows.
Keys in tests are test vectors, so files under directories such as test, tests, spec and fixtures, and test source files, are not read for private keys. A file named as a key is read wherever it is.
Coding agent settings
Section titled “Coding agent settings”When you approve a command in Claude Code with “don’t ask again”, the command is saved in .claude/settings.local.json exactly as it was typed. If the command held a password or a token, the settings file now holds it too. Teams also commit .claude/settings.json on purpose.
The analysis reads both files and reports the credentials in:
- Approved, denied and ask-first shell commands, such as
PGPASSWORD=... psql,mysql -p...,sshpass -p ...,docker login -p ...andcurl -H "Authorization: ..." - Connection strings and URLs that carry a password or a GitHub or GitLab token
- Hook and status line commands, and the headers of HTTP hooks
- The
envblock - An
apiKeyHelperthat prints a literal key
Each finding names the setting it was found under, such as permissions.allow or env.NAME, and the program the credential was handed to.
What is not reported
Section titled “What is not reported”- Values the source does not fix. A value read from the environment with no default, from a file, or from a secrets manager.
- Placeholders. Empty values,
${VAR},<your-key>,xxxx,your_api_key_here, and text containingplaceholderordummy. Weak real values such assecret,passwordandchangemeare reported, because applications are deployed with them. - Encrypted or hashed values. A Jasypt
ENC(...)value, a Spring Cloud Config{cipher}value, or a stored password hash. - Connection strings with no password.
- Keys that only verify. A public key given to a JWT verifier.
- Local emulator keys. The published Azurite and Azure Storage emulator account key.
- Code the analysis does not reach. A credential is seen where the analysis can follow the value to a call it knows. A library it does not model is not covered. The committed-file checks do not have this limit.
Run it
Section titled “Run it”There is nothing to turn on. Any extraction runs the analysis:
nightvision openapi extract . --target my-apiTo look at a repository without creating anything in NightVision or uploading anything:
nightvision openapi extract . --no-uploadThe run writes openapi-spec-credentials.json beside the spec. With --output api.yml, the report is api-credentials.json. The summary at the end of the run has a Credentials row with the count by kind and the first findings by location:
Credentials 8 found (password=4, private-key=3, signing-key=1) src/main/java/hawk/api/jwt/JwtTokenProvider.java:22 signing-key (jwt) src/main/resources/application-postgresql.properties:4 password (postgresql) src/main/resources/application-postgresql.properties:30 password (keystore)These are the first lines of the row for Java Spring Vulny, one of the example applications.
The summary holds no values. If the run found credentials and you gave no key, the CLI says that the values were not captured.
Read the report
Section titled “Read the report”The report is one JSON object with a findings list:
{ "format": "nightvision.hardcoded-credentials", "version": 2, "sealed": false, "findings": [ { "id": "eacf96293fca917e", "rule": "python.pyjwt.key", "kind": "signing-key", "source": "code", "language": "Python", "location": { "file": "config.py", "line": 13, "column": 37 }, "sinks": [ { "file": "models/user_model.py", "line": 48, "column": 23 } ], "service": { "kind": "jwt", "attributes": { "algorithm": "HS256" } } } ]}| Field | Meaning |
|---|---|
id |
A stable identifier, made from the rule and the location. Never from the value |
rule |
What found it: <language>.<library>.<parameter>, or file.<kind> for a committed file |
kind |
What the credential is. See Credentials in code |
source |
code for a literal in code, config for a setting in an application configuration file, file for a committed credential file |
location |
Where the credential is written |
sinks |
Where the code uses it. Empty for config and file findings |
service |
What the credential opens. kind names the service, such as postgresql, aws, jwt, smtp, http or openai. endpoint is the host or URL when the source names one, with any username, password and query removed. attributes holds details such as a JWT algorithm, a header name, the setting it is held under or the configuration profile |
fallbackFor |
The environment variables whose default the literal is |
publiclyKnown |
true for a committed private key that can be computed from its public half. See Cryptography analysis reference |
partial |
Present only when the run was interrupted. The report holds what was found until then |
To fix a finding, rotate the credential first. Removing it from the file leaves it in the repository’s history. Then load the new value from the environment or a secrets manager.
Fail a pipeline on findings
Section titled “Fail a pipeline on findings”The report is plain JSON, so a pipeline can gate on it. For example, with jq:
nightvision openapi extract . --target my-apitest "$(jq '.findings | length' openapi-spec-credentials.json)" -eq 0Seal the values with a key
Section titled “Seal the values with a key”The report leaves the values out on purpose. When a reviewer needs the actual values, for example to confirm which ones still work, pass a public key:
nightvision openapi extract . --target my-api --credentials-key public.jsonThe CLI then also writes openapi-spec-credentials.sealed.json. It holds the same findings with their values, encrypted to the key with HPKE (RFC 9180). Only the holder of the matching private key can open it.
- The sealed file is never uploaded. It stays where the run wrote it.
- The key file is JSON in the
nightvision.credentials-keyformat. It holds a public key only. - The key is loaded before the CLI signs in. A key that cannot be read fails the run before anything else happens.
--credentials-keyneeds the analysis, so the CLI refuses it together with--no-credentials.
Treat the sealed file as a secret in transit: it is encrypted, but it contains every credential the run found. Store and handle it as you would any other secret.
Turn it off
Section titled “Turn it off”nightvision openapi extract . --target my-api --no-credentialsNo report is written or uploaded. --credentials turns it back on, and the last of the two on the command line wins.
To skip some paths but keep the analysis, use --exclude. The committed-file checks honor it.
What is uploaded
Section titled “What is uploaded”Unless you pass --no-upload, the redacted report is uploaded to NightVision with the run’s diagnostics file, where NightVision uses it to support the product. It contains rules, locations and service names, and no values or usernames. See What leaves my machine.
Limits
Section titled “Limits”- The committed-file checks read files up to 1 MiB and stop at 200,000 directory entries. A run that stops at a limit logs a warning.
- The same credential written identically in several places may be reported at one of them.
- With
memoizeon innv.config, a literal handed to a repeated call may be missed.