Secret & Environment Guard

An offline review of selected source and configuration for credential-like patterns and environment handling.

Input
UTF-8 source and configuration files
Output
A bounded report with redacted values and review status; the scan can miss unsupported or multiline formats.

What it does

  • Redacts candidate values in its report
  • Labels real-format matches, likely candidates, fixtures, and placeholders separately
  • Never validates credentials online

Overview

Secret & Environment Guard is a local Python 3.11+ CLI that scans a project directory for hardcoded credential patterns—such as AWS access key IDs, GitHub tokens, and credential assignments—while redacting every matched value from its JSON report. It performs offline format-only checks without modifying files or testing whether a credential is live.

When to use it

  • Scanning a local repository or agent workspace for leaked API keys before committing or zipping an archive.
  • Enforcing a non-zero exit code (exit 1) in local scripts or CI whenever REAL_SECRET or LIKELY_SECRET patterns appear.
  • Generating a shareable JSON finding log where sensitive values are always replaced with [REDACTED].

Scan a project for credential patterns

Needs Python 3.11 or newer and only the standard library. Run from the package directory and point it at the project directory.

python3 tool.py /path/to/project

Sample output

Abridged output from the 0.1.0 package, run on a small synthetic fixture. The fixture held one fake key; the value never appears in the report.

{
  "complete": true,
  "findings": [
    {
      "classification": "LIKELY_SECRET",
      "kind": "credential_assignment",
      "file_id": "file-1",
      "safe_location": "agent.py",
      "line": 1,
      "value": "[REDACTED]"
    }
  ],
  "validation": "format only; never live validity"
}

Exit codes and limits

  • Exit 1 means a REAL_SECRET or LIKELY_SECRET finding, exit 0 means none within supported coverage, and exit 2 means an incomplete scan.
  • REAL_SECRET is a format check for AWS access key IDs and GitHub tokens; it does not show a credential is active.
  • Scans up to 2,000 files of 1 MiB each; unsupported providers, multiline keys and binary files may be missed.
  • No files are changed. A clean result is not proof that a project holds no secrets.

Questions

Will Secret & Environment Guard print my raw API keys into logs or stdout?

No. Matched secret values are never included in the report and are replaced with [REDACTED] alongside the file location and line number.

What do exit codes 0, 1, and 2 mean?

Exit 1 means a REAL_SECRET or LIKELY_SECRET finding was detected, exit 0 means none were detected within supported coverage, and exit 2 means the scan was incomplete.

Does REAL_SECRET mean the tool called AWS or GitHub to verify the key?

No. Validation is strictly offline format checking (for example AWS access key IDs and GitHub tokens); it never makes network requests or checks live validity.

What are the scan limits and blind spots?

It scans up to 2,000 files of 1 MiB each and modifies no files. Unsupported providers, multiline keys, and binary files may be missed, so exit 0 is not proof that a project contains zero secrets.