From ca5ac67778799061d7102d6a16e7c5348b300ba9 Mon Sep 17 00:00:00 2001 From: Alden Hilton Date: Mon, 30 Sep 2024 12:01:06 -0700 Subject: [PATCH] Add report id to front page --- .../Modules/CreateReport/ParentReport/ParentReport.html | 2 +- PowerShell/ScubaGear/Modules/Orchestrator.psm1 | 4 ++++ .../PowerShell/Orchestrator/Invoke-ReportCreation.Tests.ps1 | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PowerShell/ScubaGear/Modules/CreateReport/ParentReport/ParentReport.html b/PowerShell/ScubaGear/Modules/CreateReport/ParentReport/ParentReport.html index f89bf9dca4..3dcb6c8bea 100644 --- a/PowerShell/ScubaGear/Modules/CreateReport/ParentReport/ParentReport.html +++ b/PowerShell/ScubaGear/Modules/CreateReport/ParentReport/ParentReport.html @@ -27,7 +27,7 @@

SCuBA M365 Security Baseline Conformance Reports

{TENANT_DETAILS} {TABLES} diff --git a/PowerShell/ScubaGear/Modules/Orchestrator.psm1 b/PowerShell/ScubaGear/Modules/Orchestrator.psm1 index 4d5f508f4b..22de0c6d56 100644 --- a/PowerShell/ScubaGear/Modules/Orchestrator.psm1 +++ b/PowerShell/ScubaGear/Modules/Orchestrator.psm1 @@ -1209,10 +1209,14 @@ function Invoke-ReportCreation { $TenantMetaData = $TenantMetaData -replace '^(.*?)','
' $Fragment = $Fragment | ConvertTo-Html -Fragment -ErrorAction 'Stop' + $FileName = Join-Path -Path $OutFolderPath -ChildPath "$($OutProviderFileName).json" -Resolve + $ReportUuid = $(Get-Utf8NoBom -FilePath $FileName | ConvertFrom-Json).report_uuid + $ReportHtmlPath = Join-Path -Path $ReporterPath -ChildPath "ParentReport" -ErrorAction 'Stop' $ReportHTML = (Get-Content $(Join-Path -Path $ReportHtmlPath -ChildPath "ParentReport.html") -ErrorAction 'Stop') -Join "`n" $ReportHTML = $ReportHTML.Replace("{TENANT_DETAILS}", $TenantMetaData) $ReportHTML = $ReportHTML.Replace("{TABLES}", $Fragment) + $ReportHTML = $ReportHTML.Replace("{REPORT_UUID}", $ReportUuid) $ReportHTML = $ReportHTML.Replace("{MODULE_VERSION}", "v$ModuleVersion") $ReportHTML = $ReportHTML.Replace("{BASELINE_URL}", $BaselineURL) diff --git a/PowerShell/ScubaGear/Testing/Unit/PowerShell/Orchestrator/Invoke-ReportCreation.Tests.ps1 b/PowerShell/ScubaGear/Testing/Unit/PowerShell/Orchestrator/Invoke-ReportCreation.Tests.ps1 index 61b7246919..630c88f3b4 100644 --- a/PowerShell/ScubaGear/Testing/Unit/PowerShell/Orchestrator/Invoke-ReportCreation.Tests.ps1 +++ b/PowerShell/ScubaGear/Testing/Unit/PowerShell/Orchestrator/Invoke-ReportCreation.Tests.ps1 @@ -1,8 +1,9 @@ $OrchestratorPath = '../../../../Modules/Orchestrator.psm1' $CreateReportPath = '../../../../Modules/CreateReport/CreateReport.psm1' +$UtilityPath = '../../../../Modules/Utility/Utility.psm1' Import-Module (Join-Path -Path $PSScriptRoot -ChildPath $OrchestratorPath) -Function Invoke-ReportCreation -Force Import-Module (Join-Path -Path $PSScriptRoot -ChildPath $CreateReportPath) -Function New-Report, Import-SecureBaseline -Force - +Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath $UtilityPath) -Function Get-Utf8NoBom -Force InModuleScope Orchestrator { Describe -Tag 'Orchestrator' -Name 'Invoke-ReportCreation' { BeforeAll { @@ -19,7 +20,8 @@ InModuleScope Orchestrator { Mock -CommandName Get-Content {} Mock -CommandName Add-Type {} Mock -CommandName Invoke-Item {} - + Mock -CommandName Get-Utf8NoBom {} + Mock -CommandName ConvertFrom-Json { @{ "report_uuid"="" } } } Context 'When creating the reports from Provider and OPA results JSON' { BeforeAll {