Initial OfficeCom Sentinel client and deployment assets
This commit is contained in:
74
build/build-client-package.ps1
Normal file
74
build/build-client-package.ps1
Normal file
@@ -0,0 +1,74 @@
|
||||
param(
|
||||
[string]$Configuration = "Release"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$projectPath = Join-Path $repoRoot "src\AttackTracerNinjaCli\AttackTracerNinjaCli.csproj"
|
||||
$installerRoot = Join-Path $repoRoot "installer"
|
||||
$artifactsRoot = Join-Path $repoRoot "artifacts"
|
||||
$publishRoot = Join-Path $artifactsRoot "publish\win-x64"
|
||||
$packageRoot = Join-Path $artifactsRoot "client-package"
|
||||
$zipPath = Join-Path $artifactsRoot "OCSentinelClient-win-x64.zip"
|
||||
|
||||
[xml]$projectXml = Get-Content $projectPath
|
||||
$version = $projectXml.Project.PropertyGroup.Version | Select-Object -First 1
|
||||
if ([string]::IsNullOrWhiteSpace($version)) {
|
||||
$version = "0.0.0"
|
||||
}
|
||||
|
||||
Write-Host "Building OfficeCom Sentinel client package version $version"
|
||||
|
||||
if (Test-Path $publishRoot) { Remove-Item -LiteralPath $publishRoot -Recurse -Force }
|
||||
if (Test-Path $packageRoot) { Remove-Item -LiteralPath $packageRoot -Recurse -Force }
|
||||
if (Test-Path $zipPath) { Remove-Item -LiteralPath $zipPath -Force }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $publishRoot, $packageRoot | Out-Null
|
||||
New-Item -ItemType Directory -Force -Path (Join-Path $packageRoot "app"), (Join-Path $packageRoot "scripts"), (Join-Path $packageRoot "config"), (Join-Path $packageRoot "samples") | Out-Null
|
||||
|
||||
& dotnet restore $projectPath -r win-x64
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "dotnet restore failed"
|
||||
}
|
||||
|
||||
& dotnet publish $projectPath `
|
||||
-c $Configuration `
|
||||
-r win-x64 `
|
||||
--self-contained true `
|
||||
-p:PublishSingleFile=true `
|
||||
-p:IncludeNativeLibrariesForSelfExtract=true `
|
||||
-o $publishRoot
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "dotnet publish failed"
|
||||
}
|
||||
|
||||
Copy-Item -Path (Join-Path $publishRoot "OCSentinelCli.exe") -Destination (Join-Path $packageRoot "app\OCSentinelCli.exe") -Force
|
||||
if (Test-Path (Join-Path $publishRoot "OCSentinelCli.pdb")) {
|
||||
Copy-Item -Path (Join-Path $publishRoot "OCSentinelCli.pdb") -Destination (Join-Path $packageRoot "app\OCSentinelCli.pdb") -Force
|
||||
}
|
||||
|
||||
Copy-Item -Path (Join-Path $installerRoot "install-attacktracer-ninja.ps1") -Destination (Join-Path $packageRoot "scripts\install-ocsentinel.ps1") -Force
|
||||
Copy-Item -Path (Join-Path $installerRoot "uninstall-attacktracer-ninja.ps1") -Destination (Join-Path $packageRoot "scripts\uninstall-ocsentinel.ps1") -Force
|
||||
Copy-Item -Path (Join-Path $installerRoot "update-attacktracer-ninja.ps1") -Destination (Join-Path $packageRoot "scripts\update-ocsentinel.ps1") -Force
|
||||
Copy-Item -Path (Join-Path $installerRoot "runtime-run-attacktracer-ninja.ps1") -Destination (Join-Path $packageRoot "scripts\run-ocsentinel.ps1") -Force
|
||||
Copy-Item -Path (Join-Path $installerRoot "runtime-run-attacktracer-ninja-monitor.ps1") -Destination (Join-Path $packageRoot "scripts\run-ocsentinel-monitor.ps1") -Force
|
||||
Copy-Item -Path (Join-Path $repoRoot "scripts\protect-attacktracer-secret.ps1") -Destination (Join-Path $packageRoot "scripts\protect-ocsentinel-secret.ps1") -Force
|
||||
|
||||
Copy-Item -Path (Join-Path $repoRoot "config\attacktracer-settings.example.json") -Destination (Join-Path $packageRoot "config\ocsentinel-settings.example.json") -Force
|
||||
Copy-Item -Path (Join-Path $repoRoot "config\attacktracer-client.example.json") -Destination (Join-Path $packageRoot "config\ocsentinel-client.example.json") -Force
|
||||
Copy-Item -Path (Join-Path $repoRoot "config\update-channel.example.json") -Destination (Join-Path $packageRoot "config\update-channel.example.json") -Force
|
||||
Copy-Item -Path (Join-Path $repoRoot "samples\ninja-vulnerability-export.example.csv") -Destination (Join-Path $packageRoot "samples\ninja-vulnerability-export.example.csv") -Force
|
||||
Copy-Item -Path (Join-Path $repoRoot "samples\webhook-payload.example.json") -Destination (Join-Path $packageRoot "samples\webhook-payload.example.json") -Force
|
||||
Copy-Item -Path (Join-Path $installerRoot "README.txt") -Destination (Join-Path $packageRoot "README.txt") -Force
|
||||
|
||||
Set-Content -Path (Join-Path $packageRoot "VERSION.txt") -Value $version -NoNewline
|
||||
|
||||
Compress-Archive -Path (Join-Path $packageRoot "*") -DestinationPath $zipPath -CompressionLevel Optimal -Force
|
||||
|
||||
$sha256 = (Get-FileHash -Path $zipPath -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||
Set-Content -Path ($zipPath + ".sha256") -Value "$sha256 $(Split-Path -Leaf $zipPath)" -NoNewline
|
||||
|
||||
Write-Host "OfficeCom Sentinel client package created at $zipPath"
|
||||
Write-Host "SHA256: $sha256"
|
||||
47
build/build-release-manifest.ps1
Normal file
47
build/build-release-manifest.ps1
Normal file
@@ -0,0 +1,47 @@
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$ArtifactUrl,
|
||||
[string]$Channel = "stable",
|
||||
[string]$PackagePath = ".\artifacts\OCSentinelClient-win-x64.zip",
|
||||
[string]$OutputPath = ".\artifacts\version.json",
|
||||
[string]$MinUpdaterVersion = "1.0.0"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$projectPath = Join-Path $repoRoot "src\AttackTracerNinjaCli\AttackTracerNinjaCli.csproj"
|
||||
$packageFullPath = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $PackagePath))
|
||||
$outputFullPath = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $OutputPath))
|
||||
|
||||
if (-not (Test-Path $packageFullPath)) {
|
||||
throw "Package not found: $packageFullPath"
|
||||
}
|
||||
|
||||
[xml]$projectXml = Get-Content $projectPath
|
||||
$version = $projectXml.Project.PropertyGroup.Version | Select-Object -First 1
|
||||
if ([string]::IsNullOrWhiteSpace($version)) {
|
||||
$version = "0.0.0"
|
||||
}
|
||||
|
||||
$sha256 = (Get-FileHash -Path $packageFullPath -Algorithm SHA256).Hash.ToLowerInvariant()
|
||||
|
||||
$manifest = [ordered]@{
|
||||
channel = $Channel
|
||||
version = $version
|
||||
publishedAtUtc = (Get-Date).ToUniversalTime().ToString("o")
|
||||
artifactUrl = $ArtifactUrl
|
||||
sha256 = $sha256
|
||||
minUpdaterVersion = $MinUpdaterVersion
|
||||
}
|
||||
|
||||
$outputDirectory = Split-Path -Parent $outputFullPath
|
||||
if (-not [string]::IsNullOrWhiteSpace($outputDirectory)) {
|
||||
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
|
||||
}
|
||||
|
||||
$manifest | ConvertTo-Json -Depth 5 | Set-Content -Path $outputFullPath -Encoding UTF8
|
||||
|
||||
Write-Host "Release manifest written to $outputFullPath"
|
||||
Write-Host "Version: $version"
|
||||
Write-Host "SHA256: $sha256"
|
||||
Reference in New Issue
Block a user