Skip to main content

SherlockScan

CI PyPI

SherlockScan is a beta static risk scanner for Python packages and source trees. SherlockScan can inspect notebooks, compare package releases, and generate offline HTML reports.

A finding indicates potential risk; it does not prove maliciousness. A clean scan does not prove safety.

Install and run

Python 3.9 or newer is required. For the released version, use pip install sherlockscan. To try the latest checkout from source:

git clone https://github.com/itsual/sherlockscan.git
cd sherlockscan
python -m pip install -e ".[dev]"
sherlockscan version
sherlockscan scan ./your-project --format json --output report.json
sherlockscan scan ./package.whl --format sarif --output results.sarif
sherlockscan scan requests==2.32.3 --format md
sherlockscan scan ./training.ipynb --format html --output report.html
sherlockscan diff ./old.whl ./new.whl --output changes.json

PyPI retrieval chooses a non-yanked wheel compatible with the running interpreter, or a source archive when no compatible wheel exists. It scans one exact artifact, not every wheel, platform or dependency. The report records its filename and SHA-256. Artifact hashes from PyPI detect mismatches; they do not establish publisher trust. Use --artifact-filename with a pinned name==version target to select an exact non-yanked PyPI file, including artifacts for a different platform.

Features

  • Reads ZIP/wheel and TAR source archives without extracting or executing target code.
  • Downloads artifact bytes directly from PyPI, without pip or target build hooks.
  • Reads declared dependencies from METADATA, PKG-INFO or static PEP 621 project metadata.
  • Inspects Python AST calls, common import aliases, loader arguments and execution context.
  • Recognizes startup-executing .pth lines and identifies unanalyzed native code.
  • Scans source and up to two layers of bounded base64/hex/zlib literal decoding.
  • Explains each finding's trigger, legitimate uses and suggested investigation.
  • Produces Markdown, JSON, SARIF 2.1.0 and a declared-dependency CycloneDX SBOM.
  • Supports scoped suppressions and opt-in CI severity thresholds.
  • Scans Python notebook code cells and reports their cell-relative locations.
  • Compares two artifacts and reports changes in findings, declarations, and coverage.
  • Provides an offline HTML report and optional dependency name similarity hints.

Importing networking or serialization libraries is informational. Co-occurring environment access and networking is a review hint; no data flow or attack is proven. torch.load checks distinguish explicit unsafe arguments, unknown arguments and statically constrained PyTorch >=2.6 defaults. Static alias resolution is limited; reflection, monkey patching, complex control flow and full interprocedural data flow are outside scope. Severity describes potential impact; confidence describes the evidence supporting a flag, not a probability that the package is malicious.

CLI and CI behavior

sherlockscan scan ./package.whl --fail-on HIGH --severity MEDIUM \
  --suppressions ./reviewed-suppressions.yaml --format json --output report.json \
  --sbom dependencies.cdx.json

--severity filters displayed details only. Policy evaluates all unsuppressed findings. Reports retain detected totals, actionable totals, suppression reasons and coverage gaps. --include-tests includes tests, docs and examples, which are excluded and listed by default. --no-deobfuscation disables decoding and explicitly marks that coverage incomplete. Use --config DIRECTORY for trusted custom risk_patterns.yaml and optional approved_packages.yaml. Existing v0.2 regex/keyword YAML remains supported. Rules may supply an uppercase id; otherwise a deterministic content-derived ID is used. Custom patterns are trusted configuration, not sandboxed code or regexes.

Use --check-dependency-names for low-confidence, one-edit similarity hints based on the bundled ML watchlist. Notebook Markdown, outputs, and attachments are excluded. Line directives such as %run are flagged where applicable. The body of a cell magic and explicitly non-Python notebooks are reported as incomplete.

sherlockscan diff accepts two local artifacts or explicitly pinned PyPI releases of the same project. It compares the visible static findings and dependency declarations. Repeated findings are counted separately. For hidden or redacted evidence, different underlying values can produce the same comparison key. Review both artifacts when a comparison returns incomplete coverage. See CI and pre-commit setup.

Exit Meaning
0 Supported checks completed and the configured threshold was not exceeded. No safety guarantee.
10 Unsuppressed findings exceeded --fail-on.
20 Incomplete coverage: unknown/dynamic metadata, invalid Python, native code or exhausted limits.
30 Scanner/input/configuration/download/output error; no successful scan verdict.
2 Invalid command-line usage.

Incomplete coverage takes precedence over a policy failure; findings remain in the report. By default findings alone do not fail a completed scan. CI users should set an appropriate --fail-on threshold and treat every nonzero exit as requiring review.

Suppressions are only loaded when explicitly supplied by the operator. See suppression instructions and rule guidance. Report false positives using the repository issue form after removing credentials and proprietary source.

Library API

from sherlockscan.engine import scan_package
from sherlockscan.reporting import render

report = scan_package("./package.whl", fail_on="HIGH")
print(report["status"], report["artifact"], report["coverage"])
print(render(report, "json"))

Schema 0.3 retains common v0.2 fields, but adds stable rule IDs, fingerprints, confidence, suppression state, policy status, artifact identity and coverage. CLI error/incomplete exit codes have changed intentionally. Legacy low-level scanner functions remain available for compatibility; engine.scan_package is the supported complete v0.3 pipeline. The legacy utils.resolve_package_target also uses static ingestion; callers must delete its returned temporary directory when finished.

Limits and review scope

Defaults: compressed artifact 100 MiB, expanded total 250 MiB, each member 25 MiB, 5,000 entries, ZIP ratio 1,000:1, per-source parsing 2 MiB, and a 60-second cooperative ingestion budget. Decoding uses two transforms and a cumulative 64 KiB budget per literal. Symlinks, devices, duplicate/case-colliding paths, encrypted ZIP entries and traversal paths are rejected. Python parsing and regex processing are not an OS-level sandbox; run investigations of hostile artifacts in an isolated environment.

Static metadata can be missing or incomplete. Optional extras and environment markers are preserved and inspected as declarations, not resolved for a chosen runtime. Dependencies are not recursively audited, SBOM dependency versions are not inferred from the scanner host, and native/compiled code is not analyzed. No automatic installation, package blocking based on co-occurrence, age-based quarantine, attestation enforcement or typosquatting verdicts are provided.

Develop and release review

python -m pytest
python -m ruff check sherlockscan tests integration
python -m build
python -m twine check dist/*

See the release review checklist, changelog, security policy, and development roadmap. The manual publishing workflow requires an explicit release-review confirmation. Pushing to main does not publish a package.

Metadata

Release files for sherlockscan 0.4.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 sherlockscan 0.4.0
File Size Uploaded Provenance Actions
sherlockscan-0.4.0.tar.gz 66.1 kB With provenance Details for sherlockscan-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sherlockscan 0.4.0
File Interpreter ABI Platform Actions
sherlockscan-0.4.0-py3-none-any.whl Python 3 none any Details for sherlockscan-0.4.0-py3-none-any.whl

Total release size: 133.6 kB

Release files / sherlockscan-0.4.0.tar.gz

Download URL sherlockscan-0.4.0.tar.gz
Size 66.1 kB
Tags Source
SHA-256 checksum
How to use checksums
46505e4cf9ec29215b6a380b217d9a15bc2e745948af0258071de46d8fcb895e
BLAKE2b-256 checksum
How to use checksums
5e33f22bf008740db3636e524a0ea9f9a63883399a75285a953e47513f747317
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Release files / sherlockscan-0.4.0-py3-none-any.whl

Download URL sherlockscan-0.4.0-py3-none-any.whl
Size 67.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
281dc4fa21c25bfacb68342b01ffd7561b181e7921ce7ff5de3c8d1ea8e8ecb9
BLAKE2b-256 checksum
How to use checksums
0411d6aa5ec43342b1d64f4f0825a3920b8e4f8dc05a4dcfdac2e203934e96f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 24, 2026.

Transparency log

Security for sherlockscan 0.4.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sherlockscan-0.4.0.tar.gz

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 Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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