Add the fixed Windows LocalService hello to the cloud acceptance path
Rust development slice / linux (push) Failing after 6s

This commit is contained in:
2026-11-15 21:44:36 +01:00
parent 6fb973a247
commit 97d4f86940
2 changed files with 84 additions and 5 deletions
+52 -5
View File
@@ -6,6 +6,7 @@ Credentials stay on the cloud server; the browser reads its protected login
file. All SQL is fixed read-only evidence, scoped to the one cloud VM.
"""
import argparse
from datetime import timedelta
import hashlib
import http.client
import json
@@ -24,6 +25,38 @@ import vm_mvp_acceptance as contract
ROOT = bootstrap.ROOT
TENANT = bootstrap.TENANT
require = bootstrap.require
WINDOWS_AGENT = '63ea15b2-0643-403d-b5b4-cba1288dbea3'
WINDOWS_ASSET = 'a176520e-8a91-4e93-a78b-8e7620f430e0'
WINDOWS_SCRIPT = "Write-Output 'Zeitprofil-Test'\r\n"
WINDOWS_STDOUT = 'Zeitprofil-Test\r\n'
def windows_hello_input():
start = contract.now()
return dict(
tenant_id=TENANT, action='run_script', targets=dict(asset_ids=[WINDOWS_ASSET]),
parameters=dict(
execution_identity='agent_service', timeout_seconds=60, max_output_bytes=65536,
arguments=[], expected_stdout=WINDOWS_STDOUT,
variants=[dict(os_family='windows', interpreter='powershell', encoding='utf-8',
script_utf8=WINDOWS_SCRIPT, windows_execution_profile='powershell_51_remote_signed')]),
schedule=contract.schedule(start, start + timedelta(minutes=15)),
rollout=dict(max_parallel=1, halt_after_failures=1),
reason='Erste genehmigte PowerShell-Textausgabe auf der Windows-Test-VM')
def verify_windows_hello(result):
report = result['result']
proof = report['evidence']
contract.require(result['state'] == 'succeeded' and report['exit_code'] == 0
and bytes(report['stdout']) == WINDOWS_STDOUT.encode() and bytes(report['stderr']) == b''
and report['output_truncated'] is False and proof['postconditions_passed'] is True
and proof['execution_sid'] == 'S-1-5-19' and proof['interpreter'] == 'powershell'
and proof['script_sha256'] == hashlib.sha256(WINDOWS_SCRIPT.encode()).hexdigest()
and proof['windows_execution_profile'] == 'powershell_51_remote_signed'
and proof['execution_policy'] == 'process_remote_signed_requested'
and proof['execution_policy_requested'] == 'RemoteSigned'
and proof['execution_policy_scope'] == 'process', 'windows_hello_evidence')
def prepare_browser():
@@ -147,13 +180,18 @@ class Backend:
def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--execute-dev-test-ui',action='store_true',required=True)
parser.add_argument('--case',choices=('hello','refresh_inventory','cancel_queued'),default='hello')
parser.add_argument('--case',choices=('hello','refresh_inventory','cancel_queued','windows_hello'),default='hello')
parser.add_argument('--transport',choices=('wss','https'))
args=parser.parse_args();os.umask(0o077)
contract.require(not (Path.home()/'.local/share/rust-discovery/remote-agent').exists(),'notebook_must_not_have_client')
prepare_browser()
installed=contract.protected_json(ROOT/'devstate/remote-vm.json')
identity=installed['identity']
windows = args.case == 'windows_hello'
if windows:
contract.require(args.transport is None, 'windows_keep_current_transport')
identity = dict(agent_id=WINDOWS_AGENT, asset_id=WINDOWS_ASSET)
else:
prepare_browser()
installed=contract.protected_json(ROOT/'devstate/remote-vm.json')
identity=installed['identity']
settings=dict(tenant_id=TENANT,**identity)
def evidence(kind,**extra):
return bootstrap.rpc('server.conf',server,dict(kind=kind,tenant_id=TENANT,agent_id=identity['agent_id'],**extra))
@@ -172,11 +210,18 @@ def main():
observed=bootstrap.rpc('server.conf',bootstrap.server,dict(action='observe',agent_id=identity['agent_id']))
contract.require(observed['sync_ready'] and not observed['restore_blocked'],'signed_sync_gate_required')
needed={'refresh_inventory' if args.case=='refresh_inventory' else 'run_script','rmm.sync.v1'}
if windows:
needed.update(('windows.base/1', 'script.powershell/1', 'script.powershell.process_remote_signed/1'))
contract.require(needed<=set(device['capabilities']),'actual_vm_capability_required')
request=contract.case_input(args.case,settings)
if windows:
prepare_browser()
request=windows_hello_input() if windows else contract.case_input(args.case,settings)
plan=backend.call('operations.plan',dict(tenant_id=TENANT,input=request))
contract.require(hashlib.sha256(bytes(plan['plan_payload_bytes'])).hexdigest()==plan['plan_hash'] and len(plan['jobs'])==1,'immutable_plan')
job=plan['jobs'][0]
if windows:
contract.require(job['payload']['agent_id']==WINDOWS_AGENT and job['payload']['asset_id']==WINDOWS_ASSET
and job['payload']['tenant_id']==TENANT, 'fixed_windows_target_required')
folder=ROOT/'devstate/cloud-acceptance'/uuid.uuid4().hex;folder.mkdir(mode=0o700,parents=True)
checkpoint=dict(profile='dev/test',case=args.case,expected_principal='simulated-testprincipal-a',**settings,
plan=plan,job=job,stage='planned',no_retry=True,transport=observed['transport'],server_connection=observed)
@@ -205,6 +250,8 @@ def main():
contract.require(result['state']=='succeeded' and result['result']['evidence']['postconditions_passed'],'native_postconditions_required')
if args.case=='hello':
contract.require(result['result']['exit_code']==0 and bytes(result['result']['stdout'])==b'Hello World\n','exact_stdout_required')
elif windows:
verify_windows_hello(result)
elif args.case=='refresh_inventory':
contract.require(contract.timestamp(result['result']['evidence']['observed_at'])>=contract.timestamp(request['schedule']['not_before']),'fresh_inventory_required')
gate=evidence('gate',job_id=job['job_id']);audit=evidence('audit',operation_id=pending['operation_id'])