`EventScrubber` doesn't scrub a request body that's a top level JSON array
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Riproduci il problema con il repro.py fornito, quindi esamina EventScrubber.scrub_request, scrub_dict e scrub_list per tracciare come vengono gestiti i dati della richiesta. Usa i test esistenti dello scrubber oppure aggiungi la copertura per un array di primo livello; il lavoro è completato quando i valori annidati di password o api_key vengono filtrati nei body degli array proprio come nei body degli oggetti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.69.2 (also on master at 494ecb3)
Steps to Reproduce
When a request body parses to a top level JSON array, nothing in it gets scrubbed. The same secrets in an object body are filtered normally. No event_scrubber argument, no _experiments data collection config, default max_request_body_size. The integration and the transport in the snippet are only there to catch the event.
A top level array is the usual shape for a bulk endpoint, something like POST /api/v1/users/bulk with a list of records. If those records carry a password or an api_key, they leave the process in the clear. A team that spot checks a single object endpoint sees scrubbing work fine, so there's nothing to tip them off.
Python 3.13.15, Flask 3.1.3, sentry-sdk 2.69.2. Save this as repro.py and run it.
import json
import logging
import sentry_sdk
from flask import Flask
from sentry_sdk.integrations.flask import FlaskIntegration
events = []
class Capture(sentry_sdk.transport.Transport):
def capture_envelope(self, envelope):
for item in envelope.items:
if item.headers.get("type") == "event":
events.append(item.payload.json)
sentry_sdk.init(
dsn="https://public@example.com/1",
integrations=[FlaskIntegration()],
transport=Capture(),
)
app = Flask(__name__)
app.logger.disabled = True
logging.getLogger("werkzeug").disabled = True
@app.route("/bulk", methods=["POST"])
def bulk():
raise ValueError("boom")
@app.route("/single", methods=["POST"])
def single():
raise ValueError("boom")
client = app.test_client()
client.post("/bulk", json=[{"user": "a", "password": "hunter2"}])
client.post("/single", json={"user": "a", "password": "hunter2"})
sentry_sdk.get_client().close()
print("array body :", json.dumps(events[0]["request"]["data"]))
print("object body:", json.dumps(events[1]["request"]["data"]))
Expected Result
The array body should come out filtered the same way the object body does:
array body : [{"password": "[Filtered]", "user": "a"}]
object body: {"password": "[Filtered]", "user": "a"}
Actual Result
array body : [{"password": "hunter2", "user": "a"}]
object body: {"password": "[Filtered]", "user": "a"}
EventScrubber.scrub_request calls scrub_dict on event["request"]["data"], and scrub_dict returns immediately when what it's given isn't a dict, so a list body stops scrubbing before it starts. The class already ships scrub_list, whose docstring says it walks a list and any nested lists and calls scrub_dict on every dictionary it finds, but it's never called on the request body.
This is separate from #7542, which is about how denylist keys are matched. Here the keys never get looked at at all. I have a fix and tests ready if you want a PR.
- Lingua principale
- Python
- Stelle
- 2.2k
- Fork
- 672
- Merge medio
- 23h 14m
- PR unite (30g)
- 218
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/sentry-python
-
Python
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
getsentry/sentry-python#6992 · 1 commento ·
-
Improvement Python
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
getsentry/sentry-python#6970 · 1 commento ·
-
Bug Python
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
getsentry/sentry-python#6504 · 1 commento ·
-
Improvement Python Spans
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
getsentry/sentry-python#5833 · 1 commento ·
-
Improvement Python Spans
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
getsentry/sentry-python#5832 · 1 commento ·
Tutte le issue di getsentry/sentry-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ClickHouse/clickhouse-connect#1057 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
open-telemetry/sig-end-user#406 ·
-
bug ci good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100