Configure upload during Ninja bootstrap
Some checks failed
OfficeCom Sentinel Client / validate-client (push) Successful in 25s
OfficeCom Sentinel Client / build-client-windows (push) Has been cancelled

This commit is contained in:
OfficeCom Codex
2026-07-25 02:33:02 +02:00
parent 053d601e93
commit b1ee79ca02
2 changed files with 45 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
[CmdletBinding()]
param(
[string]$ManifestUrl = "https://gitea.officecom.cloud/officecom/oc-sentinel/raw/main/release/stable/version.json",
[string]$WebhookUrl = "",
[string]$SecretValue = "",
[switch]$RunInitialStatusScan
)
@@ -12,6 +14,9 @@ $installRoot = Join-Path $env:ProgramFiles "OCSentinel"
$updaterPath = Join-Path $installRoot "scripts\update-ocsentinel.ps1"
$monitorPath = Join-Path $installRoot "scripts\run-ocsentinel-monitor.ps1"
$appPath = Join-Path $installRoot "app\OCSentinelCli.exe"
$clientConfigPath = Join-Path $installRoot "config\ocsentinel-client.json"
$secretScriptPath = Join-Path $installRoot "scripts\protect-ocsentinel-secret.ps1"
$secretPath = "C:\ProgramData\OCSentinel\secrets\ocsentinel-upload-secret.dat"
function Assert-ArtifactSignature {
param([Parameter(Mandatory)][string]$ExecutablePath)
@@ -80,13 +85,41 @@ if (-not (Test-Path -LiteralPath $appPath)) {
throw "OCSentinel installation completed, but the client executable was not found."
}
if (-not [string]::IsNullOrWhiteSpace($WebhookUrl)) {
if (-not (Test-Path -LiteralPath $clientConfigPath)) {
throw "OCSentinel client configuration was not found: $clientConfigPath"
}
$clientConfig = Get-Content -LiteralPath $clientConfigPath -Raw | ConvertFrom-Json
$clientConfig.n8nWebhookUrl = $WebhookUrl
$clientConfig.environment = "production"
$clientConfig | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $clientConfigPath -Encoding UTF8
Write-Host "Configured OCSentinel upload endpoint."
}
if (-not [string]::IsNullOrWhiteSpace($SecretValue)) {
if (-not (Test-Path -LiteralPath $secretScriptPath)) {
throw "OCSentinel secret bootstrap script was not found: $secretScriptPath"
}
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $secretScriptPath -SecretValue $SecretValue
if ($LASTEXITCODE -ne 0) {
throw "OCSentinel secret bootstrap failed with code $LASTEXITCODE"
}
}
if ($RunInitialStatusScan) {
if (-not (Test-Path -LiteralPath $monitorPath)) {
throw "OCSentinel was installed, but the monitor script is missing."
}
Write-Host "Running initial OCSentinel status scan."
& powershell.exe -NoProfile -ExecutionPolicy Bypass -File $monitorPath -Mode status -OutputPath "..\\reports\\ocsentinel-summary.json"
$scanArguments = @("-NoProfile", "-ExecutionPolicy", "Bypass", "-File", $monitorPath, "-Mode", "status", "-OutputPath", "..\\reports\\ocsentinel-summary.json")
if ((Test-Path -LiteralPath $clientConfigPath) -and (Test-Path -LiteralPath $secretPath)) {
$scanArguments += @("-ClientConfigPath", $clientConfigPath, "-SecretPath", $secretPath, "-UploadMode", "required")
}
& powershell.exe @scanArguments
if ($LASTEXITCODE -ne 0) {
throw "Initial OCSentinel status scan exited with code $LASTEXITCODE"
}

View File

@@ -3,6 +3,10 @@ param(
[int]$TopCount = 10,
[string]$OutputPath = ".\reports\ocsentinel-summary.json",
[string]$ConfigPath = ".\config\ocsentinel-settings.example.json",
[string]$ClientConfigPath = ".\config\ocsentinel-client.json",
[string]$SecretPath = "",
[ValidateSet("disabled", "auto", "required")]
[string]$UploadMode = "auto",
[string]$VulnerabilityCsvPath = "",
[string]$MirrorRoot = "",
[ValidateSet("status", "attack-only", "cve-critical", "attack-plus-cve")]
@@ -142,9 +146,15 @@ $runnerArgs = @(
"-LookbackDays", $LookbackDays,
"-TopCount", $TopCount,
"-OutputPath", $OutputPath,
"-ConfigPath", $ConfigPath
"-ConfigPath", $ConfigPath,
"-ClientConfigPath", $ClientConfigPath,
"-UploadMode", $UploadMode
)
if (-not [string]::IsNullOrWhiteSpace($SecretPath)) {
$runnerArgs += @("-SecretPath", $SecretPath)
}
if (-not [string]::IsNullOrWhiteSpace($VulnerabilityCsvPath)) {
$runnerArgs += @("-VulnerabilityCsvPath", $VulnerabilityCsvPath)
}