Secret catcher

Scan a code diff for credential-like spans and emit redacted findings, a gated redaction proposal, and a block decision without ever quoting a raw secret.

You’re reading version sha-b3cb896c55a4. Go to the current version

Overview

SKILL.md

What this skill does

This skill reads a unified diff and detects credential-like spans that a change would introduce. It scans only added lines, reports each match as a finding located by file, line, and column, proposes a redaction that a downstream executor can perform, and returns a block decision. A change that adds a credential blocks; a clean change does not.

The skill is read-only and offline. It makes no network calls, installs nothing, executes no caller-supplied code, and edits no files. It never quotes a raw secret: every finding carries a redacted preview and a one-way SHA-256 fingerprint instead of the matched value, and the runner fails closed rather than emit output in which a raw value could appear.

When to use this skill

Use this skill on a pull-request or pre-commit diff to catch a leaked credential before it lands. It is appropriate as a gate in an agent or CI pipeline that must decide whether a diff is safe to merge, and as the evidence step before a human or a downstream redaction executor acts. It produces a machine-checkable packet plus a concise Markdown report for reviewer handoff.

When not to use this skill

Do not use this skill as a full application security review, an entropy scanner over an entire repository history, or a guarantee that a diff is secret-free. Coverage is bounded by the detector set and the contents of the supplied diff. A zero-finding result means only that no configured detector matched an added line under the current rules.

Do not use it to remove or rewrite secrets. Redaction is proposed here and performed by the gated redact-pii executor; this skill never edits content.

Procedure

  1. Read the diff input (or diff_path for a diff stored inside the skill directory) and record its byte length and SHA-256.
  2. Walk the unified diff, tracking the current file and the new-file line number from each +++ header and @@ hunk header.
  3. On each added line, run every detector and record a finding with its type, { file, line, column } location, a redacted preview, and a fingerprint.
  4. Exclude placeholders, template interpolations, and environment-variable references so ordinary configuration does not false-block.
  5. Build a gated redaction_proposal for the redact-pii executor when any finding exists.
  6. Set block to true when there is at least one finding.
  7. Verify no raw secret value appears anywhere in the output; fail closed if it would.
  8. Emit secret.catcher.result.v1 and, when output_dir is set, write evidence.json and report.md.

Edge cases and stop conditions

Stop with an error when neither diff nor diff_path is provided, when diff_path resolves outside the skill directory, or when the diff exceeds the size limit. An empty diff or a diff with no added lines is a valid clean result: zero findings and block: false.

Removed lines and context lines are never scanned, so deleting a secret does not produce a finding. Findings are grounded only in added lines of the supplied diff; the skill never infers a secret that is not literally present.

If a caller sets apply (or perform_redaction / write) to true — asking the skill to perform the redaction itself — the skill refuses and stops. It never edits files or scrubs live content; that effect belongs to the gated redact-pii executor.

The redaction proposal is a proposed effect only. Any real edit, commit, or push needs its own authority gate and receipt through the redact-pii executor.

Output schema

The primary output is secret_catcher_result, with schema secret.catcher.result.v1:

json
{
  "schema": "secret.catcher.result.v1",
  "skill": "secret-catcher",
  "version": "0.1.0",
  "block": true,
  "findings": [
    {
      "type": "aws_access_key_id",
      "location": { "file": "config/prod.env", "line": 2, "column": 19 },
      "redacted_preview": "AKIA************…",
      "value_length": 20,
      "fingerprint": "sha256:1a5d44a2dca19669"
    }
  ],
  "redaction_proposal": {
    "decision": "proposed",
    "performed_by": "redact-pii",
    "requires_approval": true,
    "edits": [
      {
        "file": "config/prod.env",
        "line": 2,
        "column_start": 19,
        "column_end": 39,
        "replacement": "***REDACTED_AWS_ACCESS_KEY_ID***"
      }
    ],
    "note": "Proposal only. secret-catcher edits no files and scrubs no live content. The redact-pii executor performs the gated edit after approval."
  },
  "summary": {
    "added_lines_scanned": 4,
    "files_scanned": 1,
    "findings": 1,
    "finding_types": ["aws_access_key_id"]
  },
  "policy": {
    "scans": "added diff lines only",
    "grounded_in": "diff",
    "edits_files": false,
    "quotes_raw_secrets": false,
    "downstream_executor": "redact-pii",
    "detectors": ["aws_access_key_id", "aws_secret_access_key", "github_personal_access_token", "slack_token", "google_api_key", "stripe_secret_key", "private_key_block", "json_web_token", "generic_secret_assignment"]
  },
  "source": { "kind": "diff", "bytes": 0, "sha256": "hex" },
  "validation": {
    "grounded_in_diff": true,
    "every_finding_has_location": true,
    "block_iff_findings": true,
    "raw_secret_values_absent": true,
    "finding_rule": "..."
  }
}

When output_dir is provided, the runner also writes evidence.json and report.md inside that directory.

Worked example

The harness scans a diff that adds a production env file containing AWS's documented example credentials and a synthetic token:

bash
runx skill "$PWD" \
  --input-json diff='"diff --git a/config/prod.env b/config/prod.env\n--- /dev/null\n+++ b/config/prod.env\n@@ -0,0 +1,2 @@\n+AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE\n"' \
  --json

Expected result shape:

  • block is true.
  • findings[0].type is aws_access_key_id and its location points at the added line and column.
  • findings[0].redacted_preview masks the value and findings[0].fingerprint is a truncated SHA-256; the raw key never appears.
  • redaction_proposal.performed_by is redact-pii and requires_approval is true.

Swapping in a diff that only references process.env.API_KEY yields zero findings and block: false.

Inputs

  • diff: the unified diff to scan (required).
  • scan_context: optional metadata recorded with the result.
  • diff_path: optional path to a diff file inside the skill directory.
  • output_dir: optional directory for evidence.json and report.md.
  • apply: must be absent or false; if set, the skill refuses (it never edits files).

Outputs

  • secret_catcher_result: the complete packet.
  • block: boolean merge gate, true when any finding exists.
  • findings: array of { type, location, redacted_preview, value_length, fingerprint }.
  • redaction_proposal: gated proposal consumed by the redact-pii executor.

Published execution profile

The execution profile published with sha-b3cb896c55a4, shown as its exact bytes.

Runner
  • default
Profile digestsha256:cdfc831cea572141d78ece25fffb6e74c3ba2427df26897d5bf1d2920b4a0640
skill: secret-catcher
version: 0.1.1
catalog:
  kind: skill
  audience: public
  visibility: public
  role: canonical
  tags:
    - security
    - secrets
    - diff
  category: security
runners:
  default:
    default: true
    inputs:
      diff:
        type: string
        required: true
        description: Unified diff to scan. Only added lines are scanned; context and removed lines are ignored.
      scan_context:
        type: object
        required: false
        description: Optional metadata (for example repo, pr, base, head) recorded with the result.
      diff_path:
        type: string
        required: false
        description: Path to a unified diff file inside the skill directory, used when a diff is too large to pass inline.
      apply:
        type: boolean
        required: false
        description: Must be absent or false. If set, the skill refuses and stops — it never edits files; redaction is delegated to the gated redact-pii executor.
      output_dir:
        type: string
        required: false
        description: Directory inside the skill directory where evidence.json and report.md are written.
    steps:
      - id: default
        tool:
          command: /usr/bin/env
          args:
            - node
            - run.mjs
        inputs:
          diff: $input.diff
          scan_context: $input.scan_context
          diff_path: $input.diff_path
          apply: $input.apply
          output_dir: $input.output_dir
        outputs:
          block:
            required: false
          findings:
            required: false
          redaction_proposal:
            required: false
          secret_catcher_result:
            required: false
          policy:
            required: false
          scan_context:
            required: false
          schema:
            required: false
          skill:
            required: false
          source:
            required: false
          summary:
            required: false
          validation:
            required: false
          version:
            required: false
        scopes:
          - diff.read
harness:
  cases:
    - name: planted-secret-blocks
      runner: default
      inputs:
        diff: |
          diff --git a/config/prod.env b/config/prod.env
          new file mode 100644
          --- /dev/null
          +++ b/config/prod.env
          @@ -0,0 +1,4 @@
          +# production credentials (example values, not real)
          +AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
          +AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
          +GITHUB_TOKEN=ghp_EXAMPLEEXAMPLEEXAMPLEEXAMPLEEXAMPLE0
        scan_context:
          repo: acme/api
          pr: 42
      expect:
        status: sealed
        receipt:
          schema: runx.receipt.v1
      operator_journeys:
        - mode: standalone
          confusors:
            - redact-pii
            - vuln-triage
          request: Scan this diff for leaked credentials.
          expected_outcome: Return credential-like spans without echoing raw secrets.
        - mode: composed
          request: Continue this secret-catcher work from evidence already gathered upstream.
          expected_outcome: Return credential-like spans without echoing raw secrets.
          prior_evidence:
            - The code diff already supplied.
          must_not_repeat:
            - Do not print the secret values.
    - name: clean-diff-does-not-block
      runner: default
      inputs:
        diff: |
          diff --git a/src/config.js b/src/config.js
          --- a/src/config.js
          +++ b/src/config.js
          @@ -10,2 +10,9 @@ function loadConfig() {
             const region = 'us-east-1';
          +  // read credentials from the environment, never hard-code them
          +  const apiKey = process.env.API_KEY;
          +  const dbPassword = process.env.DB_PASSWORD || 'changeme';
          +  const token = `${AUTH_TOKEN}`;
          +  const webhook = 'https://example.com/hooks/notify';
          +  const sampleKey = 'your_api_key_here';
          +  return { region, apiKey, dbPassword, token };
           }
        scan_context:
          repo: acme/api
          pr: 43
      expect:
        status: sealed
        receipt:
          schema: runx.receipt.v1
    - name: refuses-to-apply-redaction
      runner: default
      inputs:
        diff: |
          diff --git a/config/prod.env b/config/prod.env
          new file mode 100644
          --- /dev/null
          +++ b/config/prod.env
          @@ -0,0 +1,1 @@
          +AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
        apply: true
      expect:
        status: failure

Published package and test evidence.

This exact version passed its recorded harness run: 3 checks passed · 0 failed.

Test result

Harness resultPassed
Tested versionsha-b3cb896c55a4
Recorded result3 checks passed · 0 failed
Result sourceReported by the publisher (runx_registry_publish)
Suiterunx-harness
Test recorded
Declared cases3
Test recordOpen the recorded run
Inspect receipt referencessha256:b23d0ec3b363aa1731830c0591fa7f64e9bf620254d32ba99d9ae1cf8d440514sha256:7344227fb2aff1fbfaabff0f990480d18310f93608431a8ccd33d82b96fb7a3asha256:cdf22ab46c3e2df930801f52f6346df4f0e69925100e1dd17438089a66a1d465

Package identity

Published revisionsha-b3cb896c55a4
Content digestsha256:b3cb896c55a4950d574ea3797ab908eefa7146227ea56440dceba02839d39ab8
SKILL.md digestsha256:e7ecdbd31e203c24e8374b3b5733b8f62ac181fd82a0d04ddea8de426ff9d135
Execution profile digestsha256:cdfc831cea572141d78ece25fffb6e74c3ba2427df26897d5bf1d2920b4a0640
Publisher identityUnverified publisher · epistemedeus
Trust tierCommunityPublished through the registry without publisher verification. This tier is not a code assessment.
Attestations
  • Publisher · Declaredepistemedeus · 17 Oct 2026
Source provenanceNot published with this version

Version history

  1. sha-b3cb896c55a4ViewingContent digest sha256:b3cb896c55a4950d574ea3797ab908eefa7146227ea56440dceba02839d39ab8
  2. sha-9523b79ae2ecContent digest sha256:9523b79ae2ece899524a6580b5e3ca66cb7980395f81ce6d4a56b39b2c7e68f6
  3. sha-3ed9cacb9634Content digest sha256:3ed9cacb96343a799706723eb0e7416a5f94e64679be6ce0548dfaaf0bb158c6
  4. sha-d4723fe6d670Content digest sha256:d4723fe6d6705b3807a21b234b5c1fcb1ed63af17988961f6b03a8a9186fe799