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-d4723fe6d670. Go to the current version
Overview
In the manual
Runner
default
Declared by its execution profile. Read the profile
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
- Read the
diffinput (ordiff_pathfor a diff stored inside the skill directory) and record its byte length and SHA-256. - Walk the unified diff, tracking the current file and the new-file line number
from each
+++header and@@hunk header. - On each added line, run every detector and record a finding with its type,
{ file, line, column }location, a redacted preview, and a fingerprint. - Exclude placeholders, template interpolations, and environment-variable references so ordinary configuration does not false-block.
- Build a gated
redaction_proposalfor theredact-piiexecutor when any finding exists. - Set
blockto true when there is at least one finding. - Verify no raw secret value appears anywhere in the output; fail closed if it would.
- Emit
secret.catcher.result.v1and, whenoutput_diris set, writeevidence.jsonandreport.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:
{
"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:
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"' \
--jsonExpected result shape:
blockis true.findings[0].typeisaws_access_key_idand its location points at the added line and column.findings[0].redacted_previewmasks the value andfindings[0].fingerprintis a truncated SHA-256; the raw key never appears.redaction_proposal.performed_byisredact-piiandrequires_approvalis 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 forevidence.jsonandreport.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 theredact-piiexecutor.
Published execution profile
The execution profile published with sha-d4723fe6d670, shown as its exact bytes.
| Runner |
|
|---|---|
| Profile digest | sha256:636c2b2cb02e1b8ca7f3da0c128fed7ee3b389b19b492c844d7c91ae0985552d |
skill: secret-catcher
version: 0.1.0
catalog:
kind: skill
audience: public
visibility: public
role: canonical
tags:
- security
- secrets
- diff
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.
The latest recorded test covers an earlier version, sha-b3cb896c55a4. It does not establish a result for this version.
Test result
| Harness result | An earlier version was tested |
|---|---|
| Tested version | sha-b3cb896c55a4Not this page’s version, sha-d4723fe6d670 |
| Recorded result | 3 checks passed · 0 failed |
| Result source | Reported by the publisher (runx_registry_publish) |
| Suite | runx-harness |
| Test recorded | |
| Declared cases | 3 |
Package identity
| Published revision | sha-d4723fe6d670 |
|---|---|
| Content digest | sha256:d4723fe6d6705b3807a21b234b5c1fcb1ed63af17988961f6b03a8a9186fe799 |
| SKILL.md digest | sha256:e7ecdbd31e203c24e8374b3b5733b8f62ac181fd82a0d04ddea8de426ff9d135 |
| Execution profile digest | sha256:636c2b2cb02e1b8ca7f3da0c128fed7ee3b389b19b492c844d7c91ae0985552d |
| Publisher identity | Unverified publisher · epistemedeus |
| Trust tier | CommunityPublished through the registry without publisher verification. This tier is not a code assessment. |
| Attestations |
|
| Source provenance | Not published with this version |
Version history
sha-b3cb896c55a4Content digest sha256:b3cb896c55a4950d574ea3797ab908eefa7146227ea56440dceba02839d39ab8sha-9523b79ae2ecContent digest sha256:9523b79ae2ece899524a6580b5e3ca66cb7980395f81ce6d4a56b39b2c7e68f6sha-3ed9cacb9634Content digest sha256:3ed9cacb96343a799706723eb0e7416a5f94e64679be6ce0548dfaaf0bb158c6sha-d4723fe6d670ViewingContent digest sha256:d4723fe6d6705b3807a21b234b5c1fcb1ed63af17988961f6b03a8a9186fe799