mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Locked down supported values in default rule.
Only scalars, composites and comprehensions containing scalars are supported. This will be changed as OPA fixes bug with default values Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
@@ -15,7 +15,6 @@ pub struct Parser<'source> {
|
||||
line: u16,
|
||||
end: u16,
|
||||
future_keywords: BTreeMap<&'source str, Span<'source>>,
|
||||
in_default_value: bool,
|
||||
}
|
||||
|
||||
const FUTURE_KEYWORDS: [&str; 4] = ["contains", "every", "if", "in"];
|
||||
@@ -31,7 +30,6 @@ impl<'source> Parser<'source> {
|
||||
line: 0,
|
||||
end: 0,
|
||||
future_keywords: BTreeMap::new(),
|
||||
in_default_value: false,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -550,22 +548,6 @@ impl<'source> Parser<'source> {
|
||||
}
|
||||
}
|
||||
|
||||
if self.in_default_value {
|
||||
if let Some((kind, span)) = match &term {
|
||||
Expr::Var(v) => Some(("var", v)),
|
||||
Expr::RefDot { span, .. } => Some(("ref", span)),
|
||||
Expr::Call { span, .. } => Some(("call", span)),
|
||||
Expr::RefBrack { span, .. } => Some(("ref", span)),
|
||||
_ => None,
|
||||
} {
|
||||
return Err(self.source.error(
|
||||
span.line,
|
||||
span.col,
|
||||
format!("invalid {kind} in default value").as_str(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(term)
|
||||
}
|
||||
|
||||
@@ -1418,9 +1400,7 @@ impl<'source> Parser<'source> {
|
||||
|
||||
// todo: Rego errors for binary expressions here, but they are
|
||||
// somehow valid in a comprehension
|
||||
self.in_default_value = true;
|
||||
let value = self.parse_term()?;
|
||||
self.in_default_value = false;
|
||||
span.end = self.end;
|
||||
Ok(Rule::Default {
|
||||
span,
|
||||
|
||||
Reference in New Issue
Block a user