microsoft / security-devops-action

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

The "path" argument must be of type string. Received type undefined #57

Open RodrigoTAlmeida opened 1 year ago

RodrigoTAlmeida commented 1 year ago

Hello,

I'm incorporating this in my pipelines and it's working for yaml pipeline but when I try to run the "Run Microsoft Defender for DevOps" task on a classical release pipeline I get this error : "TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined". I've been following some tutorials online and all of them indicate that I do not need to add anything to the parameters of the task. All connection have been made on Azure side and I even tried adding a .gdnconfig file but I get the same error.

image

Some help would be immensely appreciated. Thanks for your time and efforts.

boAndron commented 1 year ago

Hello. Thanks for reporting this issue! I took a look through the task files(here) and there don't appear to be any arguments named "path". I also tried to repro unsuccessfully on a Classic Pipeline. Are you sure this error is coming from the MSDO task?
Where do you get this error? Can you post or send me the full console log for the MSDO task? Thanks!

RodrigoTAlmeida commented 1 year ago

Are you sure this error is coming from the MSDO task? Where do you get this error? Can you post or send me the full console log for the MSDO task? Thanks!

Thanks for replying!

It's the only task running on that stage :

image

image

And here is the full log :

2023-05-31T08:04:48.5818020Z ##[debug]Evaluating condition for step: 'Run Microsoft Defender for DevOps' 2023-05-31T08:04:48.5833784Z ##[debug]Evaluating: succeeded() 2023-05-31T08:04:48.5834027Z ##[debug]Evaluating succeeded: 2023-05-31T08:04:48.5834523Z ##[debug]=> True 2023-05-31T08:04:48.5834758Z ##[debug]Result: True 2023-05-31T08:04:48.5834997Z ##[section]Starting: Run Microsoft Defender for DevOps 2023-05-31T08:04:48.6142085Z ============================================================================== 2023-05-31T08:04:48.6142475Z Task : Microsoft Security DevOps 2023-05-31T08:04:48.6142681Z Description : Run the Microsoft Security DevOps CLI for static analysis. 2023-05-31T08:04:48.6142805Z Version : 1.6.0 2023-05-31T08:04:48.6142980Z Author : Microsoft Corporation 2023-05-31T08:04:48.6143262Z Help : Runs the Microsoft Security DevOps CLI for security analysis. 2023-05-31T08:04:48.6143373Z ============================================================================== 2023-05-31T08:04:48.6832478Z ##[debug]Using node path: C:\agents\3.220.2\externals\node10\bin\node.exe 2023-05-31T08:04:49.0550895Z ##[debug]agent.TempDirectory=D:\a_temp 2023-05-31T08:04:49.0552231Z ##[debug]loading inputs and endpoints 2023-05-31T08:04:49.0556625Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN 2023-05-31T08:04:49.0691814Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION 2023-05-31T08:04:49.0694626Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION 2023-05-31T08:04:49.0697116Z ##[debug]loading INPUT_ARTIFACTNAME 2023-05-31T08:04:49.0698868Z ##[debug]loading INPUT_BREAK 2023-05-31T08:04:49.0700672Z ##[debug]loading INPUT_POLICY 2023-05-31T08:04:49.0702352Z ##[debug]loading INPUT_PUBLISH 2023-05-31T08:04:49.0712501Z ##[debug]loading SANITIZED 2023-05-31T08:04:49.0715012Z ##[debug]loading SANITIZED 2023-05-31T08:04:49.0724394Z ##[debug]loaded 9 2023-05-31T08:04:49.0730841Z ##[debug]Agent.ProxyUrl=undefined 2023-05-31T08:04:49.0731814Z ##[debug]Agent.CAInfo=undefined 2023-05-31T08:04:49.0732294Z ##[debug]Agent.ClientCert=undefined 2023-05-31T08:04:49.0732827Z ##[debug]Agent.SkipCertValidation=undefined 2023-05-31T08:04:49.0778174Z ##[debug]config=undefined 2023-05-31T08:04:49.0787582Z ##[debug]policy=microsoft 2023-05-31T08:04:49.0788044Z ##[debug]categories=undefined 2023-05-31T08:04:49.0788641Z ##[debug]languages=undefined 2023-05-31T08:04:49.0789134Z ##[debug]tools=undefined 2023-05-31T08:04:49.0790077Z ##[debug]publish=true 2023-05-31T08:04:49.0791673Z ##[debug]artifactName=CodeAnalysisLogs 2023-05-31T08:04:49.0792900Z ##[debug]break=false 2023-05-31T08:04:49.0831852Z ##[debug]task result: Failed 2023-05-31T08:04:49.0863689Z ##[error]TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined 2023-05-31T08:04:49.0871060Z ##[debug]Processed: ##vso[task.issue type=error;]TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined 2023-05-31T08:04:49.0876922Z ##[debug]Processed: ##vso[task.complete result=Failed;]TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined 2023-05-31T08:04:49.1018701Z ##[section]Finishing: Run Microsoft Defender for DevOps

boAndron commented 1 year ago

Thanks for the details. I'm still having trouble pinning this down. That error can show up when calling path.join with a null / undefined value. Looking through our code and based on the console logs, the only place this could be happening (unless it is happening in an AzDO function) is here The call is let agentDirectory = path.join(process.env.AGENT_ROOTDIRECTORY, '_msdo'); and the only part of that that could be undefined is process.env.AGENT_ROOTDIRECTORY - which is supposed to be a predefined AzDO variable. Could you add a powershell task (or something similar) to check the value of that variable before the MSDO task? Sorry for the trouble, unfortunately I can't repro. Thanks!

RodrigoTAlmeida commented 1 year ago

Thanks for the details. I'm still having trouble pinning this down. That error can show up when calling path.join with a null / undefined value. Looking through our code and based on the console logs, the only place this could be happening (unless it is happening in an AzDO function) is here The call is let agentDirectory = path.join(process.env.AGENT_ROOTDIRECTORY, '_msdo'); and the only part of that that could be undefined is process.env.AGENT_ROOTDIRECTORY - which is supposed to be a predefined AzDO variable. Could you add a powershell task (or something similar) to check the value of that variable before the MSDO task? Sorry for the trouble, unfortunately I can't repro. Thanks!

I will perform this soon ( I will be going on a short vacation), I have not forgotten about this! Thanks for your support on this, really appreciate it!

RodrigoTAlmeida commented 1 year ago

I have some updates on this. I was placing this task on a Release pipeline that has its artifact source from an Azure Repo and not from a build task: azrepo_source This doesn't seem to work at all even though the first job that runs on that release pipeline is the repo download. As for the outputs of the asked variables on this pipeline: image They appear to be empty.

But as a workaround I tried to create a Classical Pipeline, very simple pipeline with just one task and it works: pipeline_scan pipeline_success

Not sure what to make of this.