42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
namespace AttackTracerNinjaCli.Commands;
|
|
|
|
internal static class ScanAndUploadCommand
|
|
{
|
|
public static int Execute(string[] args)
|
|
{
|
|
string outputPath = @"C:\ProgramData\OCSentinel\reports\latest.json";
|
|
bool hasOutput = false;
|
|
|
|
for (int i = 0; i < args.Length; i++)
|
|
{
|
|
if (string.Equals(args[i], "--output", StringComparison.OrdinalIgnoreCase) && i + 1 < args.Length)
|
|
{
|
|
outputPath = args[i + 1];
|
|
hasOutput = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
List<string> scanArgs = [.. args];
|
|
if (!hasOutput)
|
|
{
|
|
scanArgs.Add("--output");
|
|
scanArgs.Add(outputPath);
|
|
}
|
|
|
|
int scanExitCode = ScanCommand.Execute([.. scanArgs]);
|
|
if (scanExitCode != 0)
|
|
{
|
|
return scanExitCode;
|
|
}
|
|
|
|
var uploadArgs = new List<string>
|
|
{
|
|
"--report",
|
|
outputPath
|
|
};
|
|
|
|
return UploadCommand.Execute([.. uploadArgs]);
|
|
}
|
|
}
|