getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
39.3k stars 4.21k forks source link

Advanced Data Scrubbing Rules Not Working #81253

Closed zsperske closed 3 days ago

zsperske commented 4 days ago

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

We have set up a data-scrubbing rule with the following regex [A-Z0-9-]{9,16} in order to replace UUIDS in error messages, a particular tag and error.value but it isn't working.

There might be some relationship with the fact that the issue we are trying to scrub is fired from the SentryOkHttpInterceptor which seems to use a different method than usual for reporting events to Sentry.

We also tried Sentry's built in UUID scrubbing rule and several variations of our regex.

Expected Result

We should see UUIDS replaced with a string of our choosing.

Actual Result

Can share privately.

Product Area

Ingestion and Filtering

Link

No response

DSN

No response

Version

No response

getsantry[bot] commented 4 days ago

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] commented 4 days ago

Routing to @getsentry/product-owners-ingestion-and-filtering for triage ⏲️

jjbayer commented 4 days ago

I can confirm that a simple config like

{
    "rules": {
        "project:0": {
            "type": "pattern",
            "pattern": "[A-Z0-9-]{9,16}",
            "redaction": {
                "method": "replace",
                "text": "my_replacement"
            }
        }
    },
    "applications": {
        "tags.url": [
            "project:0"
        ]
    }
}

scrubs a url tag {"tags": [["url", "http://example.com/1234-5678-FOO/bar"]]} successfully. Will double check whether the url tag is generated after PII scrubbing, in which case it would not get scrubbed.

jjbayer commented 4 days ago

@zsperske unfortunately the url tag is populated from the request.url field after PII scrubbing: https://github.com/getsentry/sentry/blob/a6126669cd93cf72f041942a4e4eca3e8dd80326/src/sentry/plugins/sentry_urls/models.py#L6-L9

Apply the rule to $request.url should work.

yuval-sentry commented 3 days ago

The suggested solution by @jjbayer is working. Thank you!!

zsperske commented 3 days ago

+1, thank you!