chore: Harden RVM implementation (#537)

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2026-01-14 06:07:31 +05:30
committed by GitHub
parent d626f75421
commit 740db8a0f5
16 changed files with 1685 additions and 1040 deletions
+25 -15
View File
@@ -70,10 +70,13 @@ impl Program {
match *rule_value {
Value::Number(_) => {
if data_value != &Value::Undefined {
return Err(crate::rvm::vm::VmError::RuleDataConflict(format!(
"Conflict: rule defines path '{}' but data also provides this path",
current_path.join("."),
)));
return Err(crate::rvm::vm::VmError::RuleDataConflict {
message: format!(
"Conflict: rule defines path '{}' but data also provides this path",
current_path.join("."),
),
pc: 0,
});
}
}
Value::Object(_) => {
@@ -84,17 +87,23 @@ impl Program {
current_path,
)?;
} else if data_value != &Value::Undefined {
return Err(crate::rvm::vm::VmError::RuleDataConflict(format!(
"Conflict: rule defines subpaths under '{}' but data provides a non-object value at this path",
current_path.join("."),
)));
return Err(crate::rvm::vm::VmError::RuleDataConflict {
message: format!(
"Conflict: rule defines subpaths under '{}' but data provides a non-object value at this path",
current_path.join("."),
),
pc: 0,
});
}
}
_ => {
return Err(crate::rvm::vm::VmError::RuleDataConflict(format!(
"Invalid rule tree structure at path '{}'",
current_path.join("."),
)));
return Err(crate::rvm::vm::VmError::RuleDataConflict {
message: format!(
"Invalid rule tree structure at path '{}'",
current_path.join("."),
),
pc: 0,
});
}
}
@@ -103,9 +112,10 @@ impl Program {
}
}
_ => {
return Err(crate::rvm::vm::VmError::RuleDataConflict(
"Rule tree root must be an object".to_string(),
));
return Err(crate::rvm::vm::VmError::RuleDataConflict {
message: "Rule tree root must be an object".to_string(),
pc: 0,
});
}
}