feat(logs): add ingest-time PII scrubbing for logs#54762
Merged
DanielVisca merged 14 commits intomasterfrom Apr 16, 2026
Merged
feat(logs): add ingest-time PII scrubbing for logs#54762DanielVisca merged 14 commits intomasterfrom
DanielVisca merged 14 commits intomasterfrom
Conversation
- Team logs_settings.pii_scrub_logs and Avro pipeline (decode/enrich/scrub paths) - log-pii-scrub module, metrics, Logs UI toggle, TeamManager markTeamForRefresh per batch - Stripe-shaped test fixture uses string concat to satisfy GitHub push protection Made-with: Cursor
Made-with: Cursor
Contributor
|
Size Change: +4.34 kB (0%) Total Size: 130 MB
ℹ️ View Unchanged
|
Contributor
Prompt To Fix All With AIThis is a comment left during a code review.
Path: nodejs/src/logs-ingestion/logs-ingestion-consumer.ts
Line: 290-294
Comment:
**Cache bypassed on every batch**
`markForRefresh` deletes `cacheUntil[k]` in the LazyLoader, so every subsequent `getTeam` call hits Postgres. Because this is called for every unique team in every batch, the team cache is permanently bypassed for this consumer — the TTL-based protection never has a chance to kick in. Under steady load with many active teams, this causes O(unique_teams_per_batch × batches_per_second) DB reads rather than one per TTL window.
Consider only marking teams for refresh at most once per N seconds using a per-team timestamp, or accepting the existing cache TTL as an acceptable delay for settings to propagate.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: nodejs/src/logs-ingestion/log-pii-scrub.ts
Line: 78-84
Comment:
**Sensitive key detection not applied to JSON body objects**
`scrubJsonValue` only calls `scrubPlainString` on string leaf values — it doesn't check whether an object key is in `SENSITIVE_KEY_SUBSTRINGS`. This means `{"password": "hunter2", "api_key": "secret-value"}` in a log body leaves both values unscrubbed, because neither matches the email, Bearer, Stripe, or card-number patterns. `scrubStringMap` for `attributes` does call `isSensitiveAttributeKey(key)`, so there's an inconsistency between how body JSON and attribute maps are handled, creating a PII gap for the most common sensitive fields.
```ts
if (value !== null && typeof value === 'object') {
const out: Record<string, unknown> = {}
for (const [k, v] of Object.entries(value)) {
- out[k] = scrubJsonValue(v)
+ out[k] = isSensitiveAttributeKey(k) ? PII_REDACTED : scrubJsonValue(v)
}
return out
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: nodejs/src/logs-ingestion/log-pii-scrub.test.ts
Line: 7-12
Comment:
**Prefer parameterised tests**
Multiple input-output assertions for the same function belong in a single `it.each`, which reports each case independently on failure.
```ts
it.each([
['user_password', true],
['Authorization', true],
['my_api_key', true],
['level', false],
])('isSensitiveAttributeKey(%s) === %s', (key, expected) => {
expect(isSensitiveAttributeKey(key)).toBe(expected)
})
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "chore(logs): drop PII_SCRUBBING_DEV.md f..." | Re-trigger Greptile |
Contributor
|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |
…elay but saves resources, untested
…REDACTED}}. Potential timestamp issue
… and avro pipeline Made-with: Cursor
frankh
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(logs): ingest-time PII scrubbing for Avro log pipeline
Problem
Teams need a product-controlled way to strip common secrets and identifiers from log payloads before storage, without relying on ad-hoc client-side filtering.
Changes
processLogMessageBufferdecodes when eitherjson_parse_logsorlogs_settings.pii_scrub_logsis enabled. Flow: decode → optional JSON attribute enrich → optional PII scrub → re-encode. Passthrough (no decode) only when both are off.logs_ingestion_processing_duration_secondsgains labelpii_scrub_enabled.log-pii-scrub.ts): lossy replacement with{{REDACTED}}.Bearer …tails, Stripe-shapedsk_live_/sk_test_keys, emails, and Luhn-valid 13–19 digit card-like runs (optional spaces/hyphens between digits).SENSITIVE_KEY_SUBSTRINGS) redact the whole value.service_name,instrumentation_scope,severity_text,event_name.pii_scrub_logs?: booleanonLogsSettings(frontend + nodejs).Limitations: Secrets without those shapes, digit runs that are not Luhn-valid cards, and values under keys outside the sensitive list only get generic pattern coverage (not full KV intelligence).
How to enable:
PII scrubbing turned OFF
PII scrubbing turned ON
Attribute Scrubbing:
How did you test this code?
nodejs/src/logs-ingestion/log-pii-scrub.test.tsnodejs/src/logs-ingestion/log-record-avro.test.ts(includingpii_scrub_logsalone / combined withjson_parse_logs)Publish to changelog?
Docs update
LLM context
Improvement Ideas/Things to watch
Compute
Double JSON parse of body when both flags are on
Enrich path parses the body (via extractJsonAttributesFromBody → parseJSON). Scrub path parses again in scrubBodyField. Same string, two parses — wasted CPU and allocator churn, scales with body size.
Catch more