|
| 1 | +package securitysuite_test |
| 2 | +import rego.v1 |
| 3 | +import data.securitysuite |
| 4 | +import data.utils.key.TestResult |
| 5 | +import data.utils.key.PASS |
| 6 | + |
| 7 | +DefaultAntiMalwarePolicy := { |
| 8 | + "Identity": "Default", |
| 9 | + "EnableFileFilter": false, |
| 10 | + "FileTypes": [], |
| 11 | + "ZapEnabled": false, |
| 12 | +} |
| 13 | + |
| 14 | +StandardAntiMalwarePolicy := { |
| 15 | + "Identity": "Standard Preset Security Policy", |
| 16 | + "EnableFileFilter": true, |
| 17 | + "FileTypes": ["exe", "cmd", "vbe"], |
| 18 | + "ZapEnabled": true, |
| 19 | +} |
| 20 | + |
| 21 | +StandardProtectionPolicyRule := { |
| 22 | + "Identity": "Standard Preset Security Policy", |
| 23 | + "State": "Enabled", |
| 24 | + "SentTo": null, |
| 25 | + "SentToMemberOf": null, |
| 26 | + "RecipientDomainIs": null, |
| 27 | +} |
| 28 | + |
| 29 | +CustomAntiMalwareRule := { |
| 30 | + "State": "Enabled", |
| 31 | + "Priority": 0, |
| 32 | + "MalwareFilterPolicy": "FunctionalTest MalwarePolicy", |
| 33 | + "SentTo": null, |
| 34 | + "SentToMemberOf": null, |
| 35 | + "ExceptIfSentTo": null, |
| 36 | + "ExceptIfSentToMemberOf": null, |
| 37 | + "ExceptIfRecipientDomainIs": null, |
| 38 | + "RecipientDomainIs": ["contoso.com"], |
| 39 | +} |
| 40 | + |
| 41 | +NonCompliantCustomAntiMalwarePolicy := { |
| 42 | + "Identity": "FunctionalTest MalwarePolicy", |
| 43 | + "EnableFileFilter": true, |
| 44 | + "FileTypes": ["cmd", "vbe"], |
| 45 | + "ZapEnabled": true, |
| 46 | +} |
| 47 | + |
| 48 | +# |
| 49 | +# Policy MS.SECURITYSUITE.1.1v1 |
| 50 | +#-- |
| 51 | +test_BlockClickToRun_DefaultFilterDisabled if { |
| 52 | + Output := securitysuite.tests |
| 53 | + with input.defender_license as true |
| 54 | + with input.protection_policy_rules as [] |
| 55 | + with input.anti_malware_rules as [] |
| 56 | + with input.anti_malware_policies as [DefaultAntiMalwarePolicy] |
| 57 | + with input.accepted_domains as AcceptedDomains |
| 58 | + |
| 59 | + ReportDetailString := concat("", [ |
| 60 | + "Requirement not met. The highest priority anti-malware policy that applies to all users is the ", |
| 61 | + "default policy. The common attachments filter is disabled.", |
| 62 | + ]) |
| 63 | + TestResult("MS.SECURITYSUITE.1.1v1", Output, ReportDetailString, false) == true |
| 64 | +} |
| 65 | + |
| 66 | +test_BlockClickToRun_DefaultMissingFileTypes if { |
| 67 | + Policy := object.union(DefaultAntiMalwarePolicy, { |
| 68 | + "EnableFileFilter": true, |
| 69 | + "FileTypes": ["cmd", "vbe"], |
| 70 | + "ZapEnabled": true, |
| 71 | + }) |
| 72 | + Output := securitysuite.tests |
| 73 | + with input.defender_license as true |
| 74 | + with input.protection_policy_rules as [] |
| 75 | + with input.anti_malware_rules as [] |
| 76 | + with input.anti_malware_policies as [Policy] |
| 77 | + with input.accepted_domains as AcceptedDomains |
| 78 | + |
| 79 | + ReportDetailString := concat("", [ |
| 80 | + "Requirement not met. The highest priority anti-malware policy that applies to all users is the ", |
| 81 | + "default policy. The common attachments filter does not include exe.", |
| 82 | + ]) |
| 83 | + TestResult("MS.SECURITYSUITE.1.1v1", Output, ReportDetailString, false) == true |
| 84 | +} |
| 85 | + |
| 86 | +test_BlockClickToRun_StandardPresetCompliant if { |
| 87 | + Output := securitysuite.tests |
| 88 | + with input.defender_license as true |
| 89 | + with input.protection_policy_rules as [StandardProtectionPolicyRule] |
| 90 | + with input.anti_malware_rules as [] |
| 91 | + with input.anti_malware_policies as [StandardAntiMalwarePolicy] |
| 92 | + with input.accepted_domains as AcceptedDomains |
| 93 | + |
| 94 | + TestResult("MS.SECURITYSUITE.1.1v1", Output, PASS, true) == true |
| 95 | +} |
| 96 | + |
| 97 | +test_BlockClickToRun_CustomPolicyNonCompliant if { |
| 98 | + Output := securitysuite.tests |
| 99 | + with input.defender_license as true |
| 100 | + with input.protection_policy_rules as [] |
| 101 | + with input.anti_malware_rules as [CustomAntiMalwareRule] |
| 102 | + with input.anti_malware_policies as [NonCompliantCustomAntiMalwarePolicy] |
| 103 | + with input.accepted_domains as [{"DomainName": "contoso.com"}] |
| 104 | + |
| 105 | + ReportDetailString := concat("", [ |
| 106 | + "Requirement not met. The highest priority anti-malware policy that applies to all users is the ", |
| 107 | + "FunctionalTest MalwarePolicy policy. The common attachments filter does not include exe.", |
| 108 | + ]) |
| 109 | + TestResult("MS.SECURITYSUITE.1.1v1", Output, ReportDetailString, false) == true |
| 110 | +} |
| 111 | + |
| 112 | +test_BlockClickToRun_ReportDetailsIsString if { |
| 113 | + Output := securitysuite.tests |
| 114 | + with input.defender_license as true |
| 115 | + with input.protection_policy_rules as [] |
| 116 | + with input.anti_malware_rules as [] |
| 117 | + with input.anti_malware_policies as [DefaultAntiMalwarePolicy] |
| 118 | + with input.accepted_domains as AcceptedDomains |
| 119 | + |
| 120 | + some Result in Output |
| 121 | + Result.PolicyId == "MS.SECURITYSUITE.1.1v1" |
| 122 | + is_string(Result.ReportDetails) |
| 123 | +} |
| 124 | +#-- |
0 commit comments