-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: sentry pii #615
fix: sentry pii #615
Conversation
WalkthroughThis change updates the Sentry integration in Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Sentry
participant _sanitize_dict
participant SentryBreadcrumb
Client->>Sentry: Send event data
Sentry->>_sanitize_dict: Sanitize request and extra fields
_sanitize_dict-->>Sentry: Return sanitized data
Sentry->>Client: Return sanitized event
Client->>Sentry: Send breadcrumb data
Sentry->>SentryBreadcrumb: Process breadcrumb
SentryBreadcrumb-->>Sentry: Return sanitized breadcrumb
Sentry->>Client: Return sanitized breadcrumb
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Coverage Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
fyle_intacct_api/sentry.py (3)
10-15
: Centralize sensitive fields.Defining a single source of truth for sensitive fields is a solid approach. Consider auditing the codebase to ensure that all potential PII or security-sensitive fields (e.g., 'token') are consistently included here if necessary.
16-39
: Robust recursive sanitization.Your
_sanitize_dict
function correctly handles nested dicts and lists. However, cyclical references in the data could cause infinite recursion. If you expect potentially self-referential data structures, consider adding a visited-set check to avoid recursion errors.def _sanitize_dict(data: Dict[str, Any], visited=None) -> Dict[str, Any]: if visited is None: + visited = set() + if id(data) in visited: + return {} + visited.add(id(data)) sanitized = {} ...
67-76
: Combine conditional checks for brevity (static analysis hint).To streamline exception checks, you can merge the two branches into a single condition:
if 'exc_info' in hint: exc_type, exc_value, tb = hint['exc_info'] - if isinstance(exc_value, gevent.GreenletExit): - return None - elif getattr(exc_value, 'args', [None])[0] in ['Error: 502']: + if isinstance(exc_value, gevent.GreenletExit) or getattr(exc_value, 'args', [None])[0] in ['Error: 502']: return None🧰 Tools
🪛 Ruff (0.8.2)
72-75: Combine
if
branches using logicalor
operatorCombine
if
branches(SIM114)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
fyle_intacct_api/sentry.py
(1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
fyle_intacct_api/sentry.py
72-75: Combine if
branches using logical or
operator
Combine if
branches
(SIM114)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: pytest
- GitHub Check: pytest
🔇 Additional comments (5)
fyle_intacct_api/sentry.py (5)
2-4
: Imports look good.These additions are necessary for type annotations and handling with gevent. No concerns here.
44-47
: Sentry initialization aligns with PII concerns.Turning off default PII and specifying in-app folders properly addresses privacy requirements. This matches the PR objective to reduce exposure of sensitive information in Sentry.
Also applies to: 50-51, 53-63
78-91
: Request headers and body sanitization.Filtering sensitive headers and recursively sanitizing request data is correct and prevents accidental PII leakage. Nicely done.
92-103
: Strict user field filtering.Restricting the user object to only contain the 'id' field effectively curtails PII from being transmitted. This is consistent with the privacy goals of the PR.
106-117
: Breadcrumb filtering.Dropping breadcrumbs for certain categories and sanitizing any embedded data aligns well with the product's PII-safe stance. This feature is suitably implemented.
Co-authored-by: Rushi <[email protected]>
Description
fix: pii
Clickup
https://app.clickup.com/t/86cxygv7h
Summary by CodeRabbit
New Features
Refactor