Skip to content

Commit

Permalink
[Enhancement] Multiple format document upload (#110)
Browse files Browse the repository at this point in the history
* adding code to work with documents with other file extention

* adding update for other file formats

* remove commented line

* cleanup
  • Loading branch information
dutt0 authored Mar 15, 2024
1 parent 043addb commit 3f204ad
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 29 deletions.
Binary file modified psmodules/GR-Common.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion setup/IaC/modules/automationaccount.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ resource module13 'modules' = if (newDeployment || updatePSModules) {
properties: {
contentLink: {
uri: '${ModuleBaseURL}/GR-Common.zip'
version: '1.1.16'
version: '1.1.17'
}
}
}
Expand Down
36 changes: 18 additions & 18 deletions setup/modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "BreakGlassAccountProcedure.txt"
"Value": "BreakGlassAccountProcedure"
},
{
"Name": "itsgcode",
Expand All @@ -33,7 +33,7 @@
"ModuleType": "Builtin",
"Status": "Enabled",
"Required": "True",
"Script": "Check-GAAuthenticationMethods -StorageAccountName $vars.storageaccountname -ContainerName $vars.containerName -ResourceGroupName $ResourceGroupName -SubscriptionID $SubID -DocumentName $vars.DocumentName -ControlName $msgTable.CtrName1 -ItemName $msgTable.gaAccntsMFACheck -MsgTable $msgTable -ReportTime $ReportTime -itsgcode $vars.itsgcode",
"Script": "Check-GAAuthenticationMethods -StorageAccountName $vars.storageAccountName -ContainerName $vars.containerName -ResourceGroupName $ResourceGroupName -SubscriptionID $SubID -DocumentName $vars.DocumentName -ControlName $msgTable.CtrName1 -ItemName $msgTable.gaAccntsMFACheck -MsgTable $msgTable -ReportTime $ReportTime -itsgcode $vars.itsgcode",
"variables": [
{
"Name": "storageAccountName",
Expand All @@ -47,7 +47,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "GlobalAdministratorsUPN.txt"
"Value": "GlobalAdministratorsUPN"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -75,7 +75,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "BGFollowProcedureResponsibility.txt"
"Value": "BGFollowProcedureResponsibility"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -216,7 +216,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "GCPasswordGuidanceDoc.txt"
"Value": "GCPasswordGuidanceDoc"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -244,7 +244,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "PrivilegedAccountManagementPlan.txt"
"Value": "PrivilegedAccountManagementPlan"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -300,7 +300,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "AuthorizedProcessApprovedByCSO.txt"
"Value": "AuthorizedProcessApprovedByCSO"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -328,7 +328,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "GlobalAdministratorsUPN.txt"
"Value": "GlobalAdministratorsUPN"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -396,7 +396,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "SPNEncryptedEmailToCSPMSentAttestation.txt"
"Value": "SPNEnencryptedEmailToCSPMSentAttestation"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -524,7 +524,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "TLS12EnabledAttestation.txt"
"Value": "TLS12EnabledAttestation"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -580,7 +580,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "ConfirmNetworkDiagramExists.txt"
"Value": "ConfirmNetworkDiagramExists"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -648,7 +648,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "NetworkBoundaryProtectionPolicy.txt"
"Value": "NetworkBoundaryProtectionPolicy"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -676,7 +676,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "LimitPublicIPsPolicy.txt"
"Value": "LimitPublicIPsPolicy"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -704,7 +704,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "AuthSourceIPPolicyConfirm.txt"
"Value": "AuthSourceIPPolicyConfirm"
},
{
"Name": "itsgcode",
Expand Down Expand Up @@ -753,8 +753,8 @@
{
"Name": "DocumentName",
"Value": [
"MemorandumOfUnderstanding.txt",
"ChiefDirectoryOfficeConfirmation.txt"
"MemorandumOfUnderstanding",
"ChiefDirectoryOfficeConfirmation"
]
},
{
Expand Down Expand Up @@ -784,7 +784,7 @@
{
"Name": "DocumentName",
"Value": [
"SeverityNotificationToEmailConfigured.txt"
"SeverityNotificationToEmailConfigured"
]
},
{
Expand Down Expand Up @@ -885,7 +885,7 @@
"localVariables": [
{
"Name": "DocumentName",
"Value": "ConfirmPasswordNotificationsConfigured.txt"
"Value": "ConfirmPasswordNotificationsConfigured"
},
{
"Name": "itsgcode",
Expand Down
2 changes: 1 addition & 1 deletion src/Guardrails-Common/GR-Common.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
RootModule = 'GR-Common'

# Version number of this module.
ModuleVersion = '1.1.16'
ModuleVersion = '1.1.17'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
41 changes: 32 additions & 9 deletions src/Guardrails-Common/GR-Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,22 @@ function Check-DocumentExistsInStorage {
[PSCustomObject] $ErrorList = New-Object System.Collections.ArrayList
[bool] $IsCompliant = $false
[string] $Comments = $null

if ($ItemName.ToLower() -eq 'network architecture diagram'){
$fileExtensions = @(".pdf", ".png", ".jpeg", ".vsdx")
}
elseif ($ItemName.ToLower() -eq 'global administrators accounts mfa check') {
$fileExtensions = @(".txt")
}
else {
$fileExtensions = @(".txt",".docx", ".doc")
}

$DocumentName_new = New-Object System.Collections.Generic.List[System.Object]
ForEach ($fileExt in $fileExtensions) {
$DocumentName_new.Add($DocumentName[0] + $fileExt)
}

try {
Select-AzSubscription -Subscription $SubscriptionID | out-null
}
Expand All @@ -550,20 +566,27 @@ function Check-DocumentExistsInStorage {

$docMissing = $false
$commentsArray = @()
ForEach ($docName in $DocumentName) {
$blobFound = $false

ForEach ($docName in $DocumentName_new) {
# check for procedure doc in blob storage account
$blobs = Get-AzStorageBlob -Container $ContainerName -Context $StorageAccount.Context -Blob $docName -ErrorAction SilentlyContinue

If ($blobs) {
# a blob with the name $DocumentName was located in the specified storage account
$commentsArray += $msgTable.procedureFileFound -f $docName
}
else {
# no blob with the name $DocumentName was found in the specified storage account
$docMissing = $true
$commentsArray += $msgTable.procedureFileNotFound -f $ItemName, $docName, $ContainerName, $StorageAccountName
$blobFound = $true
break
}
}

if ($blobFound){
# a blob with the name $attestationFileName was located in the specified storage account
$commentsArray += $msgTable.procedureFileFound -f $docName
}
else {
# no blob with the name $attestationFileName was found in the specified storage account
$docMissing = $true
$commentsArray += $msgTable.procedureFileNotFound -f $ItemName, $DocumentName[0], $ContainerName, $StorageAccountName
}

$Comments = $commentsArray -join ";"

If ($docMissing) {
Expand Down

0 comments on commit 3f204ad

Please sign in to comment.