Skip to main content

verifyos_cli/rules/
privacy.rs

1use crate::rules::core::{
2    AppStoreRule, ArtifactContext, RuleCategory, RuleError, RuleReport, RuleStatus, Severity,
3};
4
5pub struct MissingPrivacyManifestRule;
6
7impl AppStoreRule for MissingPrivacyManifestRule {
8    fn id(&self) -> &'static str {
9        "RULE_PRIVACY_MANIFEST"
10    }
11
12    fn name(&self) -> &'static str {
13        "Missing Privacy Manifest"
14    }
15
16    fn category(&self) -> RuleCategory {
17        RuleCategory::Privacy
18    }
19
20    fn severity(&self) -> Severity {
21        Severity::Error
22    }
23
24    fn recommendation(&self) -> &'static str {
25        "Add a PrivacyInfo.xcprivacy file to the app bundle."
26    }
27
28    fn evaluate(&self, artifact: &ArtifactContext) -> Result<RuleReport, RuleError> {
29        if artifact
30            .bundle_relative_file("PrivacyInfo.xcprivacy")
31            .is_none()
32        {
33            return Ok(RuleReport {
34                status: RuleStatus::Fail,
35                message: Some("Missing PrivacyInfo.xcprivacy".to_string()),
36                evidence: Some(format!(
37                    "Not found at {}",
38                    artifact
39                        .app_bundle_path
40                        .join("PrivacyInfo.xcprivacy")
41                        .display()
42                )),
43            });
44        }
45
46        Ok(RuleReport {
47            status: RuleStatus::Pass,
48            message: None,
49            evidence: None,
50        })
51    }
52}