use goliath_ocsf::schema::PathError as SchemaPathError;
use goliath_rule::PathError;
use goliath_sigma::YamlError;
use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum DefinitionError {
#[error(transparent)]
Yaml(#[from] YamlError),
#[error("kind `{kind}`: target `{target}`: {source}")]
Target {
kind: String,
target: String,
source: PathError,
},
#[error("kind `{kind}`: source path `{path}` has an empty segment")]
SourcePath {
kind: String,
path: String,
},
#[error("kind `{kind}`: targets `{first}` and `{second}` overlap")]
Overlap {
kind: String,
first: String,
second: String,
},
#[error("kind `{kind}`: `{target}` is set by {reason}, not by a field")]
Reserved {
kind: String,
target: String,
reason: &'static str,
},
#[error("kind `{kind}` has no `when` condition")]
Unconditional {
kind: String,
},
#[error("the definition has no kinds")]
NoKinds,
#[error("kind `{kind}`: OCSF {version} has no class {class_uid}")]
UnknownClass {
kind: String,
class_uid: u32,
version: &'static str,
},
#[error("kind `{kind}`: class `{class}` has no activity {activity_id}")]
UnknownActivity {
kind: String,
class: &'static str,
activity_id: u32,
},
#[error("kind `{kind}`: {source}")]
Attribute {
kind: String,
source: SchemaPathError,
},
#[error("kind `{kind}`: `{target}` holds {holds}, but the field writes {writes}")]
Type {
kind: String,
target: String,
holds: String,
writes: &'static str,
},
#[error("kind `{kind}`: {value} is not a defined value of `{target}`")]
UnknownValue {
kind: String,
target: String,
value: i64,
},
#[error("kind `{kind}`: `{target}` is inside an array, which a field cannot write into")]
WithinArray {
kind: String,
target: String,
},
}