cedar_policy_validator/diagnostics/
validation_warnings.rsmacro_rules! impl_diagnostic_warning {
() => {
fn severity(&self) -> Option<miette::Severity> {
Some(miette::Severity::Warning)
}
};
}
use cedar_policy_core::{ast::PolicyID, impl_diagnostic_from_source_loc_opt_field, parser::Loc};
use miette::Diagnostic;
use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Error, Eq, Hash)]
#[error("for policy `{policy_id}`, string `\"{string}\"` contains mixed scripts")]
pub struct MixedScriptString {
pub source_loc: Option<Loc>,
pub policy_id: PolicyID,
pub string: String,
}
impl Diagnostic for MixedScriptString {
impl_diagnostic_from_source_loc_opt_field!(source_loc);
impl_diagnostic_warning!();
}
#[derive(Debug, Clone, PartialEq, Error, Eq, Hash)]
#[error("for policy `{policy_id}`, string `\"{string}\"` contains BIDI control characters")]
pub struct BidiCharsInString {
pub source_loc: Option<Loc>,
pub policy_id: PolicyID,
pub string: String,
}
impl Diagnostic for BidiCharsInString {
impl_diagnostic_from_source_loc_opt_field!(source_loc);
impl_diagnostic_warning!();
}
#[derive(Debug, Clone, PartialEq, Error, Eq, Hash)]
#[error("for policy `{policy_id}`, identifier `{id}` contains BIDI control characters")]
pub struct BidiCharsInIdentifier {
pub source_loc: Option<Loc>,
pub policy_id: PolicyID,
pub id: String,
}
impl Diagnostic for BidiCharsInIdentifier {
impl_diagnostic_from_source_loc_opt_field!(source_loc);
impl_diagnostic_warning!();
}
#[derive(Debug, Clone, PartialEq, Error, Eq, Hash)]
#[error("for policy `{policy_id}`, identifier `{id}` contains mixed scripts")]
pub struct MixedScriptIdentifier {
pub source_loc: Option<Loc>,
pub policy_id: PolicyID,
pub id: String,
}
impl Diagnostic for MixedScriptIdentifier {
impl_diagnostic_from_source_loc_opt_field!(source_loc);
impl_diagnostic_warning!();
}
#[derive(Debug, Clone, PartialEq, Error, Eq, Hash)]
#[error("for policy `{policy_id}`, identifier `{id}` contains characters that fall outside of the General Security Profile for Identifiers")]
pub struct ConfusableIdentifier {
pub source_loc: Option<Loc>,
pub policy_id: PolicyID,
pub id: String,
}
impl Diagnostic for ConfusableIdentifier {
impl_diagnostic_from_source_loc_opt_field!(source_loc);
impl_diagnostic_warning!();
}
#[derive(Debug, Clone, PartialEq, Error, Eq, Hash)]
#[error("for policy `{policy_id}`, policy is impossible: the policy expression evaluates to false for all valid requests")]
pub struct ImpossiblePolicy {
pub source_loc: Option<Loc>,
pub policy_id: PolicyID,
}
impl Diagnostic for ImpossiblePolicy {
impl_diagnostic_from_source_loc_opt_field!(source_loc);
impl_diagnostic_warning!();
}