nosecretsv0.4.0

← All examples

Machine-readable output

--format json prints one array with path, line, column, rule, severity, fingerprint and masked preview, for editors, dashboards and scripts.

Machine-readable output

site/captures/usecases/json/
# deploy.py
import requests

GITHUB_TOKEN = "ghp_R2kT9xLm4Qv7Bn3Zc8Wd5Hf1Jg6Ys0AaPeXq"

def release(version):
    return requests.post(
        "https://api.github.com/repos/acme/app/releases",
        headers={"Authorization": f"token {GITHUB_TOKEN}"},
        json={"tag_name": version},
    )
$ git add deploy.py
$ nosecrets scan --staged --format json
[
  {
    "path": "deploy.py",
    "line": 3,
    "column": 17,
    "rule_id": "github-pat",
    "rule_name": "GitHub Personal Access Token",
    "severity": "critical",
    "fingerprint": "nsi_5e31772c2cb9",
    "preview": "ghp_...PeXq"
  }
]
  • --format json