Open chryzsh opened 1 year ago
Hi. This issue is still hampering a lot of our automated campaign templates and we've had to hardcode quite a lot more than we would like to workaround it. Could we please get an estimate on a fix, or some possible workarounds? We previously reported a simliar issue with variables in automation that you fixed fairly quickly: https://github.com/SecurityRiskAdvisors/VECTR/issues/215
Describe the bug In automatic execution of test cases, when using the powershell executor, the Runtime Override of Variables¶ does not apply. This only applies to the powershell executor, not inline powershell or cmd. That is because the powershell script that is generated includes the hardcoded values from the test case, and not the replaced variables, and thus won't be overridden by env vars when the automation binary calls "powershell.exe -file testcase.ps1". I guess a possible fix would be to override the variables with env vars in the string that is to be executed before its written to the ps1 file.
To Reproduce Steps to reproduce the behavior.
Preparation:
Execution:
set "VECTR_username=testuser
or the powershell equivalent$env:VECTR_username="testuser"
Expected behavior I expected the command which is written to the PS1 file to contain the values replaced by environment variables I set in the Powershell console window I ran the test from.
Screenshots The first screenshot, shows how the test case is configured, with the preview window indicating how the test will be executed and what will be written to the PS1 file. This is correct.![image](https://user-images.githubusercontent.com/2836099/207904295-e7f056b3-85e3-4264-873d-170d4eefb2c0.png)
The second screenshot show how the environment variable VECTR_command_to_execute is set in the Powershell window, but is not written to the PS1 script when the automation binary is executed.![image](https://user-images.githubusercontent.com/2836099/207904724-9da66f0c-b8f8-4e00-96d1-407305b79b4d.png)
Desktop (please complete the following information):
Additional context Confirmed by Galen at SRA in the official Discord