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, orNonewhen nothing changes, so a caller that only needs to know skips the copy.- A value runs on through a lone surrogate in
scrub_textand is masked whole. Where the credential pair layer rewrites a text, each surrogate in it comes back as three U+FFFD, aserrors="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 pastmax_stringsread<elided>and the rest is counted. A containermax_depthdeep reads<depth limit>, and one inside itself<cycle>. NaN and the infinities read by name. Anything else, such asbytes,datetime,Decimalor aset, goes throughdefault,strwhenNone, 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.Noneor 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 withb"".is_credential_name(name, parent="", *, extra=())says whether a field name holds a credential, andmask_text(text, mask, *, extra=())masks every credential value in a text.extraadds terms toSENSITIVE_FIELDS, afrozenset, for that call.- The text layer and
mask_textmask 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 withkeep_user=False.MASK_VALUEis***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")isCREDIT_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,UNIXPATHand the rest inFIELD_NAMES. Each reads exactly as itsregex, 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, andfind_all(text)the(start, end)of each match. Indices arestrindices.Field("IPV4", validate=True)also holds each octet to 255 or less, andPORTto 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. Withboundary, 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 raisesValueError, since it would match everywhere.is_match(text)runs the cheapest check that gives the regex's answer, andtiernames it:Byte,Literal,LiteralSetorRegex.hintsays 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 assize(), a macro or a comparison of two fields, comes back as aRefusal, not an exception, so the caller runs its interpreter for that filter.whysays what the form is andspanwhere it sits, instrindices.matches()lowers only withallow_regex=True.eval(record)takes the record asbytesorstrand givesTrue,False, or the name of the error cel would raise:missing_root,missing_field,type_mismatch,malformedoroverflow.matches(record)isTrueonly onTrue.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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| grippo-0.1.0-cp314-abi3-win_amd64.whl | CPython 3.14 | abi3 | Windows x86-64 | Details for grippo-0.1.0-cp314-abi3-win_amd64.whl |
| grippo-0.1.0-cp314-abi3-musllinux_1_2_x86_64.whl | CPython 3.14 | abi3 | Linux musl 1.2+ x86-64 | Details for grippo-0.1.0-cp314-abi3-musllinux_1_2_x86_64.whl |
| grippo-0.1.0-cp314-abi3-musllinux_1_2_aarch64.whl | CPython 3.14 | abi3 | Linux musl 1.2+ ARM64 | Details for grippo-0.1.0-cp314-abi3-musllinux_1_2_aarch64.whl |
| grippo-0.1.0-cp314-abi3-manylinux_2_28_x86_64.whl | CPython 3.14 | abi3 | Linux glibc 2.28+ x86-64 | Details for grippo-0.1.0-cp314-abi3-manylinux_2_28_x86_64.whl |
| grippo-0.1.0-cp314-abi3-manylinux_2_28_aarch64.whl | CPython 3.14 | abi3 | Linux glibc 2.28+ ARM64 | Details for grippo-0.1.0-cp314-abi3-manylinux_2_28_aarch64.whl |
| grippo-0.1.0-cp314-abi3-macosx_11_0_arm64.whl | CPython 3.14 | abi3 | macOS 11.0+ ARM64 | Details for grippo-0.1.0-cp314-abi3-macosx_11_0_arm64.whl |
Total release size: 9.8 MB
Release files / grippo-0.1.0-cp314-abi3-win_amd64.whl
| Download URL | grippo-0.1.0-cp314-abi3-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.14 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7b643d2d060cf6c70e8f9ae7b0612b6aee8851a849b19be750b660081025efc3
|
|
BLAKE2b-256 checksum How to use checksums |
3981e633e54b1ae398bf296db682536282929bb6979d57b4ac00b34fd8d7d0b6
|
| 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.0-cp314-abi3-musllinux_1_2_x86_64.whl
| Download URL | grippo-0.1.0-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 |
368e8b02554f00db057b3427d38b31810843effe331a5f2efb89b5eeacc15909
|
|
BLAKE2b-256 checksum How to use checksums |
408e16ab0648214b8b106733e6ebfb929a472d7f4eb52b098beb3301840d6613
|
| 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.0-cp314-abi3-musllinux_1_2_aarch64.whl
| Download URL | grippo-0.1.0-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 |
68cf275186fa7eec6f7187eefc80145a51b512de159068647b86cc946474f89e
|
|
BLAKE2b-256 checksum How to use checksums |
7e1efa21982386cf82b3c70577fc0b0ce54e1e36a4abf1d22b2afe9df7f41cfa
|
| 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.0-cp314-abi3-manylinux_2_28_x86_64.whl
| Download URL | grippo-0.1.0-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 |
1484128b5dd3f9ca7609cb371c93b9d6ef70eba9bfe4df8010656e54baec4f6e
|
|
BLAKE2b-256 checksum How to use checksums |
98fb350701044fd2615a48717d927456e4ba0dfa94595929c7980c55578c90f7
|
| 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.0-cp314-abi3-manylinux_2_28_aarch64.whl
| Download URL | grippo-0.1.0-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 |
ec99dd2ce1ba2a946e8dbd1cafc68ec107e2399f175fd34cb13bd2254899bc13
|
|
BLAKE2b-256 checksum How to use checksums |
88c33ae1eee52c3bdcec00204a370ecef651c9ef7107dfcf05684922fec41cd8
|
| 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.0-cp314-abi3-macosx_11_0_arm64.whl
| Download URL | grippo-0.1.0-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 |
06a5318b7c946789909dce1a1da291440e1d93fa5906b5d09090d5742dcd3b15
|
|
BLAKE2b-256 checksum How to use checksums |
8a9727753b222604e7eb4cab84849ac9d1408b4ab8035ab8e8878236604f8fd1
|
| 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.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.
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.