Skip to main content

pre-commit-glassworm

CI pre-commit prek PyPI Python 3.11+ License: MIT

A pre-commit hook that detects GlassWorm‑style supply-chain attacks: invisible Unicode characters, variation selectors, Trojan Source (CVE-2021-42574), and zero-width characters that can hide malicious code from reviewers and many automated scanners.

What it catches

  • Variation Selectors (U+FE00–U+FE0F) – GlassWorm primary technique
  • Variation Selectors Supplement (U+E0100–U+E01EF)
  • Bidi control (U+202A–202E, U+2066–2069) – Trojan Source
  • Zero-width (U+200B–200F, U+2060–2064, U+180E)
  • BOM mid-file (U+FEFF) – valid at file start, flagged elsewhere
  • Replacement character (U+FFFD)
  • Other format characters (Cf category)

Installation

As a pre-commit hook

Add to .pre-commit-config.yaml:

repos:
  - repo: https://github.com/solaegis/pre-commit-glassworm
    rev: v0.1.0  # pin to tag for reproducible installs
    hooks:
      - id: glassworm

Then:

pre-commit install

Using glassworm with prek

If you prefer using prek instead of pre-commit, you can define a prek.toml file:

[[repos]]
repo = "https://github.com/solaegis/pre-commit-glassworm"
rev = "v0.1.0"  # pin to tag for reproducible installs
hooks = [{ id = "glassworm" }]

Then run prek install. Your existing .pre-commit-config.yaml also works with prek unchanged.

Standalone

uv add pre-commit-glassworm
# or: pip install pre-commit-glassworm

glassworm path/to/file.py path/to/other.js
glassworm src/                              # scan directory recursively
cat file.py | glassworm                     # read from stdin

Configuration

Optional config in pyproject.toml or .glassworm.toml:

[tool.glassworm]
severity = "error"   # "error" | "warning"
  • severity=error – exit 1 on findings (blocks commit)
  • severity=warning – exit 0, prints warning (allows commit)

CLI options

glassworm [OPTIONS] [FILES...]
Flag Description
--severity Override: error or warning
--config Path to config file
--format Output format: text (default) or json
-v, --verbose Per-file summary
-q, --quiet Summary only
--version Show version and exit

JSON output

For CI/SARIF integration:

glassworm --format json src/

Returns a JSON array of finding objects with path, line, column, codepoint, hex_repr, name, category, and unicode_category.

CI integration

pre-commit run --all-files

Commitizen and version bump

This project uses Commitizen for Conventional Commits:

pre-commit install --hook-type commit-msg

Version bump via Taskfile:

task bump          # infer from conventional commits since last tag
task bump:patch    # force patch (0.0.X)
task bump:minor    # force minor (0.X.0)
task bump:major    # force major (X.0.0)

Publishing to PyPI

# 1. Create .env with your PyPI token:
#    UV_PUBLISH_TOKEN=pypi-...

# 2. Or copy from example:
cp .env.example .env
#    Edit .env and add your token

# 3. Build and publish
task publish

.env is gitignored. task publish loads it automatically.

License

MIT – see LICENSE.

Release files for pre-commit-glassworm 0.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 pre-commit-glassworm 0.1.0
File Size Uploaded
pre_commit_glassworm-0.1.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pre-commit-glassworm 0.1.0
File Interpreter ABI Platform
pre_commit_glassworm-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / pre_commit_glassworm-0.1.0.tar.gz

Download URL pre_commit_glassworm-0.1.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4a498892bcf9e7e2371f6ce9d65113ab34f015cae9cba76c9eb7888cba525290
BLAKE2b-256 checksum
How to use checksums
cd7dd4530f9bd620aeeb8dc3e1066db168ff8202aaac4bc724bd3315032eaa0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pre_commit_glassworm-0.1.0-py3-none-any.whl

Download URL pre_commit_glassworm-0.1.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f56e394e052549e94613ee8a9e2bd0370cf257bb74cb6b715055d888f6de925c
BLAKE2b-256 checksum
How to use checksums
596d69d2121347dd658e1e1007c57c15d331ff4260c2f0a95b23bb98a7607a5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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