Files
oc-sentinel/src/AttackTracerNinjaCli/Commands/ScanAndUploadCommand.cs
OfficeCom Codex 85e394f647
Some checks failed
OfficeCom Sentinel Client / build-client (push) Has been cancelled
Adopt OCSentinel script layout and add Gitea workflow
2026-07-17 00:50:26 +02:00

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]);
}
}