Skip to main content

grippo

The Python binding for grippo: secrets, credential fields and personal data found in log text and replaced with tokens, grippo's field scanners and literal sets, regex patterns, and CEL filters over raw JSON.

from datetime import UTC, datetime

from grippo import Field, LiteralSet, Scrubber

scrubber = Scrubber()  # gitleaks' rules, every layer, mask redaction
text, report = scrubber.scrub_text("login password=hunter2 from alice@example.com")
record, report = scrubber.scrub_value(
    {"user": {"password": "hunter2"}, "at": datetime.now(UTC)}
)
Field("MAC").fullmatch("00:1a:2b:3c:4d:5e")  # True
LiteralSet(["db-1", "alice"], boundary=True).find_all(
    "alice on db-1"
)  # [(0, 5, 1), (9, 13, 0)]

Scrubbing

Build one Scrubber and share it across threads.

  • scrub_text_or_none(text) gives the scrubbed text, or None when nothing changes, so a caller that only needs to know skips the copy.
  • A value runs on through a lone surrogate in scrub_text and is masked whole. Where the credential pair layer rewrites a text, each surrogate in it comes back as three U+FFFD, as errors="replace" decodes it.
  • scrub_value(value, *, default=None, max_depth=32, max_strings=64) reads any Python value the way a log record's fields are read. A dict's own keys and string values are always read. Inside a container, keys and strings past max_strings read <elided> and the rest is counted. A container max_depth deep reads <depth limit>, and one inside itself <cycle>. NaN and the infinities read by name. Anything else, such as bytes, datetime, Decimal or a set, goes through default, str when None, and one that raises reads <unprintable TYPE>. Keys are scrubbed too, and their order is kept.
  • In scrub_value, a tuple, or a two-item list inside a list, whose first item names a credential keeps the name and masks the value, as a header list holds them. An int past 64 bits reads as its decimal text. None or an empty string under a credential name is kept, as there is nothing in it.
  • Scrubber(only_rules=[...]) builds just those config rules, and refuses an id the config has no rule for. without_rules=[...] leaves rules out by id, a PII check included. skipped() lists each rule the build left out and why.
  • Scrubber(redaction="hash", hash_key=...) writes [<RULE>_<16 hex>], the first 8 bytes of HMAC-SHA256 over the secret. An empty key hashes as HMAC does with b"".
  • is_credential_name(name, parent="", *, extra=()) says whether a field name holds a credential, and mask_text(text, mask, *, extra=()) masks every credential value in a text. extra adds terms to SENSITIVE_FIELDS, a frozenset, for that call.
  • The text layer and mask_text mask a header value an HTTP client's error quotes as refused, whole and past \ escapes: Illegal header value b'Basic dXNlcg==' keeps its head and quotes and loses the value. One that never closes is masked to the end of its line.
  • mask_url_userinfo(text, mask=MASK_VALUE, *, keep_user=True) masks every URL password, and the user too with keep_user=False. MASK_VALUE is ***REDACTED***.
  • url_passwords(text) lists every URL password in a text, as written.
  • rule_token(rule) gives the stem of the token a rule writes: rule_token("credit-card") is CREDIT_CARD, written as [CREDIT_CARD_REDACTED].
  • The PII layer checks card numbers, IBANs, email addresses, phone numbers, and AU ABN, ACN, Medicare and TFN numbers.

Fields and literal sets

  • Field(name) is one of grippo's field parsers, named for the grok pattern it reads: IPV4, IPV6, MAC, UUID, HOSTNAME, EMAILADDRESS, TIMESTAMP_ISO8601, UNIXPATH and the rest in FIELD_NAMES. Each reads exactly as its regex, leftmost first, with no regex run unless a non-ASCII digit needs one.
  • fullmatch(text) says whether the field, read from the start, takes all of the text. scan(text, at=0) gives where it ends from an index, and find_all(text) the (start, end) of each match. Indices are str indices.
  • Field("IPV4", validate=True) also holds each octet to 255 or less, and PORT to 16 bits.
  • LiteralSet(literals, *, boundary=False) finds every literal in one pass. find_all(text) gives (start, end, index): leftmost first, the longest at one start, none overlapping. With boundary, a match has no ASCII letter or digit beside it, and a literal that fails that gives way to a shorter one at the same start, as (?<![A-Za-z0-9])(?:...)(?![A-Za-z0-9]) does with its alternatives longest first.

Patterns and CEL filters

from grippo import Program, Refusal, StrMatcher

StrMatcher("^web-[0-9]+$").is_match("web-12")  # True
program = Program.compile('host.startsWith("prod-") && severity > 3')
program.matches(b'{"host":"prod-1","severity":5}')  # True
program.explain()  # 'and(prefix(host, "prod-"), Gt(severity, Int(3)))'
refused = Program.compile("size(tags) > 0")
isinstance(refused, Refusal)  # True
refused.why, refused.span  # ('a function call outside the subset', (0, 4))
  • StrMatcher(pattern) reads a regex as Rust's regex does: $ matches only at the very end, never before a final newline, and lookaround or a backreference doesn't build. An empty pattern raises ValueError, since it would match everywhere. is_match(text) runs the cheapest check that gives the regex's answer, and tier names it: Byte, Literal, LiteralSet or Regex. hint says what would reach a faster one.
  • Program.compile(text, *, allow_regex=False) lowers a CEL filter to grippo's own checks over raw JSON, with cel's meaning and no interpreter. A form outside what grippo lowers, such as size(), a macro or a comparison of two fields, comes back as a Refusal, not an exception, so the caller runs its interpreter for that filter. why says what the form is and span where it sits, in str indices. matches() lowers only with allow_regex=True.
  • eval(record) takes the record as bytes or str and gives True, False, or the name of the error cel would raise: missing_root, missing_field, type_mismatch, malformed or overflow. matches(record) is True only on True.
  • explain() names each check the filter runs, one line, for a startup log or a UI that shows what the runtime does.
  • has() takes a member, has(a.b), as cel does. has(a) on a bare name is refused.

Metadata

Release files for grippo 0.1.1

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

Built distributions (wheels)

Table of built distributions (wheels) for grippo 0.1.1
File Actions
grippo-0.1.1-cp314-abi3-win_amd64.whl CPython 3.14 abi3 Windows x86-64 Details for grippo-0.1.1-cp314-abi3-win_amd64.whl
grippo-0.1.1-cp314-abi3-musllinux_1_2_x86_64.whl CPython 3.14 abi3 Linux musl 1.2+ x86-64 Details for grippo-0.1.1-cp314-abi3-musllinux_1_2_x86_64.whl
grippo-0.1.1-cp314-abi3-musllinux_1_2_aarch64.whl CPython 3.14 abi3 Linux musl 1.2+ ARM64 Details for grippo-0.1.1-cp314-abi3-musllinux_1_2_aarch64.whl
grippo-0.1.1-cp314-abi3-manylinux_2_28_x86_64.whl CPython 3.14 abi3 Linux glibc 2.28+ x86-64 Details for grippo-0.1.1-cp314-abi3-manylinux_2_28_x86_64.whl
grippo-0.1.1-cp314-abi3-manylinux_2_28_aarch64.whl CPython 3.14 abi3 Linux glibc 2.28+ ARM64 Details for grippo-0.1.1-cp314-abi3-manylinux_2_28_aarch64.whl
grippo-0.1.1-cp314-abi3-macosx_11_0_arm64.whl CPython 3.14 abi3 macOS 11.0+ ARM64 Details for grippo-0.1.1-cp314-abi3-macosx_11_0_arm64.whl

Total release size: 9.8 MB

Release files / grippo-0.1.1-cp314-abi3-win_amd64.whl

Download URL grippo-0.1.1-cp314-abi3-win_amd64.whl
Size 1.6 MB
Tags CPython 3.14 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
633c005eca57015e15ee5eb41f6450b02af3b8cee0c202d2e15fad401f2e227f
BLAKE2b-256 checksum
How to use checksums
d314184322322046d036938436b6765f85b02ac1f29d8771e0ba070a8068e156
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / grippo-0.1.1-cp314-abi3-musllinux_1_2_x86_64.whl

Download URL grippo-0.1.1-cp314-abi3-musllinux_1_2_x86_64.whl
Size 1.7 MB
Tags CPython 3.14 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
a5ca5f640ee4a06e11bca24a381248f27f4f711231d3c30999e42376ab9a4e55
BLAKE2b-256 checksum
How to use checksums
8541f3c3a6c644d523572295087f024f79b3c7d3265f28ec43eaee3d335b4110
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / grippo-0.1.1-cp314-abi3-musllinux_1_2_aarch64.whl

Download URL grippo-0.1.1-cp314-abi3-musllinux_1_2_aarch64.whl
Size 1.6 MB
Tags CPython 3.14 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
33bb2f32a4ba78ca43925eed2f55c6bfc8ea61b1a7fb210a90598da1896fefb3
BLAKE2b-256 checksum
How to use checksums
b799cc6d525ec8ff1a8b87f0fb6375b5dbe8513be54e50b7453e0def3bb84203
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / grippo-0.1.1-cp314-abi3-manylinux_2_28_x86_64.whl

Download URL grippo-0.1.1-cp314-abi3-manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags CPython 3.14 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
dab9bbc4fe8298f63e6dce29651a3b0fd2a2294f96231f092d950996016bf163
BLAKE2b-256 checksum
How to use checksums
c0a1e9452256a46cb9c87c58cb4dfcda10e3bc125eb7f6c4840f374f3626f2ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / grippo-0.1.1-cp314-abi3-manylinux_2_28_aarch64.whl

Download URL grippo-0.1.1-cp314-abi3-manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.14 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
1e8d6859a381056992c02bced28cc15cfde5333b1b7e26794d6dfa898233a141
BLAKE2b-256 checksum
How to use checksums
c783b95b70642be86b245fbf06249794018df75e6a41b791a7ddc6a20109ee18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / grippo-0.1.1-cp314-abi3-macosx_11_0_arm64.whl

Download URL grippo-0.1.1-cp314-abi3-macosx_11_0_arm64.whl
Size 1.7 MB
Tags CPython 3.14 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7257aaf5f1daeca7762032cdedf2661412189b4fdeab456c52bb5669c649f3cd
BLAKE2b-256 checksum
How to use checksums
15c3539edb54b592582701f5df50fe506238d4cf9d998bb42610636be280086a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for grippo 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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