aquasecurity/tfsec-azure-pipelines-task

bug: tfsec fails

vanmash opened this issue ยท 4 comments

tfsec task fails when run on windows-latest in Azure DevOps pipeline

version: 1.26.2
OS: windows-latest

 - task: tfsec@1
    inputs:
      version: 'v1.26.2'
      dir: 'terraform'

log

2022-07-07T10:39:14.7100342Z ##[section]Starting: tfsec
2022-07-07T10:39:14.7248842Z ==============================================================================
2022-07-07T10:39:14.7249171Z Task         : tfsec: Secure your Terraform
2022-07-07T10:39:14.7249518Z Description  : tfsec uses static analysis of your terraform code to spot potential misconfigurations and help you to resolve them.
2022-07-07T10:39:14.7249850Z Version      : 1.2.1
2022-07-07T10:39:14.7250023Z Author       : Aqua Security
2022-07-07T10:39:14.7250338Z Help         : [Learn more about this task](https://github.com/aquasecurity/tfsec-azure-pipelines-task)
2022-07-07T10:39:14.7250679Z ==============================================================================
2022-07-07T10:39:15.0561266Z Finding correct tfsec version...
2022-07-07T10:39:15.0578133Z Required tfsec version is v1.26.2
2022-07-07T10:39:15.0634038Z Downloading tfsec...
2022-07-07T10:39:15.0693912Z Downloading: https://github.com/aquasecurity/tfsec/releases/download/v1.26.2/tfsec-windows-amd64.exe
2022-07-07T10:39:17.4091243Z Preparing output location...
2022-07-07T10:39:17.4118684Z Configuring options...
2022-07-07T10:39:17.4132564Z Running tfsec...
2022-07-07T10:39:17.4146453Z [command]D:\a\_temp\%userprofile%\AppData\Local\Temp\tfsec.exe -f junit,json -O %userprofile%\AppData\Local\Temp\tfsec-results-0.0892454241710825 terraform
2022-07-07T10:39:17.9348154Z WARNING: A tfvars file was found but not automatically used. Did you mean to specify the --tfvars-file flag?
2022-07-07T10:39:17.9349426Z Error: failed to write output: open %userprofile%\AppData\Local\Temp\tfsec-results-0.0892454241710825.junit: The system cannot find the path specified.
2022-07-07T10:39:17.9400846Z ##[error]Failed: tfsec detected misconfigurations.
2022-07-07T10:39:17.9413927Z Publishing JUnit results...
2022-07-07T10:39:20.0271268Z Result Attachments will be stored in LogStore
2022-07-07T10:39:20.0629916Z Run Attachments will be stored in LogStore
2022-07-07T10:39:20.9611932Z Failed to parse result files: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\agents\2.204.0\bin\%userprofile%\AppData\Local\Temp\tfsec-results-0.0892454241710825.junit'.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
   at System.Xml.XmlTextReaderImpl.FinishInitUriString()
   at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
   at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
   at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings)
   at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.ReadFile(String filePath, XmlDocument doc)
   at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.ParseTestResultFile(TestRunContext runContext, String filePath)
   at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.<>c__DisplayClass1_0.<ParseTestResultFiles>b__0(String file)
   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
   at Microsoft.TeamFoundation.TestClient.PublishTestResults.JUnitResultParser.ParseTestResultFiles(TestRunContext runContext, IList`1 resultFilePaths)
   at Microsoft.VisualStudio.Services.Agent.Worker.TestResults.Parser.ParseFiles(IExecutionContext executionContext, TestRunContext testRunContext, List`1 testResultsFiles, ITestResultParser testResultParser)
2022-07-07T10:39:20.9660324Z Publishing JSON results...
2022-07-07T10:39:20.9756183Z ##[error]Unable to process command '##vso[task.addattachment type=JSON_RESULT;name=results.json;]%AZP25userprofile%AZP25\AppData\Local\Temp\tfsec-results-0.0892454241710825.json' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
2022-07-07T10:39:20.9760138Z ##[error]Value cannot be null. (Parameter 'Cannot upload task attachment file, attachment file location is not specified or attachment file not exist on disk')
2022-07-07T10:39:20.9763597Z Tidying up...
2022-07-07T10:39:20.9764329Z Done!
2022-07-07T10:39:20.9805960Z ##[section]Async Command Start: Publish test results
2022-07-07T10:39:21.0090671Z ##[section]Async Command End: Publish test results
2022-07-07T10:39:21.0094180Z ##[section]Finishing: tfsec

Hi @liamg
any progress on that?

liamg commented

Apologies for the delay @vanmash - I'll look at this today!

liamg commented

Version v1.2.2 is building now - it should be available in 10-15 minutes

Thanks Liam!