Skip to content

Secret scanning

Find leaked API keys, tokens and private keys in text from SQL, offline and with redacted output

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/secretscan/index.md to help me query Secret scanning with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find and identify exposed secrets in text

Uses deliberately fake keys to demonstrate detection and redaction.

Example output · captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT f.rule_id, f.match_redacted, f.start_offset, d.provider, d.category
FROM secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f
LEFT JOIN secretscan.main.secret_detectors AS d USING (rule_id)
ORDER BY f.start_offset;
Result
rule_id match_redacted start_offset provider category
aws-access-token AKIA********4Q2T 18 AWS Cloud Keys
slack-bot-token xoxb********UvWx 51 Slack Chat Tokens
npm-access-token npm_********8eRt 116 NULL NULL

Quick start

Choose where to run Secret scanning, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the release directly

Downloads the latest release for your platform and caches it locally.

ATTACH 'secretscan' AS secretscan (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/vgi-secretscan'
);

3. Run a query

query.sql
SELECT f.rule_id, f.match_redacted, f.start_offset, d.provider, d.category
FROM secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f
LEFT JOIN secretscan.main.secret_detectors AS d USING (rule_id)
ORDER BY f.start_offset;
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the release directly

Uses the verified release each time you attach the connector.

ATTACH 'secretscan' AS secretscan (
  TYPE vgi,
  LOCATION 'github-auto://Query-farm/[email protected]'
);

Overview

Scan text/code for leaked secrets (gitleaks ruleset + entropy); redacted output, no verification

Catalog

Everything secretscan exposes once attached — read straight from the worker's released build.

secretscan 1 schema
main 1 view · 2 functions

Offline secret-detection functions (gitleaks ruleset + entropy); redacted output, no verification.

Schema examples (6)
Examples (6)

Predicate: does this string hold any detectable secret? (Returns TRUE for the AWS-style key.)

SELECT secretscan.main.secret_contains('aws_secret = AKIAZ3MZ7EXAMPLE4Q2T') AS leaked;

Enumerate each finding with its rule, redacted match, and confidence.

SELECT rule_id, match_redacted, confidence
FROM secretscan.main.secret_scan('aws_secret = AKIAZ3MZ7EXAMPLE4Q2T');

Browse the detector registry, highest-confidence first.

SELECT rule_id, provider, confidence
FROM secretscan.main.secret_detectors
ORDER BY confidence DESC, rule_id;

Enrich each finding in a .env-style string with its provider and category from the secret_detectors registry: AWS / Cloud Keys and Slack / Chat Tokens; the npm token's rule (npm-access-token) is outside the curated registry, so its provider and category are NULL.

SELECT f.rule_id, f.match_redacted, f.start_offset, d.provider, d.category
FROM secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f
LEFT JOIN secretscan.main.secret_detectors AS d USING (rule_id)
ORDER BY f.start_offset;
Result
rule_id match_redacted start_offset provider category
aws-access-token AKIA********4Q2T 18 AWS Cloud Keys
slack-bot-token xoxb********UvWx 51 Slack Chat Tokens
npm-access-token npm_********8eRt 116 NULL NULL
2 more examples

Confirm the redacted output is safe to log: re-check every finding's match_redacted with secret_contains (3 findings; leaks_after_redaction is FALSE, so no redacted match still trips a detector).

SELECT count(*) AS findings,
  bool_or(secretscan.main.secret_contains(f.match_redacted)) AS leaks_after_redaction
FROM secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f;

Coverage check: for each high-confidence (>= 0.9) detector in the registry, report whether it fired on a .env-style string (aws-access-token and slack-bot-token are TRUE; the other eight are FALSE).

SELECT d.rule_id, d.provider, count(f.rule_id) > 0 AS detected
FROM secretscan.main.secret_detectors AS d
LEFT JOIN secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f USING (rule_id)
WHERE d.confidence >= 0.9
GROUP BY d.rule_id, d.provider
ORDER BY detected DESC, d.rule_id;
Views
secret_detectors 4 examples5 cols

Curated registry of the notable gitleaks detector rules this worker flags (rule_id, provider, category, confidence, description) — browse it to see the detection surface before scanning with secret_contains / secret_scan.

Columns
rule_id VARCHAR
The gitleaks rule id this worker reports for the detector (matches secret_scan.rule_id).
provider VARCHAR
The provider or credential family the detector covers (AWS, GitHub, Slack, ...).
category VARCHAR
Broad grouping: Cloud Keys, VCS Tokens, Chat Tokens, Payment Keys, Private Keys, Tokens, or Entropy.
confidence DOUBLE
The heuristic confidence in [0,1] this worker assigns a match of this rule; structural rules score 0.95, generic/entropy rules scale with entropy.
description VARCHAR
One-line description of what the detector matches.
Examples (4)

Browse every detector this worker recognises, highest-confidence first.

SELECT rule_id, provider, category, confidence
FROM secretscan.main.secret_detectors
ORDER BY confidence DESC, rule_id;

List only the high-confidence structural detectors (confidence >= 0.9).

SELECT rule_id, provider
FROM secretscan.main.secret_detectors
WHERE confidence >= 0.9
ORDER BY rule_id;

Count the recognised detectors grouped by the provider family they cover.

SELECT category, count(*) AS detectors
FROM secretscan.main.secret_detectors
GROUP BY category
ORDER BY detectors DESC, category;
1 more example

Coverage check: for each high-confidence (>= 0.9) detector in the registry, report whether it fired on a .env-style string (aws-access-token and slack-bot-token are TRUE; the other eight are FALSE).

SELECT d.rule_id, d.provider, count(f.rule_id) > 0 AS detected
FROM secretscan.main.secret_detectors AS d
LEFT JOIN secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f USING (rule_id)
WHERE d.confidence >= 0.9
GROUP BY d.rule_id, d.provider
ORDER BY detected DESC, d.rule_id;
Link
Scalar functions
secret_contains (text VARCHAR) 3 examples

Report whether a text/code value contains at least one detectable leaked secret (gitleaks ruleset + entropy). Offline; no verification.

Arguments
text VARCHAR
Text or source code to scan
ReturnsBOOLEAN
Examples (3)

Check whether a single string holds any detectable secret (returns TRUE here for the AWS-style key).

SELECT secretscan.main.secret_contains('aws_secret = AKIAZ3MZ7EXAMPLE4Q2T') AS leaked;

Check a benign string with no secret (returns FALSE).

SELECT secretscan.main.secret_contains('just a harmless note, nothing to see here') AS leaked;
SELECT secretscan.main.secret_contains('the quick brown fox jumps over the lazy dog') AS leaked;
Link
Table functions
secret_scan (text VARCHAR) 4 examples

Scan text/code for leaked secrets; emit one row per finding (rule_id, description, match_redacted, start_offset, entropy, confidence). Redacted output only; no verification.

Arguments
text VARCHAR
The text or source code to scan for leaked secrets; passed as a constant literal
Returns columns
rule_id VARCHAR
Identifier of the gitleaks rule that matched (e.g. aws-access-token, private-key, generic-api-key).
description VARCHAR
Human-readable description of the matched gitleaks rule.
match_redacted VARCHAR
The matched text with the secret substring masked to a fixed-width placeholder — the raw credential is never returned.
start_offset INTEGER
Zero-based byte offset of the match within the input text.
entropy DOUBLE
Shannon entropy of the detected secret (the gitleaks value, or a computed fallback when the matched rule has no entropy threshold); typically ranges from about 2.5 to 6.0 bits.
confidence DOUBLE
Heuristic confidence score in [0,1]: structurally distinctive rules (AWS/GCP/GitHub/private-key/JWT) score high (0.95); other named rules 0.85; generic/entropy rules 0.30–0.75 scaled by entropy.
Examples (4)

List each secret found in a string, with its rule, redacted match, and confidence.

SELECT rule_id, match_redacted, confidence
FROM secretscan.main.secret_scan('aws_secret = AKIAZ3MZ7EXAMPLE4Q2T');

List only the high-confidence findings (confidence >= 0.9) in a string, with each finding's byte offset.

SELECT rule_id, start_offset
FROM secretscan.main.secret_scan('aws_secret = AKIAZ3MZ7EXAMPLE4Q2T')
WHERE confidence >= 0.9;

Enrich each finding in a .env-style string with its provider and category from the secret_detectors registry: AWS / Cloud Keys and Slack / Chat Tokens; the npm token's rule (npm-access-token) is outside the curated registry, so its provider and category are NULL.

SELECT f.rule_id, f.match_redacted, f.start_offset, d.provider, d.category
FROM secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f
LEFT JOIN secretscan.main.secret_detectors AS d USING (rule_id)
ORDER BY f.start_offset;
Result
rule_id match_redacted start_offset provider category
aws-access-token AKIA********4Q2T 18 AWS Cloud Keys
slack-bot-token xoxb********UvWx 51 Slack Chat Tokens
npm-access-token npm_********8eRt 116 NULL NULL
1 more example

Confirm the redacted output is safe to log: re-check every finding's match_redacted with secret_contains (3 findings; leaks_after_redaction is FALSE, so no redacted match still trips a detector).

SELECT count(*) AS findings,
  bool_or(secretscan.main.secret_contains(f.match_redacted)) AS leaks_after_redaction
FROM secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f;
Link

Try these queries

Predicate: does this string hold any detectable secret? (Returns TRUE for the AWS-style key.)

SELECT secretscan.main.secret_contains('aws_secret = AKIAZ3MZ7EXAMPLE4Q2T') AS leaked;

Uses secret_contains

Enumerate each finding with its rule, redacted match, and confidence.

SELECT rule_id, match_redacted, confidence
FROM secretscan.main.secret_scan('aws_secret = AKIAZ3MZ7EXAMPLE4Q2T');

Uses secret_scan

Browse the detector registry, highest-confidence first.

SELECT rule_id, provider, confidence
FROM secretscan.main.secret_detectors
ORDER BY confidence DESC, rule_id;

Uses secret_detectors

Confirm the redacted output is safe to log: re-check every finding's match_redacted with secret_contains (3 findings; leaks_after_redaction is FALSE, so no redacted match still trips a detector).

SELECT count(*) AS findings,
  bool_or(secretscan.main.secret_contains(f.match_redacted)) AS leaks_after_redaction
FROM secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f;

Uses secret_containssecret_scan

Coverage check: for each high-confidence (>= 0.9) detector in the registry, report whether it fired on a .env-style string (aws-access-token and slack-bot-token are TRUE; the other eight are FALSE).

SELECT d.rule_id, d.provider, count(f.rule_id) > 0 AS detected
FROM secretscan.main.secret_detectors AS d
LEFT JOIN secretscan.main.secret_scan('AWS_ACCESS_KEY_ID=AKIAZ3MZ7EXAMPLE4Q2T SLACK_TOKEN=xoxb-1234567890-1234567890123-AbCdEfGhIjKlMnOpQrStUvWx NPM_TOKEN=npm_Zq8xK2vN7rT4mW9pL3sY6bH1cJ5dF0gA8eRt') AS f USING (rule_id)
WHERE d.confidence >= 0.9
GROUP BY d.rule_id, d.provider
ORDER BY detected DESC, d.rule_id;

Uses secret_detectorssecret_scan

Browse every detector this worker recognises, highest-confidence first.

SELECT rule_id, provider, category, confidence
FROM secretscan.main.secret_detectors
ORDER BY confidence DESC, rule_id;

Uses secret_detectors

5 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Does the following text contain any leaked secret? Answer with a single boolean. Text: deploy AKIAZ3MZ7EXAMPLE4Q2T now
  • Does the following benign sentence contain any leaked secret? Answer with a single boolean. Text: the quick brown fox jumps over the lazy dog
  • Scan the following text for leaked secrets and tell me how many findings it produces. Text: deploy AKIAZ3MZ7EXAMPLE4Q2T now
  • Scan the following text for leaked secrets and report, for each finding, the matched rule id and the redacted match. Text: deploy AKIAZ3MZ7EXAMPLE4Q2T now
  • Using the scanner's browsable detector registry, how many distinct secret detectors does it recognise in total?
  • Does the scanner's detector registry include any high-confidence (>= 0.9) detector for AWS? Answer with a single boolean.

Secret scanning is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.