scrubber_rb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.cargo/config.toml +21 -0
- data/CHANGELOG.md +59 -0
- data/Cargo.lock +626 -0
- data/Cargo.toml +10 -0
- data/LICENSE +21 -0
- data/README.md +298 -0
- data/SECURITY.md +54 -0
- data/ext/scrubber_rb/Cargo.toml +41 -0
- data/ext/scrubber_rb/build.rs +6 -0
- data/ext/scrubber_rb/extconf.rb +6 -0
- data/ext/scrubber_rb/src/detectors/checksum.rs +222 -0
- data/ext/scrubber_rb/src/detectors/mod.rs +636 -0
- data/ext/scrubber_rb/src/detectors/upi.rs +138 -0
- data/ext/scrubber_rb/src/detectors/validate.rs +339 -0
- data/ext/scrubber_rb/src/engine.rs +716 -0
- data/ext/scrubber_rb/src/lib.rs +247 -0
- data/ext/scrubber_rb/src/nogvl.rs +84 -0
- data/ext/scrubber_rb/src/offsets.rs +118 -0
- data/ext/scrubber_rb/src/pattern.rs +319 -0
- data/ext/scrubber_rb/src/replace.rs +238 -0
- data/lib/scrubber/instance.rb +223 -0
- data/lib/scrubber/llm_guard.rb +79 -0
- data/lib/scrubber/log_formatter.rb +40 -0
- data/lib/scrubber/match.rb +27 -0
- data/lib/scrubber/middleware.rb +124 -0
- data/lib/scrubber/version.rb +5 -0
- data/lib/scrubber_rb.rb +109 -0
- data/sig/scrubber_rb.rbs +150 -0
- metadata +96 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c2ad9752a533c73935b72e5d66553a24ecc1f7aa3d89d1e4e420e64cd3e7d3be
|
|
4
|
+
data.tar.gz: 68e7b9b45c4470c5e182e6c36fb498d7c3aad86c8ca852d3dfe1513bbdbb9a1c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ca7640c6d91f3787336e5821f2448a995ff23059c73f132811738304e5a77708eaff82c3b5747a24a3453f21238d9cc7c44cb7917db6ed850a723e82cfbf8ca8
|
|
7
|
+
data.tar.gz: 818fd4aabd8158ebdf47ced475893c60c8a0f26a4550aeccc996040cec8c531cf47ef8ea409749a38cfb7e7a50d625355043a1d7b89fa02b290d11921834159c
|
data/.cargo/config.toml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# musl targets static-link the C runtime by default, and a statically linked
|
|
2
|
+
# CRT cannot produce a shared library. Cargo decides whether a target supports
|
|
3
|
+
# `cdylib` *before* it invokes rustc, so the `-C target-feature=-crt-static`
|
|
4
|
+
# that rb_sys appends after `cargo rustc --` arrives too late:
|
|
5
|
+
#
|
|
6
|
+
# error: cannot produce cdylib for `scrubber_rb` as the target
|
|
7
|
+
# `x86_64-unknown-linux-musl` does not support these crate types
|
|
8
|
+
#
|
|
9
|
+
# Setting it here instead means cargo sees it while probing the target, decides
|
|
10
|
+
# cdylib is buildable, and the cross-compiled gem links. This also fixes source
|
|
11
|
+
# builds on Alpine, which is why the file ships inside the gem.
|
|
12
|
+
#
|
|
13
|
+
# Note the precedence rule: a `RUSTFLAGS` environment variable *replaces* these
|
|
14
|
+
# rather than merging with them. Anything that sets `RUSTFLAGS` for a musl build
|
|
15
|
+
# has to include `-C target-feature=-crt-static` itself.
|
|
16
|
+
|
|
17
|
+
[target.x86_64-unknown-linux-musl]
|
|
18
|
+
rustflags = ["-C", "target-feature=-crt-static"]
|
|
19
|
+
|
|
20
|
+
[target.aarch64-unknown-linux-musl]
|
|
21
|
+
rustflags = ["-C", "target-feature=-crt-static"]
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-08-16
|
|
11
|
+
|
|
12
|
+
First release.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Rust scanning core** (magnus + rb-sys). Two-stage pass: one Aho-Corasick sweep over
|
|
17
|
+
literal anchors to eliminate rules that cannot match, then one `RegexSet` pass for the rest.
|
|
18
|
+
Overlaps resolved by leftmost, then most specific, then longest. Output built in a single
|
|
19
|
+
walk rather than repeated `gsub`.
|
|
20
|
+
- **14 default detectors**: `email`, `phone`, `credit_card`, `ssn`, `iban`, `ip`, `ipv6`,
|
|
21
|
+
`mac`, `jwt`, `aws_key`, `api_key`, `private_key`, `password_pair`, `url_credentials`.
|
|
22
|
+
- **Opt-in India pack** (`Scrubber::INDIA`): `phone_in`, `aadhaar`, `pan`, `upi`, for DPDP Act
|
|
23
|
+
workloads.
|
|
24
|
+
- **Checksum validation**: Luhn for cards, Verhoeff for Aadhaar, ISO 7064 mod-97 for IBAN
|
|
25
|
+
(plus an IBAN country-registry check), SSA range rules for SSNs, PAN entity-character check,
|
|
26
|
+
and a PSP allowlist for UPI handles.
|
|
27
|
+
- **19 provider-specific API key formats** under `:api_key` — GitHub, GitLab, Slack, Stripe,
|
|
28
|
+
OpenAI, Anthropic, Google, SendGrid, Twilio, npm, PyPI, Shopify, Square, Mailgun,
|
|
29
|
+
DigitalOcean, Telegram, AWS secret keys. No entropy heuristics.
|
|
30
|
+
- **Four replacement strategies**: `:label`, `:mask`, `:hash` (salted, deterministic, so logs
|
|
31
|
+
stay correlatable), `:remove`.
|
|
32
|
+
- **Custom detectors** from Ruby `Regexp`s, translated to Rust regex syntax. Backreferences,
|
|
33
|
+
lookaround, atomic groups and possessive quantifiers raise
|
|
34
|
+
`Scrubber::UnsupportedPatternError` at construction time, naming the construct — never
|
|
35
|
+
silent partial coverage.
|
|
36
|
+
- **`Scrubber::LogFormatter`** — wraps any Logger formatter.
|
|
37
|
+
- **`Scrubber::Middleware`** — Rack middleware that publishes redacted copies of the query
|
|
38
|
+
string and params at `env["scrubber.*"]` and redacts exception messages on the way out. It
|
|
39
|
+
deliberately does not rewrite the live request.
|
|
40
|
+
- **`Scrubber::LLMGuard`** — a plain callable that redacts prompts, message arrays and message
|
|
41
|
+
hashes before they reach a model API. Defaults to `:hash`.
|
|
42
|
+
- **`Scrubber.scrub_file`** — streams in 1MB chunks with an 8KB carry window, cutting at line
|
|
43
|
+
boundaries, with an extra guard so multi-line PEM blocks are never split.
|
|
44
|
+
- **GVL released** for inputs over 64KB, so large scans don't stall other threads.
|
|
45
|
+
- **Panic hygiene**: every FFI entry point is wrapped in `catch_unwind`; a Rust panic becomes
|
|
46
|
+
`Scrubber::InternalError` rather than a process abort.
|
|
47
|
+
- **Invalid UTF-8 tolerance**: valid regions are scrubbed, invalid bytes pass through
|
|
48
|
+
unchanged, nothing raises.
|
|
49
|
+
- **Character-accurate offsets** from `Scrubber#detect`, so spans index the Ruby string
|
|
50
|
+
correctly through emoji and Devanagari.
|
|
51
|
+
- **Benchmark suite** with an honest pure-Ruby reference implementing the identical detector
|
|
52
|
+
set, a seeded 100MB corpus generator, and a spec asserting the two implementations redact
|
|
53
|
+
identical spans.
|
|
54
|
+
- **Precompiled gems** for `x86_64-linux`, `x86_64-linux-musl`, `aarch64-linux`,
|
|
55
|
+
`aarch64-linux-musl`, `x86_64-darwin`, `arm64-darwin`, plus a best-effort
|
|
56
|
+
`x64-mingw-ucrt` and the source gem.
|
|
57
|
+
|
|
58
|
+
[Unreleased]: https://github.com/TheSoloHacker47/scrubber-rb/compare/v0.1.0...HEAD
|
|
59
|
+
[0.1.0]: https://github.com/TheSoloHacker47/scrubber-rb/releases/tag/v0.1.0
|