Checks/check-IP104.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
using module "..\MCCA.psm1"

class IP104 : MCCACheck {
    <#
     
          
    #>


    IP104() {
        $this.Control = "IP-104"
        $this.ParentArea = "Microsoft Information Protection"
        $this.Area = "Information Protection"
        $this.Name = "Create service side labelling policies"
        $this.PassText = "Your organization is using service side labeling policies"
        $this.FailRecommendation = "Your organization should use service side labeling policies"
        $this.Importance = "Your organization should setup and create service side labelling policies . This will help categorize your most important data so that you can effectively protect it from illicit access, and will help make it easier to investigate discovered breaches."
        $this.ExpandResults = $True
        $this.CheckType = [CheckType]::ObjectPropertyValue
        $this.ObjectType = "Auto Labelling Policy"
        $this.ItemName = "Label"
        $this.DataType = "Remarks"
        if($this.ExchangeEnvironmentNameForCheck -ieq "O365USGovGCCHigh")
        {
            $this.Links = @{
                "Learn more about configuring classifications for SharePoint Online" = "https://aka.ms/mcca-ip-docs-learn-more"
                "Compliance Center - Information Protection"                        = "https://aka.ms/mcca-gcch-ip-compliance-center"
                "Compliance Manager - IP Actions" = "https://aka.ms/mcca-gcch-ip-compliance-manager"
            } 
        }elseif ($this.ExchangeEnvironmentNameForCheck -ieq "O365USGovDoD") 
        {
            $this.Links = @{
                "Learn more about configuring classifications for SharePoint Online" = "https://aka.ms/mcca-ip-docs-learn-more"
                "Compliance Center - Information Protection"                        = "https://aka.ms/mcca-dod-ip-compliance-center"
                "Compliance Manager - IP Actions" = "https://aka.ms/mcca-dod-ip-compliance-manager"
            }
        }else
        {
        $this.Links = @{
            "Learn more about configuring classifications for SharePoint Online" = "https://aka.ms/mcca-ip-docs-learn-more"
            "Compliance Center - Information Protection"                        = "https://aka.ms/mcca-ip-compliance-center"
            "Compliance Manager - IP Actions" = "https://aka.ms/mcca-ip-compliance-manager"
        }
        }
    }

    <#
     
        RESULTS
     
    #>


    GetResults($Config) {

        if ($Config["GetAutoSensitivityLabelPolicy"] -eq "Error") {
            $this.Completed = $false
        }
        else {
            $AutoApplyExist = $false
            $isExchangeCovered = $false
            $isSharePointCovered = $false
            $isOneDriveCovered = $false
            ForEach ($AutoPolicyDefined in $Config["GetAutoSensitivityLabelPolicy"]) { 
                $AutoPolicy = $AutoPolicyDefined 
                $AutoApplyExist = $true         
                #Validate if Auto labelling policies are enabled across all workloads
                 
                if ($($AutoPolicy.Mode) -eq "Disable") {
                    $ConfigObject = [MCCACheckConfig]::new()
                    $ConfigObject.Object = "$($AutoPolicy.Name)"
                    $ConfigObject.ConfigItem = "$($AutoPolicy.ApplySensitivityLabel)"
                    $ConfigObject.ConfigData = "<B>Policy is not enabled </B> "
                    $ConfigObject.SetResult([MCCAConfigLevel]::Informational, "Pass")
                    $this.AddConfig($ConfigObject)
                }
                else {
                    $ConfigObject = [MCCACheckConfig]::new()
                    $ConfigObject.Object = "$($AutoPolicy.Name)"
                    $ConfigObject.ConfigItem = "$($AutoPolicy.ApplySensitivityLabel)"
                    $ConfigData = $null
                    if ( ($null -ne $($AutoPolicy.ExchangeLocation)  ) -and ($null -ne $($AutoPolicy.SharePointLocation) ) -and ($null -ne $($AutoPolicy.OneDriveLocation) )) {
                        $ConfigData = "<B>Exchange User/Groups:</B> $($AutoPolicy.ExchangeLocation) <BR>"
                        $ConfigData += "<B>SharePoint Sites:</B> $($AutoPolicy.SharePointLocation) <BR>"
                        $ConfigData += "<B>OneDrive Accounts:</B> $($AutoPolicy.OneDriveLocation) <BR>"
                        $ConfigObject.ConfigData = $ConfigData
                        $ConfigObject.SetResult([MCCAConfigLevel]::Ok, "Pass")
                        $this.AddConfig($ConfigObject)
                        $isExchangeCovered = $true
                        $isSharePointCovered = $true
                        $isOneDriveCovered = $true
                   
                    }
                    else {
                        $ConfigObject = [MCCACheckConfig]::new()
                        $ConfigObject.Object = "$($AutoPolicy.Name)"
                        $ConfigObject.ConfigItem = "$($AutoPolicy.ApplySensitivityLabel)"
                        $ConfigData = $null
                        if ( ($null -ne $($AutoPolicy.ExchangeLocation)  ) -and ($null -ne $($AutoPolicy.SharePointLocation) ) -and ($null -ne $($AutoPolicy.OneDriveLocation) )) {
                            $ConfigData = "<B>Exchange User/Groups:</B> $($AutoPolicy.ExchangeLocation) <BR>"
                            $isExchangeCovered = $true
                        }
                        else {
                            $ConfigData = "<B>Exchange User/Groups:</B> Not Enabled <BR>"
                        }
                        if ($null -ne $($AutoPolicy.SharePointLocation)  ) {
                            $ConfigData += "<B>SharePoint Sites:</B> $($AutoPolicy.SharePointLocation) <BR>"
                            $isSharePointCovered = $true
                        }
                        else {
                            $ConfigData += "<B>SharePoint Sites:</B> Not Enabled <BR>"
                        }
                        if ($null -ne $($AutoPolicy.OneDriveLocation)  ) {
                            $ConfigData += "<B>OneDrive Accounts:</B> $($AutoPolicy.OneDriveLocation) <BR>"
                            $isOneDriveCovered = $true
                        }
                        else {
                            $ConfigData += "<B>OneDrive Accounts:</B> Not Enabled <BR>"    

                        }
                        $ConfigObject.ConfigData = $ConfigData
                        $ConfigObject.SetResult([MCCAConfigLevel]::Informational, "Pass")
                        $this.AddConfig($ConfigObject)
                    }
                 
                }
            }
            $PartialWorkload = ""
            If ($isExchangeCovered -eq $false) {
                if ($PartialWorkload -eq "") {
                    $PartialWorkload += "Exchange"   
                }
                else {            
                    $PartialWorkload += ",Exchange" 
                } 
            }

            If ($isSharePointCovered -eq $false) {
                if ($PartialWorkload -eq "") {
                    $PartialWorkload += "SharePoint"   
                }
                else {            
                    $PartialWorkload += ",SharePoint" 
                } 
            }

            If ($isOneDriveCovered -eq $false) {
                if ($PartialWorkload -eq "") {
                    $PartialWorkload += "OneDrive"   
                }
                else {            
                    $PartialWorkload += ",OneDrive" 
                } 
            }
            #policy not defined on one or more workload
            If (($PartialWorkload -ne "") -and ($AutoApplyExist -eq $true) ){
                $ConfigObject = [MCCACheckConfig]::new()
                $ConfigObject.Object = "<B>All workload not covered</B>"
                #$ConfigObject.ConfigItem = $PartialLabel
                $ConfigData = "<B>Affected Workloads:</B>$PartialWorkload <BR>"
                $ConfigObject.ConfigData = $ConfigData
                $ConfigObject.SetResult([MCCAConfigLevel]::Ok, "Fail")
                $this.AddConfig($ConfigObject)
            }
            If ($AutoApplyExist -eq $False) {
                $ConfigObject = [MCCACheckConfig]::new()
                $ConfigObject.Object = "<b>No Auto Labeling Policy Defined</b>"
                $ConfigObject.ConfigItem = ""
                $ConfigData = "<B>Affected Workloads:</B>Exchange, SharePoint, OneDrive"
                $ConfigObject.ConfigData = $ConfigData
                $ConfigObject.SetResult([MCCAConfigLevel]::Ok, "Fail")            
                $this.AddConfig($ConfigObject)
            }
            $hasRemediation = $this.Config | Where-Object { $_.RemediationAction -ne '' }
            if ($($hasremediation.count) -gt 0) {
                $this.MCCARemediationInfo = New-Object -TypeName MCCARemediationInfo -Property @{
                    RemediationAvailable = $True
                    RemediationText      = "You need to connect to Security & Compliance Center PowerShell to execute the below commands. Please follow steps defined in <a href = 'https://docs.microsoft.com/en-us/powershell/exchange/connect-to-scc-powershell?view=exchange-ps'> Connect to Security & Compliance Center PowerShell</a>."
                }
            }
            $this.Completed = $True
        }
    }

}