-
Notifications
You must be signed in to change notification settings - Fork 2k
fix: Hardcoded CSP Nonce Tags in ResponseTrait #9937
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
base: develop
Are you sure you want to change the base?
fix: Hardcoded CSP Nonce Tags in ResponseTrait #9937
Conversation
paulbalandan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests don't make sense. You should be testing instead the behavior when the response is sent when CSP is not enabled.
| $this->{$this->directives[$directive]} = []; | ||
| } | ||
|
|
||
| public function clearNoncePlaceholders(string $text): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This can go instead in the generateNonces method in the preg_replace_callback so that if $CSPEnabled is false it just returns
''. - In
buildHeaders, if CSP is disabled, just return - In ResponseTrait, remove the conditional and retain the finalize call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| $this->assertNotContains('report-to default', $directives); | ||
| } | ||
|
|
||
| public function testClearNoncePlaceholdersWithDefaultTags(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these tests down and replace with the ones you have in ResponseTest but tailor it to be like in the majority of the tests here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com>
97b1297 to
65b1a04
Compare
Description
This PR fixes #9935.
Created one method in
system/HTTP/ContentSecurityPolicy.phpto clear all nonce placeholders.Checklist: