Skip to content

Generate Security Header Endpoint with Sentry.csp_report_uri from DSN#1507

Merged
st0012 merged 4 commits intomasterfrom
implement-#1499
Aug 16, 2021
Merged

Generate Security Header Endpoint with Sentry.csp_report_uri from DSN#1507
st0012 merged 4 commits intomasterfrom
implement-#1499

Conversation

@st0012
Copy link
Copy Markdown
Contributor

@st0012 st0012 commented Jul 17, 2021

Sentry requires a separated Security Header Endpoint for Security Policy Reporting. But the endpoint's major components like project id, public key or host are all identical with the SDK's DSN. Also, the additional environment or release information are also obtained by the SDK.

So this PR adds a helper Sentry.csp_report_uri to generate the Security Header Endpoint for users who report CSP events to the same project as DSN's (as suggested in #1499). It'll reduce the number of values they need to manage.

Take Rails' csp configuration for example:

Without helper

Rails.application.config.content_security_policy do |policy|
  policy.report_uri ENV["SENTRY_CSP_URI"]
end

With the helper

Rails.application.config.content_security_policy do |policy|
  policy.report_uri Sentry.csp_report_uri
end

@st0012 st0012 added this to the 4.7.0 milestone Jul 17, 2021
@st0012 st0012 self-assigned this Jul 17, 2021
@st0012 st0012 requested a review from rhcarvalho July 17, 2021 07:26
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 17, 2021

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.74%. Comparing base (952e9c9) to head (f870670).
⚠️ Report is 767 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1507      +/-   ##
==========================================
+ Coverage   98.19%   98.74%   +0.54%     
==========================================
  Files         220      125      -95     
  Lines       10718     6921    -3797     
==========================================
- Hits        10525     6834    -3691     
+ Misses        193       87     -106     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@st0012 st0012 changed the title Add Sentry.csp_report_uri Generate Security Header Endpoint with Sentry.csp_report_uri from DSN Jul 17, 2021
Copy link
Copy Markdown
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally I find it okay to add this. Would consider adding some escaping code instead of plain string concatenation.

@st0012 st0012 requested a review from rhcarvalho August 4, 2021 13:21
@st0012 st0012 merged commit 929b718 into master Aug 16, 2021
@st0012 st0012 deleted the implement-#1499 branch August 16, 2021 03:57
@st0012 st0012 mentioned this pull request Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants