Skip to content

Commit

Permalink
update config and core modules
Browse files Browse the repository at this point in the history
  • Loading branch information
silverhack committed Jun 10, 2024
1 parent 39ed2b4 commit db04af6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config/monkey365.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
},
"ruleSettings": {
"rules": "rules/",
"azureDefaultRuleset": "rules/rulesets/cis_azure_1.5.json",
"m365DefaultRuleset": "rules/rulesets/cis_m365_1.5.json"
"azureDefaultRuleset": "rules/rulesets/cis_azure_2.0.json",
"m365DefaultRuleset": "rules/rulesets/cis_m365_2.0.json"
},
"logging": {
"default":[
Expand Down
1 change: 1 addition & 0 deletions core/modules/monkeyjob/Localized/en-US/monkeyjob.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
RemoveDummyFunctionMessage = Removing dummy function {0}
ScriptBlockError = Unable to create ScriptBlock object
CommandNotRecognized = Command {0} cannot be imported
UnableToRemoveJob = "Unable to remove job {0}"
'@
1 change: 1 addition & 0 deletions core/modules/monkeyjob/Localized/monkeyjob.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
RemoveDummyFunctionMessage = Removing dummy function {0}
ScriptBlockError = Unable to create ScriptBlock object
CommandNotRecognized = Command {0} cannot be imported
UnableToRemoveJob = "Unable to remove job {0}"
'@
31 changes: 27 additions & 4 deletions core/modules/monkeyjob/public/Remove-MonkeyJob.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,28 @@ Function Remove-MonkeyJob{
}
}
}
if($PSBoundParameters.ContainsKey('Force')){
[void]$MonkeyJob.Job.InnerJob.Stop()
If ($MonkeyJob.Job.State -notmatch 'Completed|Failed|Stopped') {
if($PSBoundParameters.ContainsKey('Force')){
[void]$MonkeyJob.Job.InnerJob.Stop();
$MonkeyJob.Job.InnerJob.Dispose();
if(!$PSBoundParameters.ContainsKey('KeepRunspacePool')){
#$MonkeyJob.Job.InnerJob.RunspacePool.Close();
$MonkeyJob.Job.InnerJob.RunspacePool.Dispose();
}
if($MonkeyJob.Job.State -ne [System.Management.Automation.JobState]::Stopped){
$MonkeyJob.Job.StopJob();
}
$MonkeyJob.Job.Dispose();
#Dispose task
if($null -ne $MonkeyJob.Task -and $MonkeyJob.Task.Status -match 'Canceled|Faulted|RanToCompletion'){
$MonkeyJob.Task.Dispose();
$MonkeyJob.Task = $null;
}
[void]$MonkeyJobs.Remove($MonkeyJob)
}
Else{
Write-Warning ($script:messages.UnableToRemoveJob -f $MonkeyJob.Id)
}
}
#Clean MonkeyJob object
#$MonkeyJob.Job.InnerJob.Stop();
Expand All @@ -120,11 +140,14 @@ Function Remove-MonkeyJob{
$MonkeyJob.Job.StopJob();
}
$MonkeyJob.Job.Dispose();
if($null -ne $MonkeyJob.Task){
if($null -ne $MonkeyJob.Task -and $MonkeyJob.Task.Status -match 'Canceled|Faulted|RanToCompletion'){
$MonkeyJob.Task.Dispose();
$MonkeyJob.Task = $null;
[void]$MonkeyJobs.Remove($MonkeyJob)
}
Else{
Write-Warning ($script:messages.UnableToRemoveJob -f $MonkeyJob.Id)
}
[void]$MonkeyJobs.Remove($MonkeyJob)
#Perform garbage collection
[gc]::Collect()
}
Expand Down

0 comments on commit db04af6

Please sign in to comment.