Skip to content

Commit

Permalink
Added setting to config to redact data of all types
Browse files Browse the repository at this point in the history
The redaction is done based on its AsString value
rather than SDR. This is based on this issue:
#36684
  • Loading branch information
Jonathan Wilson committed Jan 13, 2025
1 parent bc20ac9 commit 9a4dda3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions processor/redactionprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ processors:
# Any keys in this list are allowed so they don't need to be in both lists.
ignored_keys:
- safe_attribute
# redact_all_types will check incoming fields for sensitive data based on their AsString() representation. This allows the processor to redact sensitive data from ints. This is useful for redacting credit card numbers
redact_all_types: true
# blocked_values is a list of regular expressions for blocking values of
# allowed span attributes. Values that match are masked
blocked_values:
Expand Down
5 changes: 5 additions & 0 deletions processor/redactionprocessor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ type Config struct {
// without being changed or removed.
IgnoredKeys []string `mapstructure:"ignored_keys"`

// RedactAllTypes is a flag to allow the processor to redact all span
// attribute values including those that are not strings. By default
// it is false and only string values are redacted.
RedactAllTypes bool `mapstructure:"redact_all_types"`

// BlockedValues is a list of regular expressions for blocking values of
// allowed span attributes. Values that match are masked
BlockedValues []string `mapstructure:"blocked_values"`
Expand Down
3 changes: 3 additions & 0 deletions processor/redactionprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ func (s *redaction) processAttrs(_ context.Context, attributes pcommon.Map) {

// Mask any blocked values for the other attributes
strVal := value.Str()
if s.config.RedactAllTypes {
strVal = value.AsString()
}
var matched bool
for _, compiledRE := range s.blockRegexList {
match := compiledRE.MatchString(strVal)
Expand Down

0 comments on commit 9a4dda3

Please sign in to comment.