Uh oh!
There was an error while loading. Please reload this page.
Add default parameter to content_security_policy_nonce for Rails compatibility - #571
Add default parameter to content_security_policy_nonce for Rails compatibility#571fletchto99 with Copilot wants to merge 10 commits into
Conversation
Do not join cookies with new like if they weren't before fix(middleware): ensure headers are wrapped with `Rack::Headers` Add `Rack::Headers` wrapping to middleware to prevent header manipulation issues. Added a test to verify cookies remain as an array when flagged if already in array format.
While this gem now uses lowercase headers, the Rails default configuration still defines non-lowercase headers. As a result, our Railtie will not remove those conflicting headers. This change ensures that we're accounting for both lowercase and non-lowercase default headers in Rails.
CSP3 more explicitly calls this out: > If path A consists of one character that is equal to the U+002F > SOLIDUS character (/) and path B is empty, return "Matches". A URL like `example.com/foo` will match a connect-src of `example.com`, as well as `example.com/`, so having two connect-srcs listed like this is redundant. fix: allow URIs with schema to have trailing slashes normalised Co-authored-by: Dusty Greif <dgreif@users.noreply.github.com>
Fix rake task file count output message
…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
bd6196aCompareI 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 |
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.