Skip to content

Commit c250fbe

Browse files
committed
Remove duplicate code in Invoke-GRRFlow
* Remove duplicate code in Invoke-GRRFlow which handles the verification of given artifact in ArtifactCollectorFlow. * Add macOS test result for Add-GRRArtifact in CHANGELOG.
1 parent 43554ce commit c250fbe

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ GRR and removing them from GRR were added.
2323
* Add **config option for the client certificate path** to handle
2424
certificate authentication based on files (_GRRClientCertFilePath_).
2525
* Add `Add-GRRArtifact` for **uploading new artifacts to GRR**. Tested with
26-
Windows PowerShell v5 and PowerShell Core 6.0.0-beta.5 on Windows.
26+
Windows PowerShell v5 and PowerShell Core 6.0.0-beta.5 on Windows and PowerShell
27+
Core 6.0.0-beta.5 on macOS.
2728
* Add `Remove-GRRArtifact` for **removing one or multiple artifacts from GRR**.
2829
* Add base64 encoding function (`ConvertTo-Base64`) which is used for
2930
manual basic authentication to mitigate missing basic authentication in

PowerGRR.psm1

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,42 +1160,17 @@ function Invoke-GRRFlow()
11601160
}
11611161
elseif ($Flow -eq "ArtifactCollectorFlow")
11621162
{
1163-
$AllArtifacts = Get-GRRArtifact -Credential $Credential
1164-
if ($AllArtifacts)
1165-
{
1166-
$AllArtifacts = $AllArtifacts | select -ExpandProperty name
1167-
}
1168-
else
1169-
{
1170-
Throw "No artifacts found in GRR"
1171-
}
1172-
1173-
$ValidatedArtifacts = @()
1163+
$ValidatedArtifacts = Get-ValidatedGRRArtifact -Credential $Credential -Artifacts $PSBoundParameters['ArtifactList']
11741164

1175-
foreach ($Artifact in $PSBoundParameters['ArtifactList'])
1165+
if ($ValidatedArtifacts)
11761166
{
1177-
if ($AllArtifacts -and $AllArtifacts.contains($Artifact))
1178-
{
1179-
$ValidatedArtifacts += $Artifact
1180-
}
1181-
else
1182-
{
1183-
write-warning "Skipping artifact `'$Artifact`' because it is not defined in GRR."
1184-
}
1185-
}
1186-
1187-
if($ValidatedArtifacts)
1188-
{
1189-
$ValidatedArtifacts = $ValidatedArtifacts | Get-Unique
1167+
$PluginArguments = '{"artifact_list":["'+ $($ValidatedArtifacts -join "`",`"") + '"]}'
1168+
Write-Verbose "PluginArguments for ArtifactCollectorFlow: $PluginArguments"
11901169
}
11911170
else
11921171
{
1193-
Throw "No artifacts found in GRR which match the command"
1172+
Throw "No artifacts found in GRR which match the given artifacts."
11941173
}
1195-
1196-
$PluginArguments = '{"artifact_list":["'+ $($ValidatedArtifacts -join "`",`"") + '"]}'
1197-
1198-
Write-Verbose "PluginArguments for ArtifactCollectorFlow: $PluginArguments"
11991174
}
12001175

12011176
$Body = '{"flow":{"runner_args":{"flow_name":"'+$Flow+'",'

0 commit comments

Comments
 (0)