Skip to content

Commit 3cf2cf7

Browse files
committed
Add concurrent queue to authenticode check
1 parent b55e7af commit 3cf2cf7

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

src/code/InstallHelper.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,12 +1069,9 @@ private bool TryInstallToTempPath(
10691069
pkgName,
10701070
tempDirNameVersion,
10711071
_cmdletPassedIn,
1072-
out string warning,
1073-
out error))
1072+
errorMsgs,
1073+
warningMsgs))
10741074
{
1075-
Utils.EnqueueIfNotNull(warningMsgs, warning);
1076-
Utils.EnqueueIfNotNull(errorMsgs, error);
1077-
10781075
return false;
10791076
}
10801077

src/code/Utils.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,16 +2329,13 @@ internal static bool CheckAuthenticodeSignature(
23292329
string pkgName,
23302330
string tempDirNameVersion,
23312331
PSCmdlet cmdletPassedIn,
2332-
out string warning,
2333-
out ErrorRecord errorRecord)
2332+
ConcurrentQueue<ErrorRecord> errorMsgs,
2333+
ConcurrentQueue<string> warningMsgs)
23342334
{
2335-
warning = string.Empty;
2336-
errorRecord = null;
2337-
23382335
// Because authenticode and catalog verifications are only applicable on Windows, we allow all packages by default to be installed on unix systems.
2339-
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
2336+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
23402337
{
2341-
warning = "Authenticode check cannot be performed on Linux or MacOS.";
2338+
warningMsgs.Enqueue("Authenticode check cannot be performed on Linux or MacOS.");
23422339
return true;
23432340
}
23442341

@@ -2360,11 +2357,11 @@ internal static bool CheckAuthenticodeSignature(
23602357
}
23612358
catch (Exception e)
23622359
{
2363-
errorRecord = new ErrorRecord(
2360+
errorMsgs.Enqueue(new ErrorRecord(
23642361
new ArgumentException(e.Message),
23652362
"GetAuthenticodeSignatureError",
23662363
ErrorCategory.InvalidResult,
2367-
cmdletPassedIn);
2364+
cmdletPassedIn));
23682365

23692366
return false;
23702367
}
@@ -2375,11 +2372,11 @@ internal static bool CheckAuthenticodeSignature(
23752372
Signature signature = (Signature)signatureObject.BaseObject;
23762373
if (!signature.Status.Equals(SignatureStatus.Valid))
23772374
{
2378-
errorRecord = new ErrorRecord(
2375+
errorMsgs.Enqueue(new ErrorRecord(
23792376
new ArgumentException($"The signature status for '{pkgName}' file '{Path.GetFileName(signature.Path)}' is '{signature.Status}'. Status message: '{signature.StatusMessage}'"),
23802377
"GetAuthenticodeSignatureError",
23812378
ErrorCategory.InvalidResult,
2382-
cmdletPassedIn);
2379+
cmdletPassedIn));
23832380

23842381
return false;
23852382
}

test/FindPSResourceTests/FindPSResourceRepositorySearching.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Describe 'Test Find-PSResource for searching and looping through repositories' -
128128

129129
It "find multiple resources from all repositories where it exists where package Name contains wildcard (without -Repository specified)" {
130130
$res = Find-PSResource -Name "test_module*" -ErrorVariable err -ErrorAction SilentlyContinue
131-
$res | Should -HaveCount 11
131+
$res | Should -HaveCount 12
132132
$err | Should -HaveCount 0
133133

134134
$pkgFoundinLocalRepo = $false

0 commit comments

Comments
 (0)