-
Notifications
You must be signed in to change notification settings - Fork 166
Replace SecureHeaders CSP tooling with built in Rails tooling #5757
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
87585e5
Replace SecureHeaders CSP tooling with built in Rails tooling
jmhooper 46f02d8
add another TODO
jmhooper b5c72df
Merge branch 'main' into jmhooper-integrate-secure-headers
jmhooper bf7415b
move everything into 1 before action
jmhooper 7265ad9
use rails CSP tooling on document capture step
jmhooper 9002dd5
more like "TO DONE" amirite?
jmhooper 78b6b8e
fix secure header invocation in template
jmhooper be7dfee
TODO note
jmhooper 832c217
use opt out config
jmhooper 8ddd50c
Merge branch 'main' into jmhooper-integrate-secure-headers
jmhooper 29fdd54
add webpacker rules
jmhooper ad88fce
Been doing this over a decade and I swear to god how do I keep making…
jmhooper b6c2bb6
cleanup connect source
jmhooper 18e88a2
re-add unsafe-eval in development
jmhooper d868776
comment out unsafe-inline / unsafe-eval and see what CI does
jmhooper 5557487
clean up lint issue
jmhooper a688dba
put unsafe-eval back
jmhooper 884b92d
slim up delta between test/production CSP
jmhooper 0234e07
delint
jmhooper db74cdf
Merge branch 'main' into jmhooper-integrate-secure-headers
jmhooper 31915da
try using dev tools in test
jmhooper 10d9ee4
whooops
jmhooper b178ca4
delint
jmhooper 76ba500
test cleanup and re-add the remove CSP middleware
jmhooper 33d3831
fix last of the tests
jmhooper 2cafd98
Merge branch 'main' into jmhooper-integrate-secure-headers
jmhooper 6a923e8
cleanup from merge
jmhooper 0c96530
reducing diff noise
jmhooper 9fbe192
PULL THE LEVER, KRONK
jmhooper 89540b2
a little re-organizing
jmhooper 3ef6e29
whoops
jmhooper 786509e
Add the default nonce generator
jmhooper 2ae9357
some cleanup to break into a separate PR
jmhooper 98772e2
Merge branch 'main' into jmhooper-integrate-secure-headers
jmhooper 84f59ff
use the current_content_security_policy method
jmhooper 3ccad15
fix document capature template test
jmhooper 36d99d2
fix document capture concern issue
jmhooper c85e462
fix saml idp controller
jmhooper 2fe8529
delint
jmhooper 2332f79
mailer preview and unsafe inline
jmhooper c35cf30
Merge branch 'main' into jmhooper-integrate-secure-headers
jmhooper fb45906
i know how conditionals work
jmhooper c2ccd20
Merge branch 'main' into jmhooper-integrate-secure-headers
jmhooper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| module SecureHeadersHelper | ||
| def backwards_compatible_javascript_tag(*args, **opts, &block) | ||
| if FeatureManagement.rails_csp_tooling_enabled? | ||
| javascript_tag(*args, opts.merge(nonce: true), &block) | ||
| else | ||
| nonced_javascript_tag(*args, **opts, &block) | ||
| end | ||
| end | ||
|
|
||
| def add_document_capture_image_urls_to_csp(request, urls) | ||
| cleaned_urls = urls.compact.map do |url| | ||
| URI(url).tap { |uri| uri.query = nil }.to_s | ||
| end | ||
|
|
||
| if FeatureManagement.rails_csp_tooling_enabled? | ||
| add_document_capture_image_urls_to_csp_with_rails_csp_tooling(request, cleaned_urls) | ||
| else | ||
| add_document_capture_image_urls_to_csp_with_secure_headers(request, cleaned_urls) | ||
| end | ||
| end | ||
|
|
||
| def add_document_capture_image_urls_to_csp_with_secure_headers(request, urls) | ||
| SecureHeaders.append_content_security_policy_directives( | ||
| request, | ||
| connect_src: urls, | ||
| ) | ||
| end | ||
|
|
||
| def add_document_capture_image_urls_to_csp_with_rails_csp_tooling(request, urls) | ||
| policy = request.content_security_policy.clone | ||
| policy.connect_src(*policy.connect_src, *urls) | ||
| request.content_security_policy = policy | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| <!-- <%= t('notices.dap_participation') %> --> | ||
| <% dap_source = 'https://dap.digitalgov.gov/Universal-Federated-Analytics-Min.js?agency=GSA&subagency=TTS' %> | ||
| <%= nonced_javascript_tag({ src: dap_source, async: true, id: '_fed_an_ua_tag' }) do %> | ||
| <%= backwards_compatible_javascript_tag({ src: dap_source, async: true, id: '_fed_an_ua_tag' }) do %> | ||
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.