-
Notifications
You must be signed in to change notification settings - Fork 231
Allow passing only -TestGuids to Invoke-AtomicTest #215
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
base: master
Are you sure you want to change the base?
Conversation
Allows users to skip passing a technique number if TestGuids is provided. Works by parsing the atomics for each guid passed, then calling the original function with the associated technique number and guid along with any other arguments passed.
cyberbuff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @JrOrOneEquals1 This is a great addition. Thanks for your contribution. I will review this PR over the weekend and test it on all the 3 platforms. Requested a minor change.
Public/Invoke-AtomicTest.ps1
Outdated
| if ($ShowDetails) { | ||
| $Parameters["ShowDetails"] = $ShowDetails | ||
| } | ||
|
|
||
| if ($ShowDetailsBrief) { | ||
| $Parameters["ShowDetailsBrief"] = $ShowDetailsBrief | ||
| } | ||
|
|
||
| if ($null -ne $TestNumbers) { | ||
| $Parameters["TestNumbers"] = $TestNumbers | ||
| } | ||
|
|
||
| if ($null -ne $TestNames) { | ||
| $Parameters["TestNames"] = $TestNames | ||
| } | ||
|
|
||
| if ($CheckPrereqs) { | ||
| $Parameters["CheckPrereqs"] = $CheckPrereqs | ||
| } | ||
|
|
||
| if ($PromptForInputArgs) { | ||
| $Parameters["PromptForInputArgs"] = $PromptForInputArgs | ||
| } | ||
|
|
||
| if ($GetPrereqs) { | ||
| $Parameters["GetPrereqs"] = $GetPrereqs | ||
| } | ||
|
|
||
| if ($Cleanup) { | ||
| $Parameters["Cleanup"] = $Cleanup | ||
| } | ||
|
|
||
| if ($NoExecutionLog) { | ||
| $Parameters["NoExecutionLog"] = $NoExecutionLog | ||
| } | ||
|
|
||
| if ($Force) { | ||
| $Parameters["Force"] = $Force | ||
| } | ||
|
|
||
| if ($null -ne $InputArgs) { | ||
| $Parameters["InputArgs"] = $InputArgs | ||
| } | ||
|
|
||
| if ($PSBoundParameters.ContainsKey('Session')) { | ||
| if ( $null -eq $Session ) { | ||
| Write-Error "The provided session is null and cannot be used." | ||
| continue | ||
| } | ||
| else { | ||
| $Parameters["Session"] = $Session | ||
| } | ||
| } | ||
|
|
||
| if ($Interactive) { | ||
| $Parameters["Interactive"] = $Interactive | ||
| } | ||
|
|
||
| if ($KeepStdOutStdErrFiles) { | ||
| $Parameters["KeepStdOutStdErrFiles"] = $KeepStdOutStdErrFiles | ||
| } | ||
|
|
||
| if ($LoggingModule) { | ||
| $Parameters["LoggingModule"] = $LoggingModule | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor correction. This portion can be shortened to
# Copy all bound parameters except TestGuids (which is handled separately)
$PSBoundParameters.GetEnumerator() | Where-Object { $_.Key -ne 'TestGuids' } | ForEach-Object {
$Parameters[$_.Key] = $_.Value
}
# Special handling for Session parameter
if ($Parameters.ContainsKey('Session') -and $null -eq $Parameters['Session']) {
Write-Error "The provided session is null and cannot be used."
continue
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed that, thank you for the suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cyberbuff sorry for getting back again so late! I was looking at the failed check for this and from what I can tell, it seems like it is calling the code with a null Session parameter, which then causes the script to fall into the statement where it writes the error, which is supposed to happen under those conditions. The test just sees that it had an exit code 1 and (seemingly incorrectly) says it failed. Am I understanding that right, or is there a problem with the script getting to that point when it shouldn't that should be resolved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cyberbuff can you help with this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey guys. Apologies for the delay. Its a linting error. I dont have access to make changes in your branch. You need to install PSScriptAnalyzer and run
Install-Module -Name PSScriptAnalyzer -Force
Invoke-ScriptAnalyzer -Recurse ./ -Settings ./PSScriptAnalyzerSettings.psd1 -Fix
Allows users to skip passing a technique number if TestGuids is provided.
Parses $TestGuids and gets the associated technique number, then calls the main command with the necessary arguments for each guid passed.
Example run:
Invoke-AtomicTest -TestGuids 970ab6a1-0157-4f3f-9a73-ec4166754b23,53cf1903-0fa7-4177-ab14-f358ae809eec -ShowDetails
Which would then call:
Invoke-AtomicTest T1016 -TestGuids 970ab6a1-0157-4f3f-9a73-ec4166754b23 -ShowDetails
Invoke-AtomicTest T1016.002 -TestGuids 53cf1903-0fa7-4177-ab14-f358ae809eec -ShowDetails