Add default parameter to content_security_policy_nonce for Rails compatibility#571
Draft
Copilot wants to merge 5 commits intofeature-7.2from
Draft
Add default parameter to content_security_policy_nonce for Rails compatibility#571Copilot wants to merge 5 commits intofeature-7.2from
Copilot wants to merge 5 commits intofeature-7.2from
Conversation
Copilot
AI
changed the title
[WIP] Fix content security policy nonce for scripts
Add default parameter to content_security_policy_nonce for Rails compatibility
Dec 17, 2025
…s compatibility Co-authored-by: fletchto99 <718681+fletchto99@users.noreply.github.com>
Co-authored-by: fletchto99 <718681+fletchto99@users.noreply.github.com>
Co-authored-by: fletchto99 <718681+fletchto99@users.noreply.github.com>
Co-authored-by: fletchto99 <718681+fletchto99@users.noreply.github.com>
6182fac to
bd6196a
Compare
6ac6e72 to
e5f347e
Compare
Contributor
|
I don't believe this approach will solve the general case, although it may fix cases where an implementer can explicitly call a parameterized version of We need to address the conflict by making sure that the nonce we provide will be used in a context where the application expects to call Rails' CSP. Alternatively there may be a mismatch in how we share the nonce value within CSP headers and how we use Idea: We may be able to use our initializer / activesupport hook to prepend our |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Third-party gems (e.g., GoodJob) call
content_security_policy_noncewithout parameters, expecting Rails' default behavior. SecureHeaders required an explicit:scriptor:styleparameter, causing these calls to returnniland nonces to be omitted from CSP headers.Changes
type = :scriptto_content_security_policy_nonceto match Rails'ActionController::ContentSecurityPolicybehavior:styleparameterExample
Backward compatible - existing code calling with explicit parameters unchanged.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
coveralls.io/usr/bin/ruby ruby -I lib:spec -r spec_helper spec/lib/secure_headers/view_helpers_spec.rb -j ACCEPT(dns block)/usr/bin/ruby ruby -I lib:spec -r spec_helper spec/lib/secure_headers/view_helpers_spec.rb(dns block)/home/REDACTED/.local/share/gem/ruby/3.2.0/bin/rspec rspec spec/lib/secure_headers/view_helpers_spec.rb(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
content_security_policy_noncecalls Rails method so CSP does not contain nonce #511💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.