Skip to main content

Kingfisher Secret Scanner for Python

Fast secret detection, credential validation and revocation for Python, powered by Kingfisher's Rust libraries. Native, in-process execution; no CLI subprocess required. Requires CPython 3.10+.

Install

uv add kingfisher-secret-scanner

The PyPI distribution is kingfisher-secret-scanner; the Python import is kingfisher_sdk. It coexists with the separately distributed kingfisher-bin CLI.

Scan offline

from kingfisher_sdk import Scanner

scanner = Scanner()  # Compile the bundled rules once and reuse the scanner.
for finding in scanner.scan_file("application.conf"):
    if finding.visible:
        print(finding.to_dict())  # Secrets and captures are redacted by default.

Inspect rules, regexes and configured actions

import json
from kingfisher_sdk import Rules

rules = Rules(confidence="low")  # Include the complete bundled catalog.
print([r["id"] for r in rules.metadata() if r["revocation"]])
detail = rules.detail("betterleaks.aws-access-token")  # Exact loaded rule ID.
print(detail["pattern"])
print(detail["detection_regex"])  # Compiled confirmation regex, comments removed.
print(json.dumps(detail["validation"], indent=2))
print(json.dumps(detail["revocation"], indent=2))

detail() also includes entropy, path/candidate filters, capture selection, dependencies, examples and references. It returns a copy; edits do not change scanning. Absent actions are None. HTTP/gRPC configurations show requests and matchers; Betterleaks logic is a serialized expression tree. Typed/raw handlers identify Rust implementations rather than exposing their source code. Inspection makes no provider requests and does not execute revocation. Custom rule literals are returned as configured.

The rule example supports catalog capability filters and detailed field selection:

uv run --no-sync python python/examples/rules.py --with-revocation
uv run --no-sync python python/examples/rules.py betterleaks.aws-access-token --field pattern --field validation --field revocation

Filter findings and choose inputs

Use Rules(confidence="high") to load only high-confidence rules, or Rules(["company.yml"], builtins=False) for a custom-only YAML/TOML catalog. Scanner(base64=False) disables Base64 detection. Leave native entropy thresholds at their defaults unless you intend to override every rule's threshold.

For report filtering, serialize once and inspect the redacted fields:

from fnmatch import fnmatchcase
from kingfisher_sdk import Scanner

findings = Scanner().scan_file("application.conf")
for finding in findings:
    data = finding.to_dict()
    if finding.visible and fnmatchcase(data["rule_id"], "betterleaks.*"):
        if data["entropy"] >= 3.5:
            print(data)

You can also filter confidence (low/medium/high), Base64 status, line/byte location, capture-name presence, fingerprint or blob ID. Keep paths alongside findings for path filters; Finding does not contain a filename. After validation, filter result.outcome, result.http_status or result.reason. Retain invisible helper findings until validation finishes. Report filters do not reduce detection work or validation requests.

The scan example supports directories, repeated --rules-path, --confidence, --exclude, --rule, --min-entropy, --base64-only, --no-base64, --unique, per-file --timeout, and Ctrl-C cancellation. Its entropy option filters output, while Scanner(min_entropy=...) overrides detector thresholds. --unique deduplicates reports by rule and credential value using per-run keyed digests internally; SDK dedup=True instead skips repeat successful scans of identical content at the same path.

uv run --no-sync python python/examples/scan.py ~/mms --timeout 5 --unique --exclude '*.min.js'
uv run --no-sync python python/examples/scan.py application.conf --rule 'betterleaks.*' --min-entropy 3.5
uv run --no-sync python python/examples/validate.py application.conf --outcome verified_active --concurrency 4

The directory example skips .git, .venv, node_modules and symlink entries; its path globs are not .gitignore syntax. The SDK does not enumerate Git history or archives, apply CLI inline-ignore/HTML/CSS context checks, or automatically validate findings. These differences, plus CLI deduplication, can change results compared with kingfisher scan. See the filtering and CLI comparison guide.

Scan timeouts and cancellation

from kingfisher_sdk import CancellationToken, Scanner

scanner = Scanner()
cancellation = CancellationToken()
findings = scanner.scan("text to inspect", timeout=2.0, cancellation=cancellation)
# Another thread can call cancellation.cancel() while scanning runs.

scan_file accepts the same keyword arguments. Timeout values must be finite, positive seconds; omit timeout for unlimited execution. An interrupted scan raises TimeoutError for an expired deadline or RuntimeError for cancellation, without partial findings or a dedup-cache entry. Tokens remain cancelled; create a new token for new work.

These controls are cooperative. Checks run between matching/filtering operations, in native match callbacks and during Base64 enumeration. File reads, decoding, rule compilation and individual native operations cannot be preempted. Python releases the GIL during scanning, allowing another thread to signal cancellation. Use a separate process when a hard wall-clock execution limit is required.

Validate explicitly

from kingfisher_sdk import Scanner, Validator

findings = Scanner().scan_file("application.conf")
for result in Validator(timeout=10, concurrency=4).validate(findings):
    if result.finding.visible:
        print(result.to_dict())

Scanning is offline. Validation may contact providers using detected credentials. Keep the complete scan result, including invisible supporting findings, until validation finishes. Report redacted results; do not log finding.secret.

Revocation is available through Revoker.revoke() and requires confirm=True. It can disable or delete real credentials. The local lifecycle example demonstrates detection, validation and revocation against a loopback mock with a synthetic credential. Blocking SDK operations release the GIL; use asyncio.to_thread in async applications.

Documentation and examples

For a source checkout, build and run the local example from the repository root:

uv sync --locked --no-install-project
uv run --no-sync maturin develop --locked --profile dev
uv run --no-sync python python/examples/local_workflow.py

For a downloaded example and a published package, use:

uv run --no-project --with kingfisher-secret-scanner python local_workflow.py

Download demo.yml beside local_workflow.py; the example loads that synthetic rule by its location. Source archives include the examples and fixture together.

Metadata

Release files for kingfisher-secret-scanner 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kingfisher-secret-scanner 1.1.0
File Size Uploaded
kingfisher_secret_scanner-1.1.0.tar.gz 1.3 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for kingfisher-secret-scanner 1.1.0
File
kingfisher_secret_scanner-1.1.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
kingfisher_secret_scanner-1.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
kingfisher_secret_scanner-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details
kingfisher_secret_scanner-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details
kingfisher_secret_scanner-1.1.0-cp310-abi3-macosx_11_0_x86_64.whl CPython 3.10 abi3 macOS 11.0+ x86-64 Details
kingfisher_secret_scanner-1.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details

Total release size: 75.7 MB

Release files / kingfisher_secret_scanner-1.1.0.tar.gz

Download URL kingfisher_secret_scanner-1.1.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
e64ba3a1a45d375b1a9890cea4e8ae9e1f3daf329ff52fc8dbbdd46646b06483
BLAKE2b-256 checksum
How to use checksums
6fbe68b5f83fe1dc5f5191b243c5e5e2a81c27503097fd12b368bd322b68ef2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / kingfisher_secret_scanner-1.1.0-cp310-abi3-win_arm64.whl

Download URL kingfisher_secret_scanner-1.1.0-cp310-abi3-win_arm64.whl
Size 10.1 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
d303a39ec10c43ac5d4c1d8962dc97bbfa3d489df1fbacec21d2110c760f56a7
BLAKE2b-256 checksum
How to use checksums
4086b759e614bc4ffebef72564b2968a6e4676b73270797ac7ac70e1bfbf0e52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / kingfisher_secret_scanner-1.1.0-cp310-abi3-win_amd64.whl

Download URL kingfisher_secret_scanner-1.1.0-cp310-abi3-win_amd64.whl
Size 21.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
dab6acfcf0867b80471c8a82d7906502734e04b6da32d3716d56181d1bc67e6f
BLAKE2b-256 checksum
How to use checksums
bcce96e2b97ece5ad1fdcb0bd7daf7c4099dcc923c6c46005e931ff7d9c1b30c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / kingfisher_secret_scanner-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL kingfisher_secret_scanner-1.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Size 11.2 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
d8d4a35be1c18654ddadd5caaed0bac06909b1cdd950022e95f4deb3d9733219
BLAKE2b-256 checksum
How to use checksums
057d8c44c931046b9775873a3bb20856e96cf91cf1a7a73c5161e5e8740d70ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / kingfisher_secret_scanner-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL kingfisher_secret_scanner-1.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 10.8 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
7ae94a944cdcd7c1b9ff641a20b029eee7d90cf5934dbd54322130c4c9cbc5b4
BLAKE2b-256 checksum
How to use checksums
7603b8892bedde0112714ee4147dd79ddd804a283dab8f9f0366b2bd2bae760a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / kingfisher_secret_scanner-1.1.0-cp310-abi3-macosx_11_0_x86_64.whl

Download URL kingfisher_secret_scanner-1.1.0-cp310-abi3-macosx_11_0_x86_64.whl
Size 10.7 MB
Tags CPython 3.10 abi3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
dafbbec8a4444cabcf60b2136657abe2a1d7a12fe32a04b1d23354d696caa851
BLAKE2b-256 checksum
How to use checksums
baf7bfddcb1b89d91a6c32d6a86fbe13a106161ade2abf81af21a4baf3ec3b94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release files / kingfisher_secret_scanner-1.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL kingfisher_secret_scanner-1.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 10.5 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
defbec2136531cf94bcffd6788263e800978815e680b31c7a455cc2012fd63f4
BLAKE2b-256 checksum
How to use checksums
ca7e2267d72d194b5627f8f9ef881b6cf9e9877627cd6c771749e5155dd5b004
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.

Transparency log

Release history Release notifications | RSS feed

1.4.0

7 release files

1.3.0

7 release files

This release

1.1.0 This release

7 release files

1.0.1

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page