Skip to content
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

feat(pymongo): add PyMongo integration #1590

Merged
merged 13 commits into from
Nov 4, 2022
Prev Previous commit
Next Next commit
Better way of checking for update db command
  • Loading branch information
antonpirker authored and Agalin committed Nov 4, 2022
commit 2e4251cf1f2832c8e40d5158b9a2b4497429b268
11 changes: 7 additions & 4 deletions sentry_sdk/integrations/pymongo.py
Original file line number Diff line number Diff line change
@@ -44,10 +44,13 @@
def _strip_pii(command):
# type: (Dict[str, Any]) -> Dict[str, Any]
for idx, key in enumerate(command):
if key in SAFE_COMMAND_ATTRIBUTES or (key == "update" and idx == 0):
# Skip if safe key, or the is "update" but not on the first place
# "update" as the first key is safe because it is the mongo db command.
# "update" as a later key (for ex in the findAndModify command) is not save and should be stripped of PII.
if key in SAFE_COMMAND_ATTRIBUTES:
# Skip if safe key
continue

if key == "update" and "findAndModify" not in command:
# Also skip "update" db command because it is save.
# There is also an "update" key in the "findAndModify" command, which is NOT safe!
continue

if key == "documents":