data_redactor 0.5.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/CHANGELOG.md +67 -0
- data/LICENSE +21 -0
- data/ext/data_redactor/data_redactor.c +1047 -0
- data/ext/data_redactor/extconf.rb +8 -0
- data/lib/data_redactor/version.rb +3 -0
- data/lib/data_redactor.rb +145 -0
- data/readme.md +269 -0
- metadata +87 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: cb5ea859ac53fad02d55edfe902ed084c2e344fdae54261ea96ea4cf84fb97ac
|
|
4
|
+
data.tar.gz: b1989344c14e784949e1130478305c4d01f1f3771b44ba4f41eb2f2ca42f6d4f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 39ef5f9ca77539d7a1c7a6cb3c430dbd4ef7f068b67b57dbe72d8df051d36496193388440930cc5cce8e309f6760313e52b5073d3d342157841c4026210b8772
|
|
7
|
+
data.tar.gz: a40435e0034cd18d28679fa384de8ae6f9e4b3dcbdc2d5e0d14e85b85add720f4a13a9b2919ea0782fdc2a3b42c31a5c5c1515c6671e4462e74e99ccef89b273
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
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.5.0] - 2026-05-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `DataRedactor.scan(text, only:, except:)` — returns `{ redacted: String, matches: Array<Hash> }` where each match contains `:tag` (Symbol), `:name` (pattern name String), `:value` (matched text), `:start` (byte offset into original), `:length` (byte length). Accepts the same `only:`/`except:` tag filters as `redact`. Includes both built-in and custom pattern matches.
|
|
14
|
+
- `pattern_names[]` array in the C extension mapping each built-in pattern index to a stable snake_case name string (e.g. `"aws_access_key_id"`, `"email"`, `"iban_de"`).
|
|
15
|
+
|
|
16
|
+
## [0.4.0] - 2026-05-02
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- `placeholder:` keyword argument on `DataRedactor.redact`.
|
|
20
|
+
- Plain string (default `"[REDACTED]"`): `placeholder: "***"`
|
|
21
|
+
- Tagged: `placeholder: :tagged` → `[REDACTED:CONTACT]`, `[REDACTED:CREDENTIALS]`, etc.
|
|
22
|
+
- Deterministic hash: `placeholder: :hash` → `[CONTACT_a3f9]` (4-hex djb2 suffix, same value always produces the same token — useful for correlating redactions across log lines).
|
|
23
|
+
- `PH_MODE_PLAIN`, `PH_MODE_TAGGED`, `PH_MODE_HASH` integer constants exposed from C.
|
|
24
|
+
- `DataRedactor::PLACEHOLDER_DEFAULT` constant (`"[REDACTED]"`).
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- `DataRedactor._redact` now takes 4 arguments: `(text, mask, ph_mode, ph_str)`. The public `DataRedactor.redact` API is fully backward compatible.
|
|
28
|
+
|
|
29
|
+
## [0.3.0] - 2026-05-02
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
- User-supplied custom patterns via `DataRedactor.add_pattern(name:, regex:, tag: :custom, boundary: false)`.
|
|
33
|
+
- `DataRedactor.remove_pattern(name)` — remove a named custom pattern (returns `true`/`false`).
|
|
34
|
+
- `DataRedactor.custom_patterns` — list all registered custom patterns as an array of hashes.
|
|
35
|
+
- `DataRedactor.clear_custom_patterns!` — remove all custom patterns (useful in test suites).
|
|
36
|
+
- New `:custom` tag and `TAG_CUSTOM` bitmask constant for custom patterns. Works with `only:`/`except:`.
|
|
37
|
+
- `DataRedactor::InvalidPatternError` raised when a pattern fails `regcomp` or uses unsupported Ruby-only syntax (`\d`, `\s`, `\w`, `\b`, lookaround, non-greedy quantifiers, named groups).
|
|
38
|
+
- Capture groups rejected at registration when `boundary: true` (group indices would shift).
|
|
39
|
+
- Name collisions replace the existing pattern (the old compiled `regex_t` is freed).
|
|
40
|
+
|
|
41
|
+
## [0.2.0] - 2026-05-02
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
- Tag system: every pattern now belongs to one of 8 tags (`:credentials`, `:financial`, `:tax_id`, `:national_id`, `:contact`, `:network`, `:travel`, `:other`).
|
|
45
|
+
- `DataRedactor.redact(text, only: [...])` to redact only patterns in the given tags.
|
|
46
|
+
- `DataRedactor.redact(text, except: [...])` to redact every tag except the given ones.
|
|
47
|
+
- `DataRedactor.tags` returning the list of supported tags.
|
|
48
|
+
- `DataRedactor::TAGS` constant mapping tag symbols to bitmask values, plus `TAG_*` integer constants exposed from C for advanced use.
|
|
49
|
+
- `DataRedactor::UnknownTagError` raised when an unknown tag symbol is passed.
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
- The C-level entry point is now `DataRedactor._redact(text, mask)` (two-arg, mask is an integer bitmask). The public API is the Ruby wrapper `DataRedactor.redact`, which remains backward compatible: `redact(text)` with no keyword arguments runs every pattern exactly as before.
|
|
53
|
+
|
|
54
|
+
## [0.1.0] - 2026-05-02
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
- Initial release.
|
|
58
|
+
- C extension (`ext/data_redactor/data_redactor.c`) using POSIX `regex.h` for high-throughput scanning.
|
|
59
|
+
- 79 redaction patterns across cloud secrets, API keys, IBANs, national IDs, and PII for 15+ countries.
|
|
60
|
+
- Patterns ordered most-specific to most-generic to prevent shorter patterns from consuming parts of longer matches.
|
|
61
|
+
- Boundary-wrapping mechanism for generic digit/alphanum sequences so they only match at word boundaries.
|
|
62
|
+
- `DataRedactor.redact(text)` module function returning the input with every match replaced by `[REDACTED]`.
|
|
63
|
+
- RSpec suite with one example per pattern.
|
|
64
|
+
|
|
65
|
+
[Unreleased]: https://github.com/danielefrisanco/data_redactor/compare/v0.2.0...HEAD
|
|
66
|
+
[0.2.0]: https://github.com/danielefrisanco/data_redactor/compare/v0.1.0...v0.2.0
|
|
67
|
+
[0.1.0]: https://github.com/danielefrisanco/data_redactor/releases/tag/v0.1.0
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniele Frisanco
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|