Skip to main content

verifyos_cli/rules/
core.rs

1use miette::Diagnostic;
2
3#[derive(Debug, thiserror::Error, Diagnostic)]
4pub enum RuleError {
5    #[error("Missing Privacy Manifest")]
6    #[diagnostic(
7        code(verifyos::privacy::missing_manifest),
8        help("Apple requires a PrivacyInfo.xcprivacy file for apps. Please include one in your app bundle.")
9    )]
10    MissingPrivacyManifest,
11
12    #[error("Missing Camera Usage Description")]
13    #[diagnostic(
14        code(verifyos::permissions::missing_camera_desc),
15        help("The Info.plist is missing the NSCameraUsageDescription key.")
16    )]
17    MissingCameraUsageDescription,
18
19    #[error(transparent)]
20    #[diagnostic(transparent)]
21    Entitlements(#[from] crate::rules::entitlements::EntitlementsError),
22}
23
24#[derive(Debug)]
25pub enum Severity {
26    Error,
27    Warning,
28    Info,
29}
30
31#[derive(Debug)]
32pub struct RuleResult {
33    pub success: bool,
34}
35
36// Stub for now. Will hold the path to the app and the parsed Info.plist
37pub struct ArtifactContext<'a> {
38    pub app_bundle_path: &'a std::path::Path,
39    pub info_plist: Option<&'a crate::parsers::plist_reader::InfoPlist>,
40}
41
42pub trait AppStoreRule {
43    fn id(&self) -> &'static str;
44    fn name(&self) -> &'static str;
45    fn severity(&self) -> Severity;
46    fn evaluate(&self, artifact: &ArtifactContext) -> Result<RuleResult, RuleError>;
47}