fix(secure-headers): keep CSP callbacks scoped to their header - #5147
Merged
yusukebe merged 3 commits intoJul 24, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5147 +/- ##
==========================================
+ Coverage 79.04% 79.07% +0.03%
==========================================
Files 154 154
Lines 10779 10777 -2
Branches 2256 2254 -2
==========================================
+ Hits 8520 8522 +2
+ Misses 2259 2255 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
yusukebe
approved these changes
Jul 24, 2026
1 task
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.
Using a nonce in one CSP mode currently breaks when both
contentSecurityPolicyandcontentSecurityPolicyReportOnlyare set.getCSPDirectives()returns a callback that handles both CSP headers. If the other policy is static, its value has already been turned into a string, so that callback reachesclone.join()with a string and the request ends in a 500 response.This change gives each callback the header name it belongs to and leaves the other CSP header alone. The added tests cover a static enforced policy with a report-only nonce, and nonce callbacks in both policies.