mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Check CSP for inline event handlers (#36510)
This also ensures that document now reports all violations and we set the correct directive. With these changes, all `script-src-attr-elem` WPT tests pass. Part of #36437 Requires servo/rust-content-security-policy#3 to land first Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
parent
70b3e24816
commit
2a81987590
64 changed files with 58 additions and 569 deletions
|
@ -3450,12 +3450,15 @@ impl GlobalScope {
|
|||
|
||||
pub(crate) fn report_csp_violations(&self, violations: Vec<Violation>) {
|
||||
for violation in violations {
|
||||
let sample = match violation.resource {
|
||||
ViolationResource::Inline { .. } | ViolationResource::Url(_) => None,
|
||||
ViolationResource::TrustedTypePolicy { sample } => Some(sample),
|
||||
let (sample, resource) = match violation.resource {
|
||||
ViolationResource::Inline { .. } => (None, "inline".to_owned()),
|
||||
ViolationResource::Url(url) => (None, url.into()),
|
||||
ViolationResource::TrustedTypePolicy { sample } => {
|
||||
(Some(sample), "trusted-types-policy".to_owned())
|
||||
},
|
||||
};
|
||||
let report = CSPViolationReportBuilder::default()
|
||||
.resource("eval".to_owned())
|
||||
.resource(resource)
|
||||
.sample(sample)
|
||||
.effective_directive(violation.directive.name)
|
||||
.build(self);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue