microsoft / security-devops-action

Microsoft Security DevOps for GitHub Actions.
MIT License
104 stars 47 forks source link

Error running bandit - bandit_runner.exe not found #58

Open piraces opened 1 year ago

piraces commented 1 year ago

Hello. I'm setting up the action in multiple repositories and all of them fails in the same step, while trying to execute bandit.

Logs:

Error:      Error running tool 2 of 5: bandit
Error:      Error running bandit job: 1 of 1
Error:      ToolLauncherNotFoundException: Could not successfully find the D:\a\_msdo\packages\nuget\Microsoft.Guardian.BanditRedist_windows_amd64.1.6.3.1\tools\bandit_runner.exe tool launcher. Please ensure any dependent frameworks are installed.
Error:      Win32Exception: An error occurred trying to start process 'D:\a\_msdo\packages\nuget\Microsoft.Guardian.BanditRedist_windows_amd64.1.6.3.1\tools\bandit_runner.exe' with working directory 'D:\a\AzureGoat\AzureGoat'. The filename or extension is too long.
Error:      BreakException: Guardian detected one or more breaking results.
Error: Error: The process 'D:\a\_msdo\versions\microsoft.security.devops.cli\0.163.0\tools\guardian.cmd' failed with exit code 1

The action run resides in: https://github.com/rpiraces-plain/AzureGoat/actions/runs/5164467559/jobs/9303379837

How can I fix this? I have set up anything wrong?

Edit: Works perfectly fine with ubuntu-latest runner... seems it only fails with windows-latest runner.

JiandongJiang commented 1 year ago

From the logs, it looks like that the Bandit issue was caused by the length of the Bandit command line too long ("The filename or extension is too long." in the log) due to the command length restriction on Windows. As a workaround, to shorten the length of the Bandit command line on Windows, you can follow the wiki at "https://github.com/microsoft/security-devops-action/wiki#bandit-options" to configure the Target argument so as for Bandit to scan fewer files and see if it will resolve the issue. If you need Bandit to scan more files, you can follow the same wiki to create a *.gdnconfig file to run Bandit multiple times on different targets. Meanwhile, we will seek if there could be a way to better handle it.

piraces commented 1 year ago

Thank you for your response @JiandongJiang ! I will try to do that 👍