Skip to content

Commit ab34966

Browse files
CBenoitCopilot
andauthored
feat(agent)!: expose active package policy (#1937)
Exposes the validated active package-broker policy through the authenticated `GET /v1/policy` route. Clients receive a stable snapshot, while an unavailable policy returns the shared structured 404 response without exposing policy source or file-security details. Uses the official `now-policy` 0.3.0, `now-policy-api` 0.4.0, and `now-policy-server-template` 0.4.0 releases. Phase 1 remains read-only: policy management, validation, and replacement routes are not exposed. Package policy files are now JSON-only. Deployments using `.yaml` or `.yml` policy files must convert them to `.json`; unsupported extensions and YAML content are rejected rather than silently parsed. Coordinated stack: Devolutions/now-libraries#93 defines the shared contract, this PR implements the Agent endpoint, and Devolutions/UniGetUI#5292 consumes it. Keep this PR open while Phase 2 #1963 is restacked and the full stack is finalized. BREAKING CHANGE: Package broker policy files must use JSON; YAML and YML are no longer discovered or parsed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 0323437 commit ab34966

16 files changed

Lines changed: 941 additions & 105 deletions

File tree

.github/workflows/ci.yml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,65 @@ jobs:
12701270
psexec -accepteula -s pwsh.exe $scriptPath
12711271
Get-Content -Path ./crates/pedm-simulator/pedm-simulator_run-expect-elevation.out
12721272
1273+
agent-policy-e2e:
1274+
name: Agent policy end-to-end test
1275+
runs-on: windows-2022
1276+
needs: [preflight]
1277+
1278+
steps:
1279+
- name: Checkout ${{ github.repository }}
1280+
uses: actions/checkout@v6
1281+
with:
1282+
ref: ${{ needs.preflight.outputs.ref }}
1283+
1284+
- name: Setup Rust cache
1285+
uses: ./.github/actions/setup-rust-cache
1286+
with:
1287+
sccache-enabled: ${{ needs.preflight.outputs.sccache }}
1288+
1289+
# Keep this installation aligned with the PEDM simulator job.
1290+
- name: Install PsExec
1291+
shell: pwsh
1292+
run: |
1293+
$expectedHash = '4F49964CC9CBAC2B5D87BDC8F9526012E9C4B243D8B7D0C0BB51F254A721CA2E'
1294+
$zipPath = Join-Path $env:RUNNER_TEMP 'PSTools.zip'
1295+
$toolsDir = Join-Path $env:RUNNER_TEMP 'PSTools'
1296+
Invoke-WebRequest -Uri 'https://download.sysinternals.com/files/PSTools.zip' -OutFile $zipPath
1297+
$actualHash = (Get-FileHash -Path $zipPath -Algorithm SHA256).Hash
1298+
if ($actualHash -ne $expectedHash) {
1299+
throw "PSTools.zip checksum mismatch: expected $expectedHash, got $actualHash"
1300+
}
1301+
Expand-Archive -Path $zipPath -DestinationPath $toolsDir
1302+
Add-Content -Path $env:GITHUB_PATH -Value $toolsDir
1303+
1304+
- name: Build Agent policy test executables
1305+
shell: pwsh
1306+
run: |
1307+
cargo build --locked -p devolutions-agent --features dev-skip-broker-signature
1308+
if ($LASTEXITCODE -ne 0) {
1309+
exit $LASTEXITCODE
1310+
}
1311+
cargo build --locked -p agent-policy-tester
1312+
if ($LASTEXITCODE -ne 0) {
1313+
exit $LASTEXITCODE
1314+
}
1315+
1316+
- name: Run Agent policy tester as LocalSystem
1317+
shell: pwsh
1318+
run: |
1319+
$scriptPath = Resolve-Path -Path "./crates/agent-policy-tester/run-as-system.ps1"
1320+
psexec -accepteula -s pwsh.exe -NoProfile -File $scriptPath
1321+
$exitCode = $LASTEXITCODE
1322+
Get-Content -Path ./crates/agent-policy-tester/agent-policy-tester.out
1323+
if ($exitCode -ne 0) {
1324+
exit $exitCode
1325+
}
1326+
1327+
- name: Show sccache stats
1328+
if: ${{ needs.preflight.outputs.sccache == 'true' && !cancelled() }}
1329+
shell: pwsh
1330+
run: sccache --show-stats
1331+
12731332
secure-memory-verifier:
12741333
name: secure-memory-verifier
12751334
runs-on: windows-2022
@@ -1298,7 +1357,7 @@ jobs:
12981357
success:
12991358
name: Success
13001359
if: ${{ always() }}
1301-
needs: [tests, agent-tunnel-e2e, lints, check-dependencies, jetsocat-lipo, devolutions-gateway-powershell, devolutions-gateway, devolutions-gateway-merge, devolutions-pedm-desktop, devolutions-agent, devolutions-agent-merge, devolutions-pedm-client, dotnet-utils-tests, winapi-sanitizer-tests, winapi-miri, pedm-simulator, secure-memory-verifier]
1360+
needs: [tests, agent-tunnel-e2e, agent-policy-e2e, lints, check-dependencies, jetsocat-lipo, devolutions-gateway-powershell, devolutions-gateway, devolutions-gateway-merge, devolutions-pedm-desktop, devolutions-agent, devolutions-agent-merge, devolutions-pedm-client, dotnet-utils-tests, winapi-sanitizer-tests, winapi-miri, pedm-simulator, secure-memory-verifier]
13021361
runs-on: ubuntu-latest
13031362

13041363
steps:

0 commit comments

Comments
 (0)