Skip to main content

verifyos_cli/rules/
core.rs

1use miette::Diagnostic;
2use serde::{Deserialize, Serialize};
3
4pub const RULESET_VERSION: &str = "0.1.0";
5
6#[derive(Debug, thiserror::Error, Diagnostic)]
7pub enum RuleError {
8    #[error(transparent)]
9    #[diagnostic(transparent)]
10    Entitlements(#[from] crate::rules::entitlements::EntitlementsError),
11
12    #[error(transparent)]
13    #[diagnostic(transparent)]
14    Provisioning(#[from] crate::parsers::provisioning_profile::ProvisioningError),
15}
16
17#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
18pub enum Severity {
19    Error,
20    Warning,
21    Info,
22}
23
24#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
25pub enum RuleStatus {
26    Pass,
27    Fail,
28    Error,
29    Skip,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33pub struct RuleReport {
34    pub status: RuleStatus,
35    pub message: Option<String>,
36    pub evidence: Option<String>,
37}
38
39#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
40pub enum RuleCategory {
41    Privacy,
42    Signing,
43    Bundling,
44    Entitlements,
45    Ats,
46    ThirdParty,
47    Permissions,
48    Metadata,
49    Other,
50}
51
52// Stub for now. Will hold the path to the app and the parsed Info.plist
53pub struct ArtifactContext<'a> {
54    pub app_bundle_path: &'a std::path::Path,
55    pub info_plist: Option<&'a crate::parsers::plist_reader::InfoPlist>,
56}
57
58pub trait AppStoreRule {
59    fn id(&self) -> &'static str;
60    fn name(&self) -> &'static str;
61    fn category(&self) -> RuleCategory;
62    fn severity(&self) -> Severity;
63    fn recommendation(&self) -> &'static str;
64    fn evaluate(&self, artifact: &ArtifactContext) -> Result<RuleReport, RuleError>;
65}