feat: complete rule evidence and frozen review fixtures
This commit is contained in:
1 parent
1f4e120a53
commit
344ef28870
27 files changed
+1992
-356
No files matched your search
+41
-5
@@ -89,11 +89,20 @@ impl ExecutionProjection {
|
||||
}
|
||||
for module in &wire.modules {
|
||||
if module.source_digest.len() != 64
|
||||
|| !module.source_digest.bytes().all(|byte| byte.is_ascii_hexdigit())
|
||||
|| !module
|
||||
.source_digest
|
||||
.bytes()
|
||||
.all(|byte| byte.is_ascii_hexdigit())
|
||||
{
|
||||
return Err(format!("模块 {} 的 source_digest 无效", module.id));
|
||||
}
|
||||
if module.relative_path.starts_with('/') || module.relative_path.contains("..") {
|
||||
let path = std::path::Path::new(&module.relative_path);
|
||||
if module.relative_path.is_empty()
|
||||
|| module.relative_path.contains('\\')
|
||||
|| !path
|
||||
.components()
|
||||
.all(|component| matches!(component, std::path::Component::Normal(_)))
|
||||
{
|
||||
return Err(format!("模块 {} 的 relative_path 不安全", module.id));
|
||||
}
|
||||
}
|
||||
@@ -124,7 +133,34 @@ fn walk_node(node: &Value) -> Box<dyn Iterator<Item = &Value> + '_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
Box::new(
|
||||
std::iter::once(node).chain(nested.into_iter().flat_map(|value| walk_node(value))),
|
||||
)
|
||||
Box::new(std::iter::once(node).chain(nested.into_iter().flat_map(|value| walk_node(value))))
|
||||
}
|
||||
|
||||
/// Spans with external effects known from public bound targets or indexed writes.
|
||||
pub(crate) fn effect_sites<'a>(
|
||||
function: &'a AnalysisFunction,
|
||||
calls: &'a [Value],
|
||||
) -> impl Iterator<Item = Span> + 'a {
|
||||
let writes = semantic_nodes(&function.body)
|
||||
.filter(|node| node["kind"] == "assign" && node["target"]["kind"] == "index");
|
||||
let external = calls.iter().filter(|call| {
|
||||
call["function"] == function.id.as_str()
|
||||
&& match call["state"].as_str() {
|
||||
Some("plugin") => true,
|
||||
Some("builtin") => call["target"].as_str().is_some_and(|target| {
|
||||
target.starts_with("resource.")
|
||||
|| matches!(target, "foreign.call" | "foreign.run")
|
||||
}),
|
||||
Some("function") => call["target"].as_str().is_some_and(|target| {
|
||||
target.starts_with("std:marqdo-stdlib@")
|
||||
&& (target.contains("::io.mq.md::io.")
|
||||
|| target.contains("::io/stream.mq.md::stream.")
|
||||
|| target.contains("::io/console.mq.md::console."))
|
||||
}),
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
writes
|
||||
.chain(external)
|
||||
.filter_map(crate::alignment::node_span)
|
||||
}
|
||||
Reference in new issue
Block a user