当您从命令行调用 UploadAndScan 操作时,您通常会传递的内容或多或少如下所示:
VeracodeC#API.exe -action uploadandscan -appname appName -version version -createprofile true -filepath filePath -vuser 用户名 -vpassword 密码
因此,要使您的代码正常工作,您需要按如下方式对其进行修改:
using System;
using System.Reflection;
using com.veracode.apiwrapper;
namespace ConsoleApplication3
{
using System;
{
static void Main()
{
//----------------------------------------------------------
String appName = "enter-application-name-here";
String version = "enter-version-here";
bool createProfile = true;//or false;
String filePath = "enter-filepath-here";//ie: "C:\\file.exe"
String username = "enter-username-here";
String password = "enter-password-here";
//----------------------------------------------------------
//String[] args = <the same args that you pass when you call the UploadAndScan composite action>;
String[] args = new String[]
{
"-action", "uploadandscan",
"-appname", appName,
"-version", version,
"-createprofile", createProfile.ToString(),
"-filepath", filePath,
"-vuser", username,
"-vpassword", password
};
Type t = System.Reflection.Assembly.GetAssembly(typeof(AbstractAPIWrapper)).GetType("com.veracode.apiwrapper.cli.VeracodeCommand");
MethodInfo m = t.GetMethod("Main", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
m.Invoke(null, new Object[] { args });
Console.Read();
}
}
}