Skip to content

redaction processor does not seem to redact attributes of span event #36633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
qrli opened this issue Dec 3, 2024 · 9 comments · Fixed by #38288
Closed

redaction processor does not seem to redact attributes of span event #36633

qrli opened this issue Dec 3, 2024 · 9 comments · Fixed by #38288
Assignees
Labels
bug Something isn't working good first issue Good for newcomers priority:p2 Medium processor/redaction Redaction processor

Comments

@qrli
Copy link

qrli commented Dec 3, 2024

Component(s)

processor/redaction

What happened?

Description

We are using allow_all_keys: true and expects all blocked values are redacted. However, we found some data which should have been redacted got through. After investigation, I found the data failed to be redacted are in span events.

Steps to Reproduce

Put some value to be redacted in attributes of span events, and try to use redaction processor to redact it.

Expected Result

The blocked values are successfully redacted from all traces/logs.

Actual Result

The blocked values in span events leaked through redaction processor.

Collector version

0.111.0

Environment information

Environment

OS: Ubuntu 22.04
Compiler(if manually compiled): (e.g., "go 14.2")

OpenTelemetry Collector configuration

exporters:    
    otlp:
      endpoint: tempo.xxx.svc:4317
      sending_queue:
        queue_size: 5000
      tls:
        insecure: true
  receivers:
    otlp:
      protocols:
        grpc:
          endpoint: 0.0.0.0:4317
        http:
          endpoint: 0.0.0.0:4318
  processors:
    redaction:
      allow_all_keys: true
      blocked_values:
        - "eyJhbGci[a-zA-Z0-9._-]+"  # jwt tokens
        - "(amqps|mongodb)://[^@]+@" # mq & mongo connection string
        - '[\w\.\-]+(@|%40)[\w\.\-]+' # email
      summary: debug
  service:
    pipelines:
      traces:
        exporters:
          - otlp
        receivers:
          - otlp
        processors: 
          - redaction

Log output

No response

Additional context

No response

@qrli qrli added bug Something isn't working needs triage New item requiring triage labels Dec 3, 2024
@github-actions github-actions bot added the processor/redaction Redaction processor label Dec 3, 2024
Copy link
Contributor

github-actions bot commented Dec 3, 2024

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@dmitryax
Copy link
Member

dmitryax commented Dec 3, 2024

Hi @qrli. Thanks for reporting! It's clearly a bug. Do you have a chance contribute a fix?

@dmitryax dmitryax added help wanted Extra attention is needed good first issue Good for newcomers and removed needs triage New item requiring triage labels Dec 3, 2024
@mx-psi mx-psi added the priority:p2 Medium label Dec 3, 2024
@qrli
Copy link
Author

qrli commented Dec 4, 2024

Hi @qrli. Thanks for reporting! It's clearly a bug. Do you have a chance contribute a fix?

I'd like to but unfortunately Go is not in my skill set.

@VihasMakwana
Copy link
Contributor

I'll find some time and fix this later this week. In the meantime, if anyone else wants to dive into the otel work, just let me know and I can assign it to them.

@VihasMakwana VihasMakwana self-assigned this Dec 4, 2024
@VihasMakwana
Copy link
Contributor

@qrli I tried to reproduce this with a couple of different kv pairs, here's my obervation:

  • For email and jwt based tokens, the regex is able to capture entire string and it works as expected.
  • For amqps\mongodb URIs, the regex is able to partially capture the string and as a result it doesn't mask the entire string.
    • Is this the issue you're facing?
    • If not, can you send a sample log and expected output?

@qrli
Copy link
Author

qrli commented Dec 9, 2024

@VihasMakwana No, the issue is not about my regex for redaction - I just provided them for example.
The issue is about the redaction does not apply to event attributes of spans.
I can see from the code here:


It loops through all attributes of a span, but it does not touch any span events, so event attributes are not redacted.

So I think the fix should be simply adding a nested loop of span events and process each event attribute.

@qrli
Copy link
Author

qrli commented Jan 6, 2025

The issue is still marked as waiting for author. Is there anything more you need me to provide?

@mx-psi
Copy link
Member

mx-psi commented Jan 7, 2025

I think we are not waiting for author anymore, we just need to land the fix :)

@VihasMakwana
Copy link
Contributor

VihasMakwana commented Jan 7, 2025

I was working on the fix and then was on holidays for new yeas. Sorry for inconvenience.

I'll open up a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers priority:p2 Medium processor/redaction Redaction processor
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants