azsk / ADOScanner

Source code repository for ADO Security Scanner.
MIT License
28 stars 14 forks source link

ADO extension: Could not find file #623

Open danielstefanescu opened 1 year ago

danielstefanescu commented 1 year ago

Could not find file

Task: Azure DevOps (ADO) Security Scanner

Using the task in the Azure Pipelines Pool - windows-latest image is displaying an error.

Steps to reproduce

Add the Azure DevOps (ADO) Security Scanner task to a pipeline:

pool:
  vmImage: windows-latest

steps:
  - task: ADOSecurityScanner@1
    inputs:
      ADOConnectionName: 'foobar'
      OrgName: '$(System.CollectionUri)'
      ProjectNames: '$(System.TeamProject)'
      ScanFilter: 'Org_Project_User'

Expected behavior

No error messages.

Actual behavior

Add-Type : Could not find file 'D:\a_tasks\ADOSecurityScanner_0f42e73b-1b51-41b9-8bd2-c1a864393316\1.5.7\ps_modules\VstsTaskSdk\VstsTaskSdk.dll'. At D:\a_tasks\ADOSecurityScanner_0f42e73b-1b51-41b9-8bd2-c1a864393316\1.5.7\ps_modules\VstsTaskSdk\VstsTaskSdk.psm1:20 char:1

v-dpardeshi commented 5 months ago

Could you please confirm if, after encountering this error, you are still able to run the ADO Security Scanner extension in the pipeline, or if it becomes stuck in the error state?

sckissel commented 4 months ago

I also see this error both in self-hosted and MSFT agents. The pipeline does complete in my pipeline with MSFT agents, but in the self-hosted agents, the pipeline becomes stuck in an error state. The error occurs right after the AzSK.ADO modules are successfully installed:

[debug]Module 'AzSK.ADO' was installed successfully to path 'C:\Users\TFSServiceSvc\Documents\WindowsPowerShell\Modules\AzSK.ADO\1.21.0'.

[debug]00:01:03.0693295 Done calling powershell «Install-Package» «PSModule»

[debug]Error record:

[debug]Invoke-VstsTaskScript : Unable to find type [VstsTaskSdk.TerminationException].

[debug]At line:1 char:907

[debug]+ ... Continue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create ...

[debug]+ ~~~~~~~~~~~~~

[debug] + CategoryInfo : InvalidOperation: (VstsTaskSdk.TerminationException:TypeName) [Invoke-VstsTaskScript], R untimeException

[debug] + FullyQualifiedErrorId : TypeNotFound,Invoke-VstsTaskScript

[debug]

[debug]Script stack trace:

[debug]at , : line 18

[debug]at , : line 1

[debug]Exception:

[debug]System.Management.Automation.RuntimeException: Unable to find type [VstsTaskSdk.TerminationException].

[debug] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)

[debug] at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)

[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

[debug] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

[debug] at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)

[debug] at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)

[debug] at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)

[debug] at System.Management.Automation.PSScriptCmdlet.DoEndProcessing()

[debug] at System.Management.Automation.CommandProcessorBase.Complete()

[error]Unable to find type [VstsTaskSdk.TerminationException].

[debug]Processed: ##vso[task.logissue type=error]Unable to find type [VstsTaskSdk.TerminationException].

[debug]Agent running environment resource - Disk:D:\ available:323982.00MB out of 1048444.00MB, Memory: used 33MB out of 32767MB, CPU: usage 5.86

[error]Exit code 1 returned from process: file name 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe', arguments '-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ([scriptblock]::Create('if ([Console]::InputEncoding -is [Text.UTF8Encoding] -and [Console]::InputEncoding.GetPreamble().Length -ne 0) { [Console]::InputEncoding = New-Object Text.UTF8Encoding $false } if (!$PSHOME) { $null = Get-Item -LiteralPath ''variable:PSHOME'' } else { Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1'')) ; Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1'')) }')) 2>&1 | ForEach-Object { Write-Verbose $_.Exception.Message -Verbose } ; Import-Module -Name 'D:\Agent01_work_tasks\ADOSecurityScanner_0f42e73b-1b51-41b9-8bd2-c1a864393316\1.5.7\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1' -ArgumentList @{ NonInteractive = $true } -ErrorAction Stop ; $VerbosePreference = 'Continue' ; $DebugPreference = 'Continue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ''D:\Agent01_work_tasks\ADOSecurityScanner_0f42e73b-1b51-41b9-8bd2-c1a864393316\1.5.7\ADOSecurityScannerSVTRuntime.ps1'''))"'.

[debug]Microsoft.VisualStudio.Services.Agent.Util.ProcessExitCodeException: Exit code 1 returned from process: file name 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe', arguments '-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". ([scriptblock]::Create('if ([Console]::InputEncoding -is [Text.UTF8Encoding] -and [Console]::InputEncoding.GetPreamble().Length -ne 0) { [Console]::InputEncoding = New-Object Text.UTF8Encoding $false } if (!$PSHOME) { $null = Get-Item -LiteralPath ''variable:PSHOME'' } else { Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1'')) ; Import-Module -Name ([System.IO.Path]::Combine($PSHOME, ''Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1'')) }')) 2>&1 | ForEach-Object { Write-Verbose $_.Exception.Message -Verbose } ; Import-Module -Name 'D:\Agent01_work_tasks\ADOSecurityScanner_0f42e73b-1b51-41b9-8bd2-c1a864393316\1.5.7\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1' -ArgumentList @{ NonInteractive = $true } -ErrorAction Stop ; $VerbosePreference = 'Continue' ; $DebugPreference = 'Continue' ; Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ''D:\Agent01_work_tasks\ADOSecurityScanner_0f42e73b-1b51-41b9-8bd2-c1a864393316\1.5.7\ADOSecurityScannerSVTRuntime.ps1'''))"'.

at Microsoft.VisualStudio.Services.Agent.Util.ProcessInvoker.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in D:\a\1\s\src\Agent.Sdk\ProcessInvoker.cs:line 381 at Microsoft.VisualStudio.Services.Agent.ProcessInvokerWrapper.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, InputQueue1 redirectStandardIn, Boolean inheritConsoleHandler, Boolean keepStandardInOpen, Boolean highPriorityProcess, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in D:\a\1\s\src\Microsoft.VisualStudio.Services.Agent\ProcessInvoker.cs:line 308 at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.DefaultStepHost.ExecuteAsync(String workingDirectory, String fileName, String arguments, IDictionary`2 environment, Boolean requireExitCodeZero, Encoding outputEncoding, Boolean killProcessOnCancel, Boolean inheritConsoleHandler, Boolean continueAfterCancelProcessTreeKillAttempt, CancellationToken cancellationToken) in D:\a\1\s\src\Agent.Worker\Handlers\StepHost.cs:line 76 at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.PowerShell3Handler.RunAsync() in D:\a\1\s\src\Agent.Worker\Handlers\PowerShell3Handler.cs:line 73 at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync() in D:\a\1\s\src\Agent.Worker\TaskRunner.cs:line 410 at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken) in D:\a\1\s\src\Agent.Worker\StepsRunner.cs:line 263 Finishing: ADO Security Scanner