mirror of
https://github.com/lexmount/moli.git
synced 2026-09-26 16:01:30 +00:00
fix(csp): report eval source locations
This commit is contained in:
@@ -889,7 +889,7 @@ fn runtime_preparation_capture_uses_live_document_base_url() {
|
||||
#[test]
|
||||
fn runtime_preparation_only_captures_nonceable_script_nonces() {
|
||||
let url = Url::parse("https://example.test/").expect("test url should parse");
|
||||
let document = HtmlParser.parse(
|
||||
let document = HtmlParser::SCRIPTING_ENABLED.parse(
|
||||
url.clone(),
|
||||
"<!doctype html><html><head></head><body></body></html>".to_owned(),
|
||||
);
|
||||
|
||||
@@ -1312,22 +1312,3 @@ fn current_script_violation_location(
|
||||
let column_number = i32::try_from(frame.get_column()).unwrap_or_default().max(0);
|
||||
Some((source_file, line_number, column_number))
|
||||
}
|
||||
|
||||
fn current_script_violation_location(
|
||||
scope: &mut v8::PinScope<'_, '_>,
|
||||
) -> Option<(String, i32, i32)> {
|
||||
let stack = v8::StackTrace::current_stack_trace(scope, 1)?;
|
||||
let frame = stack.get_frame(scope, 0)?;
|
||||
let source_file = frame
|
||||
.get_script_name_or_source_url(scope)
|
||||
.map(|source| source.to_rust_string_lossy(scope))
|
||||
.map(|source| {
|
||||
crate::content_security_policy::content_security_policy_source_file_for_report(&source)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let line_number = i32::try_from(frame.get_line_number())
|
||||
.unwrap_or_default()
|
||||
.max(0);
|
||||
let column_number = i32::try_from(frame.get_column()).unwrap_or_default().max(0);
|
||||
Some((source_file, line_number, column_number))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user