mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
chore: Harden RVM implementation (#537)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
d626f75421
commit
740db8a0f5
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user