Skip to content

Scrub bug report text before Sentry ingest#383

Open
silentgeckoaudit3801 wants to merge 5 commits into
Quantarq:mainfrom
silentgeckoaudit3801:security/scrub-sentry-bug-report-199
Open

Scrub bug report text before Sentry ingest#383
silentgeckoaudit3801 wants to merge 5 commits into
Quantarq:mainfrom
silentgeckoaudit3801:security/scrub-sentry-bug-report-199

Conversation

@silentgeckoaudit3801

Copy link
Copy Markdown

Summary

  • add a bounded html.escape-based scrubber for user-controlled Sentry text
  • add a Sentry before_send hook that re-scrubs bug-report context and event extra descriptions before persistence
  • send only scrubbed wallet/description values from /api/save-bug-report
  • add static coverage for endpoint wiring, hook registration, escaping, and truncation markers

Testing

  • Not run locally: this workspace avoids installing/running project dependencies or invasive toolchains.
  • Added static regression checks under quantara/web_app/tests/test_sentry_bug_report_scrub_static.py for CI.

Closes #199



def test_bug_report_endpoint_sends_only_scrubbed_description_to_sentry():
assert "safe_description = scrub_user_text_for_sentry(report.bug_description)" in USER_API

def test_bug_report_endpoint_sends_only_scrubbed_description_to_sentry():
assert "safe_description = scrub_user_text_for_sentry(report.bug_description)" in USER_API
assert 'extras={"description": safe_description}' in USER_API
def test_bug_report_endpoint_sends_only_scrubbed_description_to_sentry():
assert "safe_description = scrub_user_text_for_sentry(report.bug_description)" in USER_API
assert 'extras={"description": safe_description}' in USER_API
assert '"description": report.bug_description' not in USER_API
assert "safe_description = scrub_user_text_for_sentry(report.bug_description)" in USER_API
assert 'extras={"description": safe_description}' in USER_API
assert '"description": report.bug_description' not in USER_API
assert 'extras={"description": report.bug_description}' not in USER_API


def test_sentry_before_send_hook_is_registered():
assert "from web_app.api.sentry_hooks import before_send" in MAIN_API


def test_before_send_enforces_scrub_on_context_and_extra_payloads():
assert 'BUG_REPORT_CONTEXT = "bug_report"' in HOOKS

def test_before_send_enforces_scrub_on_context_and_extra_payloads():
assert 'BUG_REPORT_CONTEXT = "bug_report"' in HOOKS
assert 'DESCRIPTION_FIELD = "description"' in HOOKS
def test_before_send_enforces_scrub_on_context_and_extra_payloads():
assert 'BUG_REPORT_CONTEXT = "bug_report"' in HOOKS
assert 'DESCRIPTION_FIELD = "description"' in HOOKS
assert 'contexts.get(BUG_REPORT_CONTEXT)' in HOOKS
assert 'BUG_REPORT_CONTEXT = "bug_report"' in HOOKS
assert 'DESCRIPTION_FIELD = "description"' in HOOKS
assert 'contexts.get(BUG_REPORT_CONTEXT)' in HOOKS
assert 'event.get("extra")' in HOOKS
assert 'DESCRIPTION_FIELD = "description"' in HOOKS
assert 'contexts.get(BUG_REPORT_CONTEXT)' in HOOKS
assert 'event.get("extra")' in HOOKS
assert "scrub_user_text_for_sentry(" in HOOKS No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sanitise user content fed to Sentry

2 participants