Conversation
Co-authored-by: plengauer <100447901+plengauer@users.noreply.github.com>
plengauer
approved these changes
Mar 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Restores JWT masking in job-level OpenTelemetry transform rules without reintroducing the prior hostname-collision problem by matching only JWTs in explicit auth contexts (Bearer , jwt=).
Changes:
- Added prefix-scoped JWT regexes (
(?i)bearer ...andjwt=...) to log attribute/body masking. - Applied the same JWT masking patterns to metric datapoint attributes.
- Applied the same JWT masking patterns to span attributes and span names.
Comments suppressed due to low confidence (5)
actions/instrument/job/inject_and_init.sh:1
- The replacement currently rewrites the entire matched substring (including the
bearer/jwt=prefix) to***. That means strings likeAuthorization: bearer <jwt>will becomeAuthorization: ***(andCookie: jwt=<jwt>becomesCookie: ***), which contradicts the PR description/behavior examples that claim the prefix remains (e.g.,bearer ******,jwt=******). Consider using capturing groups and a replacement that preserves the prefix (e.g., capture the prefix and replace only the token portion).
#!/bin/bash
actions/instrument/job/inject_and_init.sh:1
- The replacement currently rewrites the entire matched substring (including the
bearer/jwt=prefix) to***. That means strings likeAuthorization: bearer <jwt>will becomeAuthorization: ***(andCookie: jwt=<jwt>becomesCookie: ***), which contradicts the PR description/behavior examples that claim the prefix remains (e.g.,bearer ******,jwt=******). Consider using capturing groups and a replacement that preserves the prefix (e.g., capture the prefix and replace only the token portion).
#!/bin/bash
actions/instrument/job/inject_and_init.sh:1
- Same as logs: these patterns replace the full
bearer <jwt>/jwt=<jwt>with***, dropping the prefix. If you want outputs likebearer ***andjwt=***(as described in the PR), update the regex + replacement to preserve the prefix via a captured group.
#!/bin/bash
actions/instrument/job/inject_and_init.sh:1
- These trace/span rules also drop the
bearer/jwt=prefix entirely by replacing the whole match with***. If the intended behavior is to keep the prefix visible and only mask the token, adjust to a capture + replacement approach consistently for bothspan.attributesandspan.name.
#!/bin/bash
actions/instrument/job/inject_and_init.sh:1
- These trace/span rules also drop the
bearer/jwt=prefix entirely by replacing the whole match with***. If the intended behavior is to keep the prefix visible and only mask the token, adjust to a capture + replacement approach consistently for bothspan.attributesandspan.name.
#!/bin/bash
moflwi
approved these changes
Mar 19, 2026
plengauer
added a commit
that referenced
this pull request
Mar 19, 2026
…collisions (#3149) Co-authored-by: Claude <242468646+Claude@users.noreply.github.com>
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.
The generic JWT pattern
[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}was previously disabled in job-level instrumentation because it masked hostnames likeapi.example.com. This restores JWT masking using prefix-specific patterns that only match tokens in authentication contexts.Changes
actions/instrument/job/inject_and_init.sh:(?i)bearer [A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}- case-insensitive ******jwt=[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}\.[A-Za-z0-9_-]{2,}- jwt= prefixBehavior
Masks:
Does not mask:
api.example.commy-service.prod.example.comOriginal prompt