-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the report UUID to the ScubaResults.json filename (#1426)
* Initial implementation of adding UUID to the file name * Add back missing ConvertFrom-Json call * Mock Get-ChildItem in unit tests * Document addition of UUID to ScubaResults file name * Add unit tests for when there are multiple ScubaResults*.json files * Correct minor typo in documentation * remove wildcard search in ConvertTo-ResultsCSV code path * add error handling of window path length limit errors * fix some of the tests * fix the all the current broken unit tests * additional unit tests * add back in accidentally removed fields in config * complete lorem ipsum * todo message * remove UUID truncation for now * first draft * add truncation param to documentation * spacing * fix failing test cases; handle full truncation case * make code consistent; add code comments to describe it's purpose * review feedback; point to additional options in the error message * PR Review: Fix absolute path check; fix config file override * review feedback; move new parameter in alphabetical order in docs * keep documentation consistent * remove configuration paramset from scubacached * code comments for the new edge case * Remove OBE unit test * Remove duplicate word * fix typos, wording and formatting in config * Refactor truncation logic into own function * rm duplicate text from PowerShell as well * captialize * remove long path check let the set-content naturally error out * add long path error check within the catch block * remove todo * Add UUID to mock data for cached tests * Fix unit tests * Remove commented out validation code. Co-authored-by: mitchelbaker-cisa <[email protected]> * add validation set to check invalid config file parameter * Remove stacktrace --------- Co-authored-by: buidav <[email protected]> Co-authored-by: mitchelbaker-cisa <[email protected]>
- Loading branch information
Showing
10 changed files
with
392 additions
and
161 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
PowerShell/ScubaGear/Testing/Unit/PowerShell/Orchestrator/Get-FullOutJsonName.Tests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
$OrchestratorPath = '../../../../Modules/Orchestrator.psm1' | ||
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath $OrchestratorPath) -Function 'Get-FullOutJsonName' | ||
|
||
Describe -Tag 'Orchestrator' -Name 'Get-FullOutJsonName' { | ||
InModuleScope Orchestrator { | ||
It 'Adds the full UUID' { | ||
$FullNameParams = @{ | ||
'OutJsonFileName' = "ScubaResults"; | ||
'Guid' = "30ebce05-f8f0-4a09-8ec2-589efbbd0e72"; | ||
'NumberOfUUIDCharactersToTruncate' = 0; | ||
} | ||
(Get-FullOutJsonName @FullNameParams) | Should -eq "ScubaResults_30ebce05-f8f0-4a09-8ec2-589efbbd0e72.json" | ||
} | ||
It 'Handles partial truncation' { | ||
$FullNameParams = @{ | ||
'OutJsonFileName' = "ScubaResults"; | ||
'Guid' = "30ebce05-f8f0-4a09-8ec2-589efbbd0e72"; | ||
'NumberOfUUIDCharactersToTruncate' = 18; | ||
} | ||
(Get-FullOutJsonName @FullNameParams) | Should -eq "ScubaResults_30ebce05-f8f0-4a09.json" | ||
} | ||
It 'Handles full truncation' { | ||
$FullNameParams = @{ | ||
'OutJsonFileName' = "ScubaResults"; | ||
'Guid' = "30ebce05-f8f0-4a09-8ec2-589efbbd0e72"; | ||
'NumberOfUUIDCharactersToTruncate' = 36; | ||
} | ||
(Get-FullOutJsonName @FullNameParams) | Should -eq "ScubaResults.json" | ||
} | ||
It 'Handles non-default names' { | ||
$FullNameParams = @{ | ||
'OutJsonFileName' = "my_results"; | ||
'Guid' = "30ebce05-f8f0-4a09-8ec2-589efbbd0e72"; | ||
'NumberOfUUIDCharactersToTruncate' = 18; | ||
} | ||
(Get-FullOutJsonName @FullNameParams) | Should -eq "my_results_30ebce05-f8f0-4a09.json" | ||
} | ||
} | ||
} | ||
|
||
AfterAll { | ||
Remove-Module Orchestrator -ErrorAction SilentlyContinue | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.