flare-redact 1.10.4 → 1.12.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +144 -3
  2. package/README.md +40 -3
  3. package/SECURITY.md +1 -1
  4. package/dist/audit.d.ts +82 -0
  5. package/dist/audit.d.ts.map +1 -0
  6. package/dist/audit.js +146 -0
  7. package/dist/audit.js.map +1 -0
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +20 -3
  10. package/dist/cli.js.map +1 -1
  11. package/dist/db.d.ts +67 -0
  12. package/dist/db.d.ts.map +1 -0
  13. package/dist/db.js +402 -0
  14. package/dist/db.js.map +1 -0
  15. package/dist/detectors.d.ts +1 -2
  16. package/dist/detectors.d.ts.map +1 -1
  17. package/dist/detectors.js +8 -4
  18. package/dist/detectors.js.map +1 -1
  19. package/dist/engine.d.ts.map +1 -1
  20. package/dist/engine.js +24 -6
  21. package/dist/engine.js.map +1 -1
  22. package/dist/extra.d.ts.map +1 -1
  23. package/dist/extra.js +3 -1
  24. package/dist/extra.js.map +1 -1
  25. package/dist/fold.d.ts +22 -0
  26. package/dist/fold.d.ts.map +1 -0
  27. package/dist/fold.js +140 -0
  28. package/dist/fold.js.map +1 -0
  29. package/dist/help.d.ts +1 -1
  30. package/dist/help.d.ts.map +1 -1
  31. package/dist/help.js +15 -9
  32. package/dist/help.js.map +1 -1
  33. package/dist/i18n.d.ts +10 -0
  34. package/dist/i18n.d.ts.map +1 -1
  35. package/dist/i18n.js +18 -1
  36. package/dist/i18n.js.map +1 -1
  37. package/dist/pack.d.ts +2 -2
  38. package/dist/pack.d.ts.map +1 -1
  39. package/dist/pack.js +9 -7
  40. package/dist/pack.js.map +1 -1
  41. package/dist/recording.d.ts +82 -0
  42. package/dist/recording.d.ts.map +1 -0
  43. package/dist/recording.js +195 -0
  44. package/dist/recording.js.map +1 -0
  45. package/dist/register.d.ts +22 -4
  46. package/dist/register.d.ts.map +1 -1
  47. package/dist/register.js +51 -4
  48. package/dist/register.js.map +1 -1
  49. package/dist/replay.d.ts +54 -0
  50. package/dist/replay.d.ts.map +1 -0
  51. package/dist/replay.js +87 -0
  52. package/dist/replay.js.map +1 -0
  53. package/dist/snapshot.d.ts +25 -0
  54. package/dist/snapshot.d.ts.map +1 -0
  55. package/dist/snapshot.js +49 -0
  56. package/dist/snapshot.js.map +1 -0
  57. package/dist/terms.d.ts +4 -4
  58. package/dist/terms.d.ts.map +1 -1
  59. package/dist/terms.js +22 -13
  60. package/dist/terms.js.map +1 -1
  61. package/docs/guide.md +318 -16
  62. package/package.json +21 -1
  63. package/spec/SPEC.md +142 -51
  64. package/spec/conformance/README.md +7 -4
  65. package/spec/conformance/cases.json +22 -0
  66. package/spec/conformance/expected.json +378 -0
  67. package/spec/detectors.json +4 -4
  68. package/spec/detectors.schema.json +1 -1
package/docs/guide.md CHANGED
@@ -10,7 +10,8 @@ version. Coding assistants can read the same API in condensed form at
10
10
  - [Install](#install)
11
11
  - [Practical guides](https://flare-collection.github.io/flare-redact/guides/)
12
12
  - [Runnable examples](#runnable-examples)
13
- - [Python, Go, and Rust](#python-go-and-rust)
13
+ - [Python, Go, Rust, Java and .NET](#python-go-rust-java-and-net)
14
+ - [Fluent Bit](#fluent-bit)
14
15
  - [The sidecar gateway](#the-sidecar-gateway)
15
16
  - [Redact anything](#redact-anything)
16
17
  - [Integrate any SDK or framework](#integrate-any-sdk-or-framework)
@@ -25,10 +26,15 @@ version. Coding assistants can read the same API in condensed form at
25
26
  - [Protect tool calls and MCP loops](#protect-tool-calls-and-mcp-loops)
26
27
  - [Your own words](#your-own-words)
27
28
  - [See what leaks, and why](#see-what-leaks-and-why)
29
+ - [Measure before you enforce](#measure-before-you-enforce)
28
30
  - [Guard your logger in one line](#guard-your-logger-in-one-line)
31
+ - [Database query logs](#database-query-logs)
29
32
  - [One policy, everywhere](#one-policy-everywhere)
30
33
  - [Anonymize a dataset for staging](#anonymize-a-dataset-for-staging)
34
+ - [Clean test recordings and snapshots](#clean-test-recordings-and-snapshots)
35
+ - [Clean data frames and SQL tables](#clean-data-frames-and-sql-tables)
31
36
  - [Guard what leaves your app](#guard-what-leaves-your-app)
37
+ - [Mask session replays](#mask-session-replays)
32
38
  - [Streams](#streams)
33
39
  - [Fail a build when a secret sneaks in](#fail-a-build-when-a-secret-sneaks-in)
34
40
  - [CLI](#cli)
@@ -154,21 +160,25 @@ Clone the repository and run these small applications locally:
154
160
 
155
161
  Run `npm run build` and install an example's dependencies before its first run.
156
162
 
157
- ## Python, Go, and Rust
163
+ ## Python, Go, Rust, Java and .NET
164
+
165
+ <a id="python-go-and-rust"></a>
158
166
 
159
167
  The people who most need to keep data out of a prompt are usually not writing
160
- JavaScript. There are now four engines, and they are not four ports: they all
168
+ JavaScript. There are now six engines, and they are not six ports: they all
161
169
  execute the same [FRS-1 detector specification](../spec/SPEC.md) and are held to the
162
170
  same [conformance corpus](../spec/conformance/), so a policy written once produces
163
171
  identical output in every one of them.
164
172
 
165
173
  Each engine is its own package. Installing `flare-redact` from npm gives you the
166
- JavaScript engine and nothing else: no Python, no Go, no Rust, and no
167
- dependencies of any kind.
174
+ JavaScript engine and nothing else: no Python, no Go, no Rust, no JVM, no .NET,
175
+ and no dependencies of any kind.
168
176
 
169
177
  | | Install | Docs |
170
178
  |---|---|---|
171
179
  | **Go** | `go get github.com/flare-collection/flare-redact/sdk/go` | [`sdk/go`](../sdk/go) |
180
+ | **Java** | `io.github.flare-collection:flare-redact` on Maven Central | [`sdk/java`](../sdk/java) |
181
+ | **.NET** | `dotnet add package FlareRedact` | [`sdk/dotnet`](../sdk/dotnet) |
172
182
  | **Python** | `pip install flare-redact` | [`sdk/python`](../sdk/python) |
173
183
  | **Rust** | `cargo add flare-redact` | [`sdk/rust`](../sdk/rust) |
174
184
 
@@ -177,11 +187,11 @@ first release after 1.9.1. Until it lands, or to pin a tag, install them from
177
187
  this repository:
178
188
 
179
189
  ```bash
180
- pip install "flare-redact @ git+https://github.com/flare-collection/flare-redact@v1.10.4#subdirectory=sdk/python"
190
+ pip install "flare-redact @ git+https://github.com/flare-collection/flare-redact@v1.12.0#subdirectory=sdk/python"
181
191
  ```
182
192
 
183
193
  ```toml
184
- flare-redact = { git = "https://github.com/flare-collection/flare-redact", tag = "v1.10.4" }
194
+ flare-redact = { git = "https://github.com/flare-collection/flare-redact", tag = "v1.12.0" }
185
195
  ```
186
196
 
187
197
  ```python
@@ -202,18 +212,33 @@ let policy = Policy::compile(Options::new().enable(["pii"]))?;
202
212
  let safe = policy.redact_str("contact ada@example.com")?;
203
213
  ```
204
214
 
205
- Each SDK is dependency-light on purpose (Python is standard library only, Go is
206
- standard library only, Rust is `regex` plus `serde`) because a redaction library
215
+ ```java
216
+ Policy policy = Policy.compile(RedactOptions.builder().enable("pii").build());
217
+ String safe = policy.redactString("contact ada@example.com");
218
+ ```
219
+
220
+ ```csharp
221
+ builder.Logging.AddConsole().AddFlareRedact(new RedactOptions { Enable = { "pii" } });
222
+ ```
223
+
224
+ The Java and .NET packages are published to Maven Central and NuGet starting
225
+ with 1.12.0.
226
+
227
+ Each SDK is dependency-light on purpose (Python and Go use the standard library
228
+ only, the Java and .NET cores have no dependencies at all, Rust is `regex` plus
229
+ `serde`) because a redaction library
207
230
  that expands your dependency tree is a security library that widened your attack
208
231
  surface. Each also ships the integrations its ecosystem actually uses: a
209
- `logging` filter and formatter and OpenAI/Anthropic client wrappers in Python, an
210
- `slog.Handler` and an `http.RoundTripper` in Go.
232
+ `logging` filter and formatter, OpenAI/Anthropic client wrappers and
233
+ [pandas, Polars and DuckDB](#clean-data-frames-and-sql-tables) helpers in
234
+ Python, an `slog.Handler` and an `http.RoundTripper` in Go, Logback and Log4j 2
235
+ in Java, and Serilog and `Microsoft.Extensions.Logging` in .NET.
211
236
 
212
- Drift is the reason this is a specification and not three ports. Detection logic
213
- maintained in four hand-written copies diverges within a release or two, and a
237
+ Drift is the reason this is a specification and not six ports. Detection logic
238
+ maintained in six hand-written copies diverges within a release or two, and a
214
239
  redactor that behaves differently per language is worse than none, because the
215
240
  team stops being able to reason about what leaves the process. The corpus runs in
216
- all four test suites; a change that makes them disagree fails CI.
241
+ all six test suites; a change that makes them disagree fails CI.
217
242
 
218
243
  Detectors themselves are data. Write an [FRS-1 pack](../spec/SPEC.md) once and every
219
244
  engine loads the same file:
@@ -227,6 +252,32 @@ A pack that uses a construct an engine cannot execute exactly (a lookahead, a
227
252
  `\d` whose meaning differs between languages, a checksum it does not implement)
228
253
  fails to load. Failing open is how a redactor leaks.
229
254
 
255
+ ## Fluent Bit
256
+
257
+ When logs are collected by Fluent Bit, redact them on the node with the WASM
258
+ filter, before they reach Loki, Elasticsearch, Datadog or S3. It is the Rust
259
+ engine compiled to WebAssembly, so it catches what the other engines catch.
260
+
261
+ ```text
262
+ [FILTER]
263
+ Name wasm
264
+ Match *
265
+ WASM_Path /etc/fluent-bit/flare-redact-fluent-bit.wasm
266
+ Function_Name flare_redact
267
+ Accessible_Paths /etc/flare-redact
268
+ WASM_Stack_Size 2M
269
+ WASM_Heap_Size 8M
270
+ ```
271
+
272
+ Keep the two size lines: Fluent Bit's 8 KB defaults are too small to compile
273
+ the detectors, and the heap bounds the largest record. `Function_Name` picks the policy: `flare_redact` (defaults), `flare_redact_pii`
274
+ (phone numbers too) or `flare_redact_label` (`[REDACTED:email]`). Anything else
275
+ goes in a `flare-redact.json` in an accessible path, with the same option names
276
+ as everywhere else. An invalid file, or a record that cannot be redacted, makes
277
+ the filter replace the record with `{"flare_redact_error": "..."}` instead of
278
+ passing it on. The `.wasm` is attached to every GitHub Release;
279
+ [sdk/fluent-bit](../sdk/fluent-bit) has the build steps and every option.
280
+
230
281
  ## The sidecar gateway
231
282
 
232
283
  Sometimes the right amount of integration is none. The gateway is a reverse
@@ -866,6 +917,57 @@ isClean(payload); // → false
866
917
  summary(payload); // → { total: 3, byDetector: { email: 1, github_token: 1, sensitive_key: 1 } }
867
918
  ```
868
919
 
920
+ ## Measure before you enforce
921
+
922
+ Turning redaction on in production is a leap of faith: nobody knows how many
923
+ log lines carry an email, which detector fires most, or whether a field the
924
+ team needs would be masked. Shadow mode counts what a policy would redact while
925
+ the data passes through unchanged, so the decision rests on numbers. It never
926
+ keeps a matched value.
927
+
928
+ ```bash
929
+ FLARE_REDACT_MODE=shadow node --import flare-redact/register app.js
930
+ ```
931
+
932
+ ```
933
+ [flare-redact shadow] 2184 findings in 1940 of 52310 values (3.7%) since 2026-11-23T09:00:00.000Z
934
+ email 1602
935
+ jwt 410
936
+ sensitive_key 172
937
+ top fields:
938
+ user.email 1544
939
+ headers.authorization 410
940
+ ```
941
+
942
+ `FLARE_REDACT_MODE` is `enforce` (the default), `shadow` (count only) or
943
+ `audit` (redact and count). The report goes to stderr when the process exits,
944
+ and every `FLARE_REDACT_REPORT_EVERY` seconds when that is set. An unknown mode
945
+ stops the process at startup, like an unknown preset.
946
+
947
+ In code, an audit observes any value and can feed OpenTelemetry, so the counts
948
+ land on the dashboards you already have:
949
+
950
+ ```js
951
+ import { createAudit, shadowConsole } from 'flare-redact/audit';
952
+
953
+ const audit = createAudit({ preset: 'gdpr', meter: metrics.getMeter('app') });
954
+ audit.observe(webhookBody, 'webhook'); // returned unchanged, counted
955
+ audit.redact(event, 'events'); // enforced, still counted
956
+ shadowConsole(audit); // count console output
957
+ audit.report(); // { total, byDetector, byRisk, bySource, byPath }
958
+ ```
959
+
960
+ The meter gets `flare_redact.findings` (by detector, risk and source) and
961
+ `flare_redact.scanned` (by source). Field paths fold array indices, so
962
+ `users[3].email` and `users[7].email` count as `users[].email`, and at most 500
963
+ distinct paths are kept. Python has the same `Audit` and a logging filter:
964
+
965
+ ```python
966
+ from flare_redact.audit import Audit, AuditFilter
967
+
968
+ logging.getLogger().addFilter(AuditFilter(Audit(preset="gdpr"))) # enforce=True to redact too
969
+ ```
970
+
869
971
  ## Guard your logger in one line
870
972
 
871
973
  `wrapConsole` patches `console.*` so every argument is redacted on the way out,
@@ -969,6 +1071,39 @@ span. Keep personal data out of span names, as Sentry itself advises, and leave
969
1071
  Same `policy` object flows into `flare-redact/llm`, `wrapConsole`, `createVault`,
970
1072
  and `redactStream` too.
971
1073
 
1074
+ ## Database query logs
1075
+
1076
+ Query logging is turned on to debug a slow page and left on. ORMs log the SQL
1077
+ and its bound parameters, and a parameter list is the hardest place to see a
1078
+ secret: in `["ada@example.com", "hunter2"]` the password has no shape a
1079
+ detector could recognise. `flare-redact/db` matches each placeholder and
1080
+ literal to the column it is compared with or inserted into, so a value bound to
1081
+ `password`, `token` or `api_key` is masked by name, and the rest is checked by
1082
+ the usual detectors.
1083
+
1084
+ ```
1085
+ insert into "users" ("email", "password", "api_key") values ($1, $2, $3) -- params: ["ada@example.com","hunter2","k-7c1e0f2a9b"]
1086
+ insert into "users" ("email", "password", "api_key") values ($1, $2, $3) -- params: ["a***@***","***","***"]
1087
+ ```
1088
+
1089
+ ```js
1090
+ import { prismaQueryLogger, drizzleLogger, typeormLogger, knexQueryLogger, sequelizeLogging } from 'flare-redact/db';
1091
+
1092
+ prisma.$on('query', prismaQueryLogger(logger.info)); // log: [{ emit: 'event', level: 'query' }]
1093
+ drizzle(client, { logger: drizzleLogger() });
1094
+ new DataSource({ ...config, logger: typeormLogger(new SimpleConsoleLogger()) });
1095
+ knex.on('query', knexQueryLogger(logger.debug));
1096
+ new Sequelize(url, { logging: sequelizeLogging(logger.debug) }); // logQueryParameters too
1097
+ ```
1098
+
1099
+ `redactQuery(sql, params)` does the same for any other client and returns
1100
+ `{ sql, params }`; positional (`$1`, `?`) and named (`:name`, `@name`)
1101
+ parameters are both understood. A column is found from `col = ?`,
1102
+ `col IN (?, ?)`, a qualified `"t"."col"` and `INSERT INTO t (a, b) VALUES ...`
1103
+ rows. Checked against Prisma 7, Drizzle on PGlite, TypeORM on sql.js, Knex on
1104
+ better-sqlite3 and Sequelize on SQLite: none of them leaked an email, password
1105
+ or API key into their logs.
1106
+
972
1107
  ## Streams
973
1108
 
974
1109
  Pipe any log stream through it. Secrets may be split across chunks, and bounded
@@ -1001,6 +1136,118 @@ Alice,alice@corp.com,4242 4242 4242 4242 Alice,user_93a78c61e204@example.in
1001
1136
  `redactCsv(text, opts)` is available from `flare-redact/csv` for the same thing
1002
1137
  in code.
1003
1138
 
1139
+ ## Clean test recordings and snapshots
1140
+
1141
+ Test suites write real traffic to disk and commit it: vcrpy and
1142
+ pytest-recording cassettes, Polly.js and Playwright HAR files, Jest and Vitest
1143
+ snapshots. A recording leaks where a log line does not: `X-Api-Key` and
1144
+ `Set-Cookie` headers, opaque session cookies, `?access_token=` in a URL, and
1145
+ bodies stored as JSON text, form text or base64. These hooks clean each of
1146
+ them before the file is written, and leave everything a test matches on alone.
1147
+
1148
+ **pytest-recording and vcrpy.** Requests are masked the same way when they are
1149
+ recorded and when they are matched, so playback still works with a token in the
1150
+ query string. Gzip bodies are stored decompressed so they can be read and
1151
+ cleaned; binary bodies are left as they are.
1152
+
1153
+ ```python
1154
+ import pytest
1155
+ from flare_redact.recording import vcr_config as flare_vcr_config
1156
+
1157
+ @pytest.fixture(scope="module")
1158
+ def vcr_config():
1159
+ return flare_vcr_config() # or vcr.VCR(**flare_vcr_config())
1160
+ ```
1161
+
1162
+ **Polly.js.** Polly matches a replayed request by a hash it took of the live
1163
+ request, so the recording on disk can be masked without breaking replay.
1164
+
1165
+ ```js
1166
+ import { pollyBeforePersist } from 'flare-redact/recording';
1167
+
1168
+ polly.server.any().on('beforePersist', pollyBeforePersist());
1169
+ ```
1170
+
1171
+ **Any HAR file** (devtools export, Playwright `recordHar`): clean it in place
1172
+ before it is committed or attached to a ticket. Headers, cookies, query
1173
+ parameters and bodies are masked; timings, status codes and every other field
1174
+ stay as they were, and `Content-Length` and `size` are updated.
1175
+
1176
+ ```bash
1177
+ flare-redact --har < session.har > session.safe.har
1178
+ python -m flare_redact --har < session.har > session.safe.har
1179
+ ```
1180
+
1181
+ `redactHar(har, opts)` and `redactHarEntry(entry, opts)` do the same in code;
1182
+ the JavaScript and Python engines give the same output for the same file.
1183
+
1184
+ **Vitest and Jest snapshots.** The serializer takes over only values that need
1185
+ masking and hands the masked copy back to the usual printer, so clean snapshots
1186
+ do not change.
1187
+
1188
+ ```js
1189
+ // vitest.config.js
1190
+ export default { test: { snapshotSerializers: ['flare-redact/snapshot'] } };
1191
+ ```
1192
+
1193
+ Jest cannot `require` an ES module before Node 24.9, so with Jest register it
1194
+ from a setup file (`setupFilesAfterEnv: ['<rootDir>/jest.setup.mjs']`, run with
1195
+ `NODE_OPTIONS=--experimental-vm-modules`):
1196
+
1197
+ ```js
1198
+ // jest.setup.mjs
1199
+ import { expect } from '@jest/globals';
1200
+ import serializer from 'flare-redact/snapshot';
1201
+
1202
+ expect.addSnapshotSerializer(serializer);
1203
+ ```
1204
+
1205
+ `createSnapshotSerializer(opts)` builds one with your own options, for example
1206
+ `{ mode: 'label' }` for `[REDACTED:email]` in place of a mask.
1207
+
1208
+ ## Clean data frames and SQL tables
1209
+
1210
+ Data on its way to a notebook, a parquet file, a feature store or a model often
1211
+ passes through pandas, Polars or DuckDB. The Python SDK cleans text columns
1212
+ where the data already is. None of the three libraries is a dependency; each is
1213
+ imported only when you use it.
1214
+
1215
+ ```python
1216
+ import flare_redact.frames as frames
1217
+
1218
+ safe = frames.redact_frame(df) # pandas or Polars, lazy frames too
1219
+ safe = frames.redact_frame(df, columns=["note"], mode="label")
1220
+ frames.scan_frame(df)
1221
+ # {'total': 5, 'columns': {'note': {'rows': 2, 'by_detector': {'email': 1, 'github_token': 1}},
1222
+ # 'password': {'rows': 3, 'by_detector': {'sensitive_key': 3}}}}
1223
+ ```
1224
+
1225
+ `frames.register()` adds a `.flare` namespace to pandas (`DataFrame`, `Series`)
1226
+ and Polars (`DataFrame`, `LazyFrame`, `Series`, `Expr`):
1227
+
1228
+ ```python
1229
+ frames.register()
1230
+ df.flare.redact()
1231
+ df.with_columns(pl.col("note").flare.redact()) # inside a Polars query
1232
+ ```
1233
+
1234
+ In DuckDB the same rules are SQL functions:
1235
+
1236
+ ```python
1237
+ frames.register_duckdb(con)
1238
+ con.sql("""
1239
+ SELECT redact(note), redact_field('password', pw), redact_is_clean(note)
1240
+ FROM tickets
1241
+ """)
1242
+ ```
1243
+
1244
+ A column is treated like a field, so a column named `password` or `api_key` is
1245
+ masked whole, as a dictionary key with that name would be. Each distinct value
1246
+ is redacted once (1M pandas or Polars rows with 2,000 distinct values take
1247
+ under 0.2 s), and with `mode="hash"`, `"pseudonym"` or `"surrogate"` the same
1248
+ value maps the same way everywhere, so joins keep working. `scan_frame` returns
1249
+ counts only, never values, so its report is safe to log.
1250
+
1004
1251
  ## Guard what leaves your app
1005
1252
 
1006
1253
  Stop PII from reaching an analytics, telemetry, or webhook endpoint: wrap
@@ -1014,6 +1261,52 @@ const fetch = wrapFetch(globalThis.fetch, { hosts: ['api.segment.io', 'telemetry
1014
1261
  // bodies sent to those hosts are redacted; everything else is left alone
1015
1262
  ```
1016
1263
 
1264
+ ## Mask session replays
1265
+
1266
+ Session replay tools record what users see and type. Their built-in choices are
1267
+ to mask every character, which makes replays hard to use, or to mask only the
1268
+ elements a CSS selector names, which misses the email typed into a search box
1269
+ and the API key pasted into a support form. `flare-redact/replay` masks what is
1270
+ sensitive and keeps the rest readable.
1271
+
1272
+ ```js
1273
+ import { replayMaskFn, rrwebMasking } from 'flare-redact/replay';
1274
+
1275
+ // rrweb
1276
+ rrweb.record({ emit, ...rrwebMasking() });
1277
+
1278
+ // Sentry Session Replay: maskAllText and maskAllInputs stay on (the default)
1279
+ Sentry.replayIntegration({ maskFn: replayMaskFn() });
1280
+
1281
+ // PostHog
1282
+ posthog.init(key, { session_recording: rrwebMasking() });
1283
+ ```
1284
+
1285
+ ```
1286
+ Please call me at +44 20 7946 0958 or mail ada@example.com
1287
+ Please call me at *** ** **** **** or mail ***************
1288
+ ```
1289
+
1290
+ - Each masked character becomes `*` and spaces are kept, as rrweb's own masking
1291
+ does, so the replayed layout does not shift. `preserveLength: false` gives
1292
+ the usual masks (`a***@***`) or the chosen `mode` instead.
1293
+ - A form field is masked whole when it is a password field, when its
1294
+ `autocomplete` names a password, one-time code or card number, or when its
1295
+ `name` or `id` is a credential name such as `password` or `api_key`. Anything
1296
+ else typed is masked where a detector finds something, and that holds for
1297
+ later keystrokes too, not only the first snapshot.
1298
+ - Without detector options the `pii` group is on, so phone numbers count. Free
1299
+ text names and addresses are not caught by default; add
1300
+ `enable: ['pii', 'entities']`, or keep a selector-based mask on the parts of
1301
+ the page that show them.
1302
+ - It runs in the browser with no Node built-ins: about 57 kB gzipped with every
1303
+ detector bundled. Repeated texts are cached.
1304
+
1305
+ Checked with rrweb 2.2, which Sentry and PostHog both record with. This makes
1306
+ replays readable, so it only shows text the detectors consider clean; keep
1307
+ `block` and `mask` selectors on screens that show sensitive data the detectors
1308
+ cannot recognise, such as medical notes.
1309
+
1017
1310
  ## Fail a build when a secret sneaks in
1018
1311
 
1019
1312
  Stop it before the commit exists:
@@ -1035,7 +1328,7 @@ not, as long as Node 20 or newer is on the PATH:
1035
1328
  ```yaml
1036
1329
  repos:
1037
1330
  - repo: https://github.com/flare-collection/flare-redact
1038
- rev: v1.10.4
1331
+ rev: v1.12.0
1039
1332
  hooks:
1040
1333
  - id: flare-redact # only the lines being added, like --staged
1041
1334
  ```
@@ -1100,7 +1393,7 @@ reports never echo the matched secret value:
1100
1393
  with:
1101
1394
  node-version: 24
1102
1395
  - name: Scan project text files
1103
- run: npx --yes --package flare-redact@1.10.4 flare-redact --scan . --exclude package-lock.json
1396
+ run: npx --yes --package flare-redact@1.12.0 flare-redact --scan . --exclude package-lock.json
1104
1397
  ```
1105
1398
 
1106
1399
  The scan runs on the GitHub runner, reports safe file and source locations, and
@@ -1326,8 +1619,17 @@ redactHttp(req, opts?) // 'flare-redact/http' → safe-to-log request snaps
1326
1619
  redactUrl(url, opts?) // 'flare-redact/http' → sanitized absolute/relative URL
1327
1620
  httpRedactor(opts?) // 'flare-redact/http' → Express/Connect middleware
1328
1621
  redactCsv(text, opts?) // 'flare-redact/csv' → anonymize a CSV dataset
1622
+ redactHar(har, opts?) // 'flare-redact/recording' → clean a HAR file (also redactHarEntry)
1623
+ pollyBeforePersist(opts?) // 'flare-redact/recording' → Polly.js beforePersist handler
1624
+ createSnapshotSerializer(opts?) // 'flare-redact/snapshot' → Vitest/Jest snapshot serializer
1625
+ redactQuery(sql, params?, opts?) // 'flare-redact/db' → SQL and bound parameters, masked by column
1626
+ // also from 'flare-redact/db': prismaQueryLogger, drizzleLogger, typeormLogger, knexQueryLogger, sequelizeLogging
1329
1627
  wrapFetch(fetch, opts?) // 'flare-redact/fetch' → redact egress to named hosts
1628
+ replayMaskFn(opts?) // 'flare-redact/replay' → rrweb maskTextFn/maskInputFn, Sentry maskFn
1629
+ rrwebMasking(opts?) // 'flare-redact/replay' → options for rrweb record() or PostHog session_recording
1330
1630
  createRedactionMiddleware(opts?) // 'flare-redact/middleware' → any function/handler
1631
+ createAudit(opts?) // 'flare-redact/audit' → shadow mode: count findings, optional OpenTelemetry meter
1632
+ shadowConsole(audit, console?, { enforce? }) // 'flare-redact/audit' → count console output
1331
1633
 
1332
1634
  // from 'flare-redact/ml'
1333
1635
  secretProbability(value, context?): number // learned secret-vs-look-alike score, 0..1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flare-redact",
3
- "version": "1.10.4",
3
+ "version": "1.12.0",
4
4
  "description": "Keep secrets and PII out of logs, Sentry, LLM prompts and commits. Reads values, not field names. Zero dependencies.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -61,6 +61,26 @@
61
61
  "types": "./dist/csv.d.ts",
62
62
  "default": "./dist/csv.js"
63
63
  },
64
+ "./recording": {
65
+ "types": "./dist/recording.d.ts",
66
+ "default": "./dist/recording.js"
67
+ },
68
+ "./snapshot": {
69
+ "types": "./dist/snapshot.d.ts",
70
+ "default": "./dist/snapshot.js"
71
+ },
72
+ "./replay": {
73
+ "types": "./dist/replay.d.ts",
74
+ "default": "./dist/replay.js"
75
+ },
76
+ "./audit": {
77
+ "types": "./dist/audit.d.ts",
78
+ "default": "./dist/audit.js"
79
+ },
80
+ "./db": {
81
+ "types": "./dist/db.d.ts",
82
+ "default": "./dist/db.js"
83
+ },
64
84
  "./fetch": {
65
85
  "types": "./dist/fetch.d.ts",
66
86
  "default": "./dist/fetch.js"