Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dedupe $ProductNames #782

Merged
merged 6 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PowerShell/ScubaGear/Modules/Orchestrator.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function Invoke-SCuBA {
if ($PSCmdlet.ParameterSetName -eq 'Report'){

$ProvidedParameters = @{
'ProductNames' = $ProductNames | Sort-Object
'ProductNames' = $ProductNames | Sort-Object -Unique
'M365Environment' = $M365Environment
'OPAPath' = $OPAPath
'LogIn' = $LogIn
Expand Down Expand Up @@ -1536,7 +1536,7 @@ function Invoke-RunCached {
New-Item -ItemType "Directory" -Path $OutPath | Out-Null
}
$OutFolderPath = $OutPath
$ProductNames = $ProductNames | Sort-Object
$ProductNames = $ProductNames | Sort-Object -Unique

Remove-Resources
Import-Resources # Imports Providers, RunRego, CreateReport, Connection
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/ScubaGear/Modules/ScubaConfig/ScubaConfig.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ScubaConfig {
}
else{
Write-Debug "ProductNames provided - using as is."
$this.Configuration.ProductNames = $this.Configuration.ProductNames | Sort-Object
$this.Configuration.ProductNames = $this.Configuration.ProductNames | Sort-Object -Unique
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ InModuleScope Orchestrator {
}
{Invoke-Scuba @SplatParams} | Should -Not -Throw
}
It 'Should only run each baseline once if provider names contains duplicates' {
{Invoke-Scuba -ProductNames aad,aad} | Should -Not -Throw
Should -Invoke Invoke-ReportCreation -ParameterFilter {$ProductNames -eq 'aad'}
}
}
Context 'Service Principal provided'{
It 'All items given as not null or empty'{
Expand Down Expand Up @@ -116,4 +120,4 @@ InModuleScope Orchestrator {
}
AfterAll {
Remove-Module Orchestrator -ErrorAction SilentlyContinue
}
}
twneale marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using module '..\..\..\..\Modules\ScubaConfig\ScubaConfig.psm1'

InModuleScope ScubaConfig {
Describe -tag "Utils" -name 'ScubaConfigJson' {
context 'JSON Configuration' {
BeforeEach{
twneale marked this conversation as resolved.
Show resolved Hide resolved
[ScubaConfig]::ResetInstance()
$Config = [ScubaConfig]::GetInstance()
$Config.Configuration.ProductNames = @('aad', 'aad')
}
It 'Should not contain duplicate product names'{
$Config.Configuration.ProductNames | Should -BeExactly @('aad')
}
AfterAll {
[ScubaConfig]::ResetInstance()
twneale marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}

Loading