Framework/Models/RemoteReports/ComplianceStateModel.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
Set-StrictMode -Version Latest

class ComplianceStateTableEntity
{
    #partition key = resourceid/subscriptionid
    [string] $PartitionKey; 
    #row key = controlid
    [string] $RowKey;    
    [string] $ResourceId = "";
    [string] $LastEventOn = [Constants]::AzSKDefaultDateTime;
    [string] $ResourceGroupName = "";
    [string] $ResourceName = "";    
    [string] $FeatureName = "";
    
    #Default control values
    [string] $ControlId = "";
    [string] $ControlIntId = "";
    [string] $ControlUpdatedOn = [Constants]::AzSKDefaultDateTime;
    [string] $ControlSeverity = ([ControlSeverity]::High).ToString();
    [string] $ActualVerificationResult= ([VerificationResult]::Manual).ToString();
    [string] $AttestationStatus = ([AttestationStatus]::None).ToString();
    [string] $VerificationResult = ([VerificationResult]::Manual).ToString();
    [string] $AttestedBy = "";
    [string] $AttestedDate = [Constants]::AzSKDefaultDateTime;
    [string] $Justification = "";
    [string] $PreviousVerificationResult = ([VerificationResult]::Manual).ToString();
    [bool] $IsBaselineControl;
    [bool] $HasOwnerAccessTag;

    #Tracking information
    [string] $LastResultTransitionOn = [Constants]::AzSKDefaultDateTime;
    [string] $LastScannedOn = [Constants]::AzSKDefaultDateTime;
    [string] $FirstScannedOn = [Constants]::AzSKDefaultDateTime;
    [string] $FirstFailedOn = [Constants]::AzSKDefaultDateTime;
    [string] $FirstAttestedOn = [Constants]::AzSKDefaultDateTime;
    [int] $AttestationCounter = 0;

    #Other information
    [string] $ScannedBy = "";
    [string] $ScanSource;
    [string] $ScannerModuleName = "";
    [string] $ScannerVersion = "";
    [bool] $IsLatestPSModule;
    [bool] $HasRequiredPermissions;
    [bool] $HasAttestationWritePermissions;
    [bool] $HasAttestationReadPermissions;
    [string] $UserComments = "";    
    [string] $ChildResourceName = "";
    [bool] $IsActive = $true;

    [string] GetPartitionKey()
    {                        
        $HashId = [Helpers]::ComputeHash($this.ResourceId.ToLower());
        
        return $HashId;
    }

    [string] GetRowKey()
    {    
        $partsToHash = $this.ControlIntId;
        if(-not [string]::IsNullOrWhiteSpace($this.ChildResourceName))
        {
            $partsToHash = $partsToHash + ":" + $this.ChildResourceName;
        }
        $HashId = [Helpers]::ComputeHash($partsToHash.ToLower());    
        return $HashId;
    }

    # static [ComplianceStateTableEntity] CreateEmptyResource([string] $resourceId, [string] $hashId)
    # {
    # [ComplianceStateTableEntity] $emptyResourceEntity = [ComplianceStateTableEntity]::new();
    # $emptyResourceEntity.PartitionKey = $hashId;
    # $emptyResourceEntity.RowKey = "EmptyResource";
    # $emptyResourceEntity.ResourceId = $resourceId;
    # return $emptyResourceEntity;
    # }
}