Skip to content

Commit

Permalink
Merge pull request #46 from chocolate-pie/allow-eval-by-default
Browse files Browse the repository at this point in the history
fix: Allow evaluation by default when `script-src` and `default-src` aren't passed
  • Loading branch information
notriddle authored Jul 28, 2024
2 parents 5635525 + 5be5cca commit fe4224c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ impl Directive {
AllowResult::Allows => CheckResult::Allowed,
AllowResult::DoesNotAllow => CheckResult::Blocked,
},
_ => CheckResult::Blocked
_ => CheckResult::Allowed
}
}
/// https://www.w3.org/TR/CSP/#can-compile-wasm-bytes
Expand All @@ -1009,7 +1009,7 @@ impl Directive {
AllowResult::Allows => CheckResult::Allowed,
AllowResult::DoesNotAllow => CheckResult::Blocked
},
_ => CheckResult::Blocked
_ => CheckResult::Allowed
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,5 +471,12 @@ test_should_js_wasm_evaluation_be_blocked!{
disposition: Report,
kind: is_wasm_evaluation_allowed,
result: Allowed
),
(
name: eval_javascript_works_if_multiple_policies_were_passed,
policy: "script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self';",
disposition: Enforce,
kind: is_js_evaluation_allowed,
result: Allowed
)
}

0 comments on commit fe4224c

Please sign in to comment.