
YG790424 (Community Member) asked a question.
Application Name: Dayforce HCM
I am using the veracodeC#API.exe wrapper to upload and scan my code which is already built in Debug and bundled in to Zip. Below are two samples that I can use to upload:
Example 1
-----------
$appname = "Dayforce HCM"
$command = $PSScriptRoot, "veracodeC#API.exe" -join "\"
$userid = "my API ID"
$password = "my API Secret Key"
$action ="Uploadandscan"
$toplevel = "true"
$createprofile = "false"
$autoscan = "true"
$final_remote_archive_name = "D:\Veracode\Scans\20191127T1555199329\bindayforcehcm_2019-11-27.zip"
$veracode_scanname = "DFDebugBuild_2019-11-28"
$arguments = "-action=$action -vid=$userid -vkey=$password -appname=$appname -toplevel=$toplevel -createprofile=$createprofile -filepath=$final_remote_archive_name -version=$veracode_scanname -autoscan=$autoscan"
& $command -action $action -vid=($userid.ToString()) -vkey=($password.ToString()) -appname $appname -toplevel $toplevel -createprofile $createprofile -filepath $final_remote_archive_name -version $veracode_scanname -autoscan $autoscan
Using the call operator (&) I am able to upload and submit for a scan but capturing errors using the call operator difficult as $LastErrorCode variable doesn't always gets populated. I therefore tried another way. See below.
Example 2
-----------
$appname = "Dayforce HCM"
$command = $PSScriptRoot, "veracodeC#API.exe" -join "\"
$userid = "my API ID"
$password = "my API Secret Key"
$action ="Uploadandscan"
$toplevel = "true"
$createprofile = "false"
$autoscan = "true"
$final_remote_archive_name = "D:\Veracode\Scans\20191127T1555199329\bindayforcehcm_2019-11-27.zip"
$veracode_scanname = "DFDebugBuild_2019-11-28"
$arguments = "-action=$action -vid=$userid -vkey=$password -appname=$appname -toplevel=$toplevel -createprofile=$createprofile -filepath=$final_remote_archive_name -version=$veracode_scanname -autoscan=$autoscan"
$proc_info = New-Object System.Diagnostics.ProcessStartInfo
$proc_info.FileName = $command
$proc_info.RedirectStandardError = $true
$proc_info.RedirectStandardOutput = $true
$proc_info.UseShellExecute = $false
$proc_info.Arguments = $arguments
$proc = New-Object System.Diagnostics.Process
$proc.StartInfo = $proc_info
$proc.Start() | Out-Null
$proc.WaitForExit()
$stdout = $proc.StandardOutput.ReadToEnd()
$stderr = $proc.StandardError.ReadToEnd()
Write-Host "stdout: $stdout"
Write-Host "stderr: $stderr"
Write-Host "exit code: " + $proc.ExitCode
When I run this code the white space in $appname gets ignored.
This is is the output:
stdout:
stderr: [19.11.29 15:40:29]
[19.11.29 15:40:29] An app_id could not be located for application profile "Dayforce".
exit code: + 2
Note that the white space and the second part of the name is completely ignored.
If I change the name of the application on the Veracode portal to get rid of the whitespace everything works fine but this is
an unacceptable solution. I would appreciate anyone's ideas and help.
Thank you.
.png)
Hi the problem is related to how Windows PS is treating stings with white spaces in them. It appears that it's not handling strings with White Spaces as complete strings. If the appname is "My Application" then the string has to be $appname = "`"My Application`""
Winnows PS will then treat it as a whole string.