diff --git a/deploy/script_console_windows_acceptance.py b/deploy/script_console_windows_acceptance.py new file mode 100644 index 0000000..ff65f7e --- /dev/null +++ b/deploy/script_console_windows_acceptance.py @@ -0,0 +1,226 @@ +#!/usr/bin/env python3 +"""Current Windows units: list-only first, then one explicit list-hash-bound run. + +Parent executes only after source review. No deployment, RMM/UI jobs, service, +SQL, helper, capability, time-policy or production-clock changes. +""" +import argparse +import base64 +import hashlib +import json +import os +from pathlib import Path +import re +import uuid + +ROOT = Path(__file__).resolve().parents[1] +SUPPORT = { + 'deploy/script_console_acceptance.py': '2b3ba8d548d18627643a9f73c9a4f7bacce4ac2cd5495745c6760d088e078145', + 'deploy/windows_msi_runtime_acceptance.py': '833ad8806c90a19342aa6fbc71c33e81975caffb1746550e9b0fbdca7fa0c7ab', + 'deploy/vm_access_check.py': '5c8107ea9151a9f498b2530cdc61c1a7a6d745aff853a9b05710f3395838c0dd', + 'deploy/script_console_windows_link.py': '7c770c4537f1e0bd4e7583f4af5fab0934065970d2f2aec9d7a42ecdc98d4089', +} + +def sha(path): + return hashlib.sha256(Path(path).read_bytes()).hexdigest() + + +def require(value, code): + if not value: + raise RuntimeError(code) + + +def support_guards(): + require(all(not (ROOT/n).is_symlink() and sha(ROOT/n)==h for n,h in SUPPORT.items()), 'reviewed bootstrap sources unchanged') + + +support_guards() +import script_console_acceptance as native +support = native.support +require(Path(native.__file__).resolve()==ROOT/'deploy/script_console_acceptance.py' + and Path(support.__file__).resolve()==ROOT/'deploy/windows_msi_runtime_acceptance.py' + and Path(support.access.__file__).resolve()==ROOT/'deploy/vm_access_check.py','exact pinned transport module origins') +PACK = ROOT/'devstate/script-console-windows-link/run-d0b7c844-6770-4930-ac87-4380c87fbad7' +PACK_SHA = '4b31e6a997248f91db00cf56d7d6043a6feb840be237b9a5a5de5eb71ee4b80c' +LINUX = ROOT/'devstate/script-console-native/7b61ce46-7913-492b-9c6b-414a0c2b6ffc/passed-e214cd9b-21ac-48ce-82dc-d10364329d04.json' +LINUX_SHA = 'a831a70a3cf76a3e8a9bf5820dcca7100d2ef9860dd9388539fe9c13f949f470' +STATE = ROOT/'devstate/script-console-windows-native' +PROFILE = 'script-console-windows-units-v1' +KINDS = {'lib':'windows-lib-tests.exe','bin':'windows-agent-tests.exe'} +REMOTE = '/C:/ProgramData/RustDiscoveryBootstrap/script-console-units-' +FLAGS = ('product_state_writes','rmm_jobs','approvals','capabilities_activated','clock_qualified','helper_runtime_qualified','sql_changed') + + +SCRIPT = r''' +$ErrorActionPreference='Stop';$request=([Console]::In.ReadLine()|ConvertFrom-Json) +function HashBytes([byte[]]$b){$h=[Security.Cryptography.SHA256]::Create();try{return ([BitConverter]::ToString($h.ComputeHash($b))).Replace('-','').ToLowerInvariant()}finally{$h.Dispose()}} +$raw=[Convert]::FromBase64String($request.intent_bytes_b64);if($raw.Length-gt196608-or(HashBytes $raw)-cne$request.intent_sha256){throw 'Exact bounded original intent bytes'} +$p=[Text.Encoding]::UTF8.GetString($raw)|ConvertFrom-Json +if([string]([guid]$p.id)-cne$p.id-or$p.profile-cne'script-console-windows-units-v1'-or$request.action-notin@('prepare','list','run','read')-or$p.manifest_sha256-notmatch'^[a-f0-9]{64}$'-or$p.runner_sha256-notmatch'^[a-f0-9]{64}$'-or$p.script_sha256-notmatch'^[a-f0-9]{64}$'-or$p.linux_proof_sha256-notmatch'^[a-f0-9]{64}$'){throw 'Fixed Windows script-console unit intent'} +$root='C:\ProgramData\RustDiscoveryBootstrap';$case=Join-Path $root ('script-console-units-'+$p.id) +function Safe($path,$dir){$i=Get-Item -LiteralPath $path -Force;if($i.PSIsContainer-ne$dir-or($i.Attributes-band[IO.FileAttributes]::ReparsePoint)){throw 'Fixed unit path type'};$a=Get-Acl -LiteralPath $path;if($a.GetOwner([Security.Principal.SecurityIdentifier]).Value-notin@('S-1-5-18','S-1-5-32-544')){throw 'Private unit owner'};$rules=@($a.GetAccessRules($true,$true,[Security.Principal.SecurityIdentifier]));if(!$rules.Count){throw 'Empty private unit ACL'};foreach($e in $rules){if($e.AccessControlType-ne'Allow'-or$e.IdentityReference.Value-notin@('S-1-5-18','S-1-5-32-544')-or($e.PropagationFlags-band[Security.AccessControl.PropagationFlags]::InheritOnly)){throw 'Broad private unit ACL'}}} +function WriteBytes($path,[byte[]]$b){$f=[IO.File]::Open($path,'CreateNew','Write','Read');try{$f.Write($b,0,$b.Length);$f.Flush($true)}finally{$f.Dispose()}} +function WriteNew($path,$value){WriteBytes $path ([Text.Encoding]::UTF8.GetBytes(($value|ConvertTo-Json -Depth 24 -Compress)))} +function ReadPrivate($path){Safe $path $false;if((Get-Item -LiteralPath $path).Length-gt8388608){throw 'Bounded unit receipt'};return (Get-Content -LiteralPath $path -Raw|ConvertFrom-Json)} +if($request.action-eq'read'-and!(Test-Path -LiteralPath $case)){@{id=$p.id;readback_only=$true;case_present=$false}|ConvertTo-Json -Compress;exit 0} +Safe $root $true +if($request.action-eq'prepare'){if(Test-Path -LiteralPath $case){throw 'Existing case: readback only'};New-Item -ItemType Directory -Path $case|Out-Null;Safe $case $true;WriteBytes (Join-Path $case 'intent.json') $raw;@{id=$p.id;prepared=$true}|ConvertTo-Json -Compress;exit 0} +Safe $case $true;Safe (Join-Path $case 'intent.json') $false;if((Get-FileHash -LiteralPath (Join-Path $case 'intent.json') -Algorithm SHA256).Hash.ToLowerInvariant()-cne$request.intent_sha256){throw 'Original complete intent retained'} +if($request.action-eq'read'){ + $partial=@{};foreach($name in @('lists.json','list-lib.json','list-bin.json','run-lib.json','run-bin.json','result.json')){$path=Join-Path $case $name;if(Test-Path -LiteralPath $path){$partial[$name]=ReadPrivate $path}} + $listPath=Join-Path $case 'lists.json';$listBytes=$(if(Test-Path -LiteralPath $listPath){[IO.File]::ReadAllBytes($listPath)}else{$null}) + @{id=$p.id;readback_only=$true;case_present=$true;list_entered=(Test-Path -LiteralPath (Join-Path $case 'list-entered.json'));run_entered=(Test-Path -LiteralPath (Join-Path $case 'run-entered.json'));lists_sha256=$(if($null-ne$listBytes){HashBytes $listBytes}else{$null});lists_bytes_b64=$(if($null-ne$listBytes){[Convert]::ToBase64String($listBytes)}else{$null});partial=$partial;tests_repeated=$false}|ConvertTo-Json -Depth 24 -Compress;exit 0 +} +if(!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)){throw 'Bootstrap administrator unit context required'} +# Native OS directory + a checked Windows environment, never arbitrary inherited +# variables. SystemDrive is required by the native inventory unit and retained. +$system32=[Environment]::SystemDirectory;$windows=[IO.Directory]::GetParent($system32).FullName;$drive=[IO.Path]::GetPathRoot($windows).TrimEnd('\') +if($drive-notmatch'^[A-Za-z]:$'-or$windows-ine($drive+'\Windows')-or$system32-ine($windows+'\System32')-or$env:WINDIR-ine$windows-or$env:SystemRoot-ine$windows-or($env:SystemDrive-and$env:SystemDrive-ine$drive)-or!(Test-Path -LiteralPath $system32 -PathType Container)){throw 'Checked native SystemDrive/WINDIR/SystemRoot required'} +$temp=Join-Path $case 'tmp' +if($request.action-eq'list'){WriteNew (Join-Path $case 'list-entered.json') @{list_once=$true;intent_sha256=$request.intent_sha256};New-Item -ItemType Directory -Path $temp|Out-Null};Safe $temp $true +function RunUnit($exe,[string]$arguments){$s=New-Object Diagnostics.ProcessStartInfo;$s.FileName=$exe;$s.Arguments=$arguments;$s.UseShellExecute=$false;$s.CreateNoWindow=$true;$s.WorkingDirectory=$case;$s.RedirectStandardOutput=$true;$s.RedirectStandardError=$true;$s.EnvironmentVariables.Clear();$s.EnvironmentVariables['SystemRoot']=$windows;$s.EnvironmentVariables['WINDIR']=$windows;$s.EnvironmentVariables['SystemDrive']=$drive;$s.EnvironmentVariables['PATH']=$system32;$s.EnvironmentVariables['TEMP']=$temp;$s.EnvironmentVariables['TMP']=$temp;$s.EnvironmentVariables['RUST_BACKTRACE']='0';$c=New-Object Diagnostics.Process;$c.StartInfo=$s;if(!$c.Start()){throw 'Unit start'};try{$o=$c.StandardOutput.ReadToEndAsync();$e=$c.StandardError.ReadToEndAsync();$timed=$false;if(!$c.WaitForExit(30000)){$timed=$true;$c.Kill();if(!$c.WaitForExit(2000)){throw 'Own unit process did not exit'}};if(!$o.Wait(2000)-or!$e.Wait(2000)-or$o.Result.Length-gt1048576-or$e.Result.Length-gt1048576){throw 'Bounded unit output'};return @{exit_code=$c.ExitCode;timed_out=$timed;stdout_b64=[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($o.Result));stderr_b64=[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($e.Result))}}finally{$c.Dispose()}} +$paths=@{} +foreach($kind in @('lib','bin')){$a=$p.artifacts.$kind;$exe=Join-Path $case ($kind+'.exe');Safe $exe $false;if($a.sha256-notmatch'^[a-f0-9]{64}$'-or(Get-FileHash -LiteralPath $exe -Algorithm SHA256).Hash.ToLowerInvariant()-cne$a.sha256-or(Get-Item -LiteralPath $exe).Length-ne$a.bytes){throw 'Exact current Windows unit delivery'};$paths[$kind]=$exe} +if($request.action-eq'list'){ + $lists=@{};foreach($kind in @('lib','bin')){$listed=RunUnit $paths[$kind] '--list --format terse';$text=[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($listed.stdout_b64));[string[]]$lines=@($text-split'\r?\n'|Where-Object{$_.Trim()});if($listed.exit_code-ne0-or$listed.timed_out-or@($lines|Where-Object{$_-notmatch'^[A-Za-z0-9_:]+: test$'}).Count){throw 'Only complete actual native terse test entries'};[string[]]$names=@($lines|ForEach-Object{$_-replace': test$',''});[Array]::Sort($names,[StringComparer]::Ordinal);if($names.Count-lt1-or$names.Count-gt512-or@($names|Select-Object -Unique).Count-ne$names.Count){throw 'Bounded distinct complete names'};$value=@{sha256=$p.artifacts.$kind.sha256;names=$names;listed=$listed};WriteNew (Join-Path $case ('list-'+$kind+'.json')) $value;$lists[$kind]=$value} + $value=@{id=$p.id;profile=$p.profile;manifest_sha256=$p.manifest_sha256;intent_sha256=$request.intent_sha256;linux_proof_sha256=$p.linux_proof_sha256;lists=$lists;actual_native_lists=$true;tests_executed=$false;environment=@{SystemRoot=$windows;WINDIR=$windows;SystemDrive=$drive};environment_cleared=$true;product_state_writes=$false;rmm_jobs=$false;approvals=$false;capabilities_activated=$false;clock_qualified=$false;helper_runtime_qualified=$false;sql_changed=$false};$path=Join-Path $case 'lists.json';WriteNew $path $value;$bytes=[IO.File]::ReadAllBytes($path);@{id=$p.id;lists_sha256=(HashBytes $bytes);lists_bytes_b64=[Convert]::ToBase64String($bytes);tests_executed=$false}|ConvertTo-Json -Depth 24 -Compress;exit 0 +} +if($request.lists_sha256-notmatch'^[a-f0-9]{64}$'){throw 'Explicit list SHA required'};$path=Join-Path $case 'lists.json';Safe $path $false;if((Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash.ToLowerInvariant()-cne$request.lists_sha256){throw 'Original complete list bytes'};$lists=ReadPrivate $path +if($lists.id-cne$p.id-or$lists.intent_sha256-cne$request.intent_sha256-or$lists.manifest_sha256-cne$p.manifest_sha256-or!$lists.actual_native_lists-or$lists.tests_executed){throw 'Actual original list-only proof'} +WriteNew (Join-Path $case 'run-entered.json') @{execute_tests_once=$true;lists_sha256=$request.lists_sha256};$reports=@{} +foreach($kind in @('lib','bin')){if($lists.lists.$kind.sha256-cne$p.artifacts.$kind.sha256){throw 'Exact list executable binding'};$run=RunUnit $paths[$kind] '--test-threads=1';$value=@{sha256=$p.artifacts.$kind.sha256;names=$lists.lists.$kind.names;result=$run};WriteNew (Join-Path $case ('run-'+$kind+'.json')) $value;$reports[$kind]=$value;if($run.exit_code-ne0-or$run.timed_out){throw 'Native unit failed; original case readback only'}} +$value=@{id=$p.id;manifest_sha256=$p.manifest_sha256;intent_sha256=$request.intent_sha256;lists_sha256=$request.lists_sha256;reports=$reports;all_lists_before_any_tests=$true;environment_cleared=$true;bootstrap_administrator_units=$true;local_service_proof=$false;native_pipe_proof=$false;product_state_writes=$false;rmm_jobs=$false;approvals=$false;capabilities_activated=$false;clock_qualified=$false;helper_runtime_qualified=$false;sql_changed=$false};WriteNew (Join-Path $case 'result.json') $value;$value|ConvertTo-Json -Depth 24 -Compress +''' + + +def guards(): + support_guards();native.verify_support() + require(sha(PACK/'manifest.json')==PACK_SHA and sha(LINUX)==LINUX_SHA, 'current pack and Linux84 receipt exact') + manifest=support.load(PACK/'manifest.json');proof=support.load(LINUX) + require(manifest['source_manifest_sha256']==native.MANIFEST_SHA and manifest['linux_native_proof_sha256']==LINUX_SHA + and manifest['linux_actual_passed']==84 and manifest['linux_explicit_database_ignored']==5 + and manifest['source_before_after_equal'] is True and manifest['windows_target']=='x86_64-pc-windows-gnu' + and manifest['pipe_v2_sha256']=='ce525dab23f2e4faa2c9816280c1a5a8b40e56d0e63a350256e83b2df1d9229d' + and all(manifest[f] is False for f in ('windows_native_lists_executed','windows_native_tests_executed','clock_qualified','capabilities_activated','deployed','rmm_jobs','approvals')), + 'current qualified Windows link-only generation') + require(proof['verified'] is True and proof['manifest_sha256']==native.MANIFEST_SHA + and proof['native']['passed']==84 and proof['native']['ignored_database_cases']==5 + and all(proof['native'][f] is False for f in ('product_state_writes','rmm_jobs','capabilities_activated','approvals')), 'actual Linux84 scope') + require(sha(native.PACK/'manifest.json')==native.MANIFEST_SHA and len(manifest['source_files'])==158 + and manifest['source_files']==support.load(native.PACK/'manifest.json')['source_files'] + and all(not (ROOT/n).is_symlink() and sha(ROOT/n)==h for n,h in manifest['source_files'].items()), 'all frozen158 inputs unchanged') + require(set(manifest['artifacts'])=={'windows-lib-tests.exe','windows-agent-tests.exe','rmm-helper-windows.exe','rmm-agent-windows.exe'}, 'all four current PE deliveries') + for name,item in manifest['artifacts'].items(): + for suffix,key,size in (('', 'sha256','bytes'),('.original','original_sha256','original_bytes')): + path=PACK/(name+suffix);support.private(path) + require(sha(path)==item[key] and path.stat().st_size==item[size], 'all exact delivery/original PE bytes') + return manifest + + +def encoded(intent): + return json.dumps(intent,sort_keys=True,separators=(',',':')).encode() + + +def rpc(intent,action,folder,lists_sha=None): + guards() + require(intent['runner_sha256']==sha(__file__) and intent['script_sha256']==hashlib.sha256(SCRIPT.encode()).hexdigest() + and intent['support_sha256']==SUPPORT,'same original runner/script/support before every target call') + raw=encoded(intent);payload=dict(intent_bytes_b64=base64.b64encode(raw).decode(),intent_sha256=hashlib.sha256(raw).hexdigest(),action=action) + if lists_sha is not None:payload['lists_sha256']=lists_sha + wrapper='try {\n'+SCRIPT+'\n} catch {[pscustomobject]@{bootstrap_error=$true;error_id=$_.FullyQualifiedErrorId;line=$_.InvocationInfo.ScriptLineNumber}|ConvertTo-Json -Compress;exit 1}' + command='powershell.exe -NoLogo -NoProfile -NonInteractive -EncodedCommand '+base64.b64encode(wrapper.encode('utf-16le')).decode() + return support.transport(support.access_settings(support.ACCESS_ROOT,'windows'),command,(json.dumps(payload)+'\n').encode(),folder,timeout=110) + + +def checked_lists(raw,intent,expected_sha): + require(hashlib.sha256(raw).hexdigest()==expected_sha and len(raw)<=8*1024*1024,'exact bounded immutable list bytes') + value=json.loads(raw,object_pairs_hook=support.object_pairs) + require(value['id']==intent['id'] and value['profile']==PROFILE and value['manifest_sha256']==PACK_SHA + and value['intent_sha256']==hashlib.sha256(encoded(intent)).hexdigest() and value['linux_proof_sha256']==LINUX_SHA + and value['actual_native_lists'] is True and value['tests_executed'] is False + and value['environment_cleared'] is True and set(value['lists'])==set(KINDS) + and all(value[f] is False for f in FLAGS),'list-only provenance and scope') + env=value['environment'];require(set(env)=={'SystemRoot','WINDIR','SystemDrive'} and re.fullmatch(r'[A-Za-z]:',env['SystemDrive']) + and env['SystemRoot'].lower()==env['WINDIR'].lower()==(env['SystemDrive']+'\\Windows').lower(),'checked minimal native test environment') + for kind,item in value['lists'].items(): + listed=item['listed'];text=base64.b64decode(listed['stdout_b64'],validate=True).decode();lines=[line for line in text.splitlines() if line.strip()] + require(item['sha256']==intent['artifacts'][kind]['sha256'] and listed['exit_code']==0 and listed['timed_out'] is False + and all(re.fullmatch(r'[A-Za-z0-9_:]+: test',line) for line in lines) + and sorted(line[:-6] for line in lines)==item['names'] and len(set(item['names']))==len(lines) + and 1<=len(lines)<=512,'actual complete distinct named native list') + return value + + +def checked_result(value,intent,lists,lists_sha): + require(value['id']==intent['id'] and value['manifest_sha256']==PACK_SHA + and value['intent_sha256']==hashlib.sha256(encoded(intent)).hexdigest() and value['lists_sha256']==lists_sha + and set(value['reports'])==set(KINDS) and value['all_lists_before_any_tests'] is True + and value['environment_cleared'] is True and value['bootstrap_administrator_units'] is True + and value['local_service_proof'] is False and value['native_pipe_proof'] is False + and all(value[f] is False for f in FLAGS),'exact narrow final unit scope') + for kind,report in value['reports'].items(): + result=report['result'];text=base64.b64decode(result['stdout_b64'],validate=True).decode();names=lists['lists'][kind]['names'];count=len(names) + require(report['sha256']==intent['artifacts'][kind]['sha256'] and report['names']==names + and result['exit_code']==0 and result['timed_out'] is False + and sorted(re.findall(r'^test (.+) \.\.\. ok\r?$',text,re.M))==names + and re.search(r'^test result: ok\. '+str(count)+r' passed; 0 failed; 0 ignored; 0 measured; 0 filtered out;',text,re.M), + 'all exact current named tests passed, no skips or filtering') + + +def retain_original_lists(folder,raw,intent,digest): + value=checked_lists(raw,intent,digest);path=folder/'lists-original.json' + if path.exists(): + support.private(path);require(path.read_bytes()==raw,'original native list bytes never replaced') + else: + with path.open('xb') as out:out.write(raw);out.flush();os.fsync(out.fileno()) + return value + + +def retain_passed(folder,result,intent,lists,digest): + checked_result(result,intent,lists,digest);guards() + proof=dict(verified=True,manifest_sha256=PACK_SHA,linux_native_proof_sha256=LINUX_SHA,lists_sha256=digest,native=result) + path=folder/'passed.json' + if path.exists():require(support.load(path)==proof,'original native proof never replaced') + else:support.save(path,proof) + + +def main(): + parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('mode',choices=('prepare-local','list','run','read'));parser.add_argument('--case');parser.add_argument('--lists-sha');args=parser.parse_args() + os.umask(0o077);STATE.mkdir(mode=0o700,parents=True,exist_ok=True);support.private(STATE,True);manifest=guards() + if args.mode=='prepare-local': + require(args.case is None and args.lists_sha is None,'new local intent only');case=str(uuid.uuid4());folder=STATE/case;folder.mkdir(mode=0o700) + intent=dict(id=case,profile=PROFILE,manifest_sha256=PACK_SHA,linux_proof_sha256=LINUX_SHA,runner_sha256=sha(__file__),script_sha256=hashlib.sha256(SCRIPT.encode()).hexdigest(),support_sha256=SUPPORT, + artifacts={kind:{key:manifest['artifacts'][name][key] for key in ('sha256','bytes')} for kind,name in KINDS.items()}) + support.save(folder/'intent.json',intent) + else: + case=str(uuid.UUID(args.case));require(case==args.case,'canonical original case');folder=STATE/case;intent=support.load(folder/'intent.json') + expected=dict(id=case,profile=PROFILE,manifest_sha256=PACK_SHA,linux_proof_sha256=LINUX_SHA,runner_sha256=sha(__file__),script_sha256=hashlib.sha256(SCRIPT.encode()).hexdigest(),support_sha256=SUPPORT, + artifacts={kind:{key:manifest['artifacts'][name][key] for key in ('sha256','bytes')} for kind,name in KINDS.items()}) + require(intent==expected,'complete original same-source JSON case for every readback') + if args.mode=='list': + require(args.lists_sha is None,'list-only step');support.save(folder/'list-entered-local.json',dict(list_once=True,no_retry=True)) + result=rpc(intent,'prepare',folder);support.save(folder/'prepared-remote.json',result);require(result['prepared'] is True,'new exact remote unit case') + for kind,name in KINDS.items(): + guards();support.upload(support.access_settings(support.ACCESS_ROOT,'windows'),dict(path=str(PACK/name),**intent['artifacts'][kind]),REMOTE+case+'/'+kind+'.exe',folder,kind) + result=rpc(intent,'list',folder);support.save(folder/'list-reply.json',result) + raw=base64.b64decode(result['lists_bytes_b64'],validate=True);retain_original_lists(folder,raw,intent,result['lists_sha256']) + print(json.dumps(dict(case_id=case,mode='list',lists_sha256=result['lists_sha256'],counts={k:len(v['names']) for k,v in json.loads(raw)['lists'].items()},tests_executed=False)));return + elif args.mode=='run': + require(args.lists_sha is not None and re.fullmatch('[a-f0-9]{64}',args.lists_sha),'explicit immutable native lists SHA required') + path=folder/'lists-original.json';support.private(path);lists=checked_lists(path.read_bytes(),intent,args.lists_sha) + support.save(folder/'run-entered-local.json',dict(run_once=True,lists_sha256=args.lists_sha,no_retry=True)) + result=rpc(intent,'run',folder,args.lists_sha);support.save(folder/'run-reply.json',result);retain_passed(folder,result,intent,lists,args.lists_sha) + else: + require(args.lists_sha is None,'readback never executes or needs a new list choice');result=rpc(intent,'read',folder);support.save(folder/('readback-'+str(uuid.uuid4())+'.json'),result) + require(result['id']==case and result['readback_only'] is True + and result.get('tests_repeated',False) is False,'readback scope and case') + if result.get('lists_bytes_b64') is not None: + raw=base64.b64decode(result['lists_bytes_b64'],validate=True) + lists=retain_original_lists(folder,raw,intent,result['lists_sha256']) + if 'result.json' in result['partial']: + retain_passed(folder,result['partial']['result.json'],intent,lists,result['lists_sha256']) + print(json.dumps(dict(case_id=case,mode=args.mode,intent=str(folder/'intent.json'),intent_sha256=sha(folder/'intent.json'),target_called=args.mode!='prepare-local',rmm_jobs=False,approvals=False))) + + +if __name__=='__main__': + main() diff --git a/docs/script-console-windows-link.md b/docs/script-console-windows-link.md new file mode 100644 index 0000000..f94b62b --- /dev/null +++ b/docs/script-console-windows-link.md @@ -0,0 +1,124 @@ +# Windows-Skriptkonsole: native Units bestanden, Runtimeabnahme offen + +Tatsächlicher Stand2026-11-14, Spezifikation1.20: Nach dem tatsächlichen +Linux-Unitnachweis mit84 bestandenen Tests und5 ausdrücklich ausgelassenen +Datenbankfällen wurden die Windows-Release-Unitprogramme und beide +Windows-Runtimeprogramme aus denselben unveränderten158 Compilerinputs +erfolgreich gelinkt. Der separate isolierte PostgreSQL-Lauf des Linuxpacks +hatte bereits alle45 Servertests einschließlich der5 Datenbankfälle bestanden. + +Das neue Linkmanifest liegt privat unter +`devstate/script-console-windows-link/run-d0b7c844-6770-4930-ac87-4380c87fbad7/manifest.json`, +SHA256 `4b31e6a997248f91db00cf56d7d6043a6feb840be237b9a5a5de5eb71ee4b80c`. +Es bindet das Quellmanifest +`ddd1a78d1cd289b02b1f98572f9652171ec00be84e01ce099fd722d689bcaacd` +und den tatsächlichen Linux-Nativbeleg +`a831a70a3cf76a3e8a9bf5820dcca7100d2ef9860dd9388539fe9c13f949f470`. +Der GNU-Crosslinker lief im unveränderlichen Offline-Dockerimage +`sha256:1b2fd985d2c1fcc3545ace602405dc68fa899201bd8a73fa319ff96377203fa9` +für `x86_64-pc-windows-gnu`. Die ursprünglichen Linkbytes und die zur +Bereitstellung von Debugdaten bereinigten PE-Dateien werden getrennt erhalten. + +| Artefakt | SHA256 der Bereitstellungsdatei | +| --- | --- | +| `windows-lib-tests.exe` | `d4e37cbec44766d6d520e4d358a43f5f58779659261172084ad1746640a73993` | +| `windows-agent-tests.exe` | `eaa0cc0331d5e5a48090de7c8f904c13f27bfe4d1a029e6638f5d96573f262b8` | +| `rmm-helper-windows.exe` | `89482ed2914465ffbe06062fe828539edd6a3bed2c9491e6f75be9e538ce286d` | +| `rmm-agent-windows.exe` | `7e8c3cc0045584cf551ded7a71531b771bb34cde915bff5f5ab60f54f4365960` | + +Der PipeV2-Quellhash bleibt +`ce525dab23f2e4faa2c9816280c1a5a8b40e56d0e63a350256e83b2df1d9229d`. +Der Build verändert keine Dienste, Geräteidentitäten, Journale, Policies oder +Capabilities. Er verwendet keine Zugangsdaten und startet keine Windows- +Testprogramme oder RMM-Dienste auf der VM oder dem Entwicklungsnotebook. + +**Tatsächlich nativ bestanden:** Beide vollständigen Windows-Listen wurden vor +jedem Testlauf festgehalten; alle 36 Bibliotheks- und sieben Agenttests bestanden +ohne Fehler, Auslassung oder Filter. Frühere 23+7- oder 35+7-Abnahmen anderer +Quellstände werden nicht auf dieses Pack übertragen. Der Administrator-Unitlauf +ersetzt weder laufende LocalService-/SYSTEM-Dienstnachweise noch die native +Zeitfreigabe oder einen WebUI-genehmigten Skriptauftrag. Die neue Windowsruntime +wurde dadurch nicht bereitgestellt. Es wurden keine neuen Windows-Capabilities +aktiviert; die Runtime-Zeitfreigabe bleibt geschlossen. + +Der dafür vorbereitete separate Runner ist +`deploy/script_console_windows_acceptance.py`. Seine Python-Syntax, +vollständigen lokalen Herkunftsprüfungen und gezielten synthetischen +Listen-/Ergebnisvalidatorfälle wurden geprüft: beide positiven Fälle und sechs +Verweigerungsfälle für falsche Herkunft, doppelte beziehungsweise fehlende +Testnamen und ausgelassene Tests bestanden. Diese künstlichen Daten sind kein +Windows-Ausführungsbeleg. + +Der anschließende lesende Vergleich mit dem tatsächlich geprüften Harness aus +Commit `1136707` fand einen Fehler im neuen Bootstrapcode: fünf ungültige +`-cine`-Operatoren statt `-ine`. Python-Syntax- und JSON-Validatorprüfungen hatten +die eingebettete PowerShell-Syntax nicht geprüft. Der ursprüngliche Stand +`46f62b54fce5a0411b6ced1322bf20ebe315877df559185e6aa1714d62718659` +und sein unbenutzter lokaler Intent bleiben erhalten. Der vorhandene lokale +PowerShell-Parser wurde anschließend über seinen bestehenden Clock-Harnesspfad, +Dateieigentümer und Toolhashes gebunden; sämtliche Tooldateihashes blieben vor +und nach der Prüfung gleich. Tatsächliche PowerShell 7.7.0 `ParseFile` und +`ParseInput` meldeten für das ursprüngliche vollständige Skript jeweils 14 +Parserfehler, nach dem engen Operatorfix jeweils null. Es wurde ausschließlich +geparst, kein Inhalt des Skripts ausgeführt. + +Der korrigierte Stand +`8f0684053f998733607ec28bb0c5e17cb313e2209bd8a276589881783852b1f7` +wurde danach durch den übergeordneten Entwickleragenten tatsächlich bis zum +Bootstrap-Prepare auf der Windows-VM ausgeführt. Der erste SFTP-Upload scheiterte +vor der Übertragung: Dem Zielpfad fehlte der führende Slash, deshalb wurde er +relativ zum Benutzerverzeichnis aufgelöst. Der tatsächliche lesende Readback +des Falls `4e59cc83-df75-4a65-9679-c8c8b48a4e5a` bestätigte vorhandenen +Prepare-Fall, `list_entered:false`, `run_entered:false` und keine Teilberichte. +Das war ein Harnessfehler; kein Windows-Unittest wurde ausgeführt. Quellstand, +Intent und Readback bleiben unverändert erhalten. + +Aktueller Runner: +`41fc85342ec40fb48b075717ccf7a4c76f788296f1f69fb5c5bdc10ddb78a9c5`. +Die zusätzliche Korrektur setzt ausschließlich den absoluten SFTP-Zielpräfix +`/C:/ProgramData/...`; das PowerShell-Skript ist bytegleich zum Operatorfix. +Vollständiges Skript und tatsächlicher Transportwrapper bestanden erneut sowohl +`ParseFile` als auch `ParseInput` mit null Fehlern. Zunächst ausschließlich lokal +vorbereiteter und danach nativ verwendeter Fall: +`76bb47dd-9334-46ff-ab64-a6b173d95e24`, Intent-SHA256 +`e350c3eb46dea9107fc2478981a624f5767c1fbd3c171523dbbf7dfdbc18057c`. +Der übergeordnete Entwickleragent führte für diesen Fall anschließend die +Listenphase tatsächlich erfolgreich aus: 36 Bibliotheks- und sieben Agenttests, +beide vollständigen Listen vor jeder Testausführung. SHA256 der unveränderten +Original-Listenbytes: +`13288f7c50db7ed5a38b439cda17d9e00cdbe1355b584498e7a4ce8f0d8b58e9`. +Dies sind die tatsächlichen neuen Listen mit insgesamt 43 Fällen, keine +Umetikettierung der älteren 42 Fälle. Der separate einmalige Lauf gegen genau +diesen SHA bestand mit 36+7 Tests, jeweils null Fehlern, Auslassungen und +herausgefilterten Tests. Der anschließende Readback validierte denselben +unveränderten Ergebnisbeleg ohne Wiederholung. Privater Beleg: +`devstate/script-console-windows-native/76bb47dd-9334-46ff-ab64-a6b173d95e24/passed.json`, +SHA256 `6d0fea175d63a27eaf754ee4ab921b220e3b910a4d74c44f5e560518d6b7b512`. +Der ursprüngliche Run-Reply hat SHA256 +`e458af4b84d61809b9c614de73773c3b15ee47a0a37c0a5a88400285342e5ef7`. +Manifest-, Quell-, Linux- und Listenbindungen sowie sämtliche Scopeflags wurden +erneut geprüft. Keine Produktinstallation, Clock-/SYSTEM-Freigabe oder +RMM-Jobausführung folgte aus dieser Unitabnahme. + +`prepare-local` erstellt einen +privaten unveränderlichen Fall mit Quell-, Skript-, Unterstützungsquell-, +Artefakt- und Linux-Belegbindung. Im tatsächlichen Ablauf führte nach unabhängiger +Quellprüfung `list --case ` auf der Windows-VM ausschließlich beide +vollständigen `--list`-Aufrufe aus. Die tatsächlichen Listen wurden als +unveränderte Originalbytes mit SHA256 erhalten. Erst ein separater Aufruf +`run --case --lists-sha ` führte genau diese beiden +Unitprogramme jeweils einmal ohne Filter aus. Ein vorheriger dauerhafter +Startmarker verhindert Wiederholung. `read --case ` las allein die +ursprünglichen Teil-/Endbelege; eine verlorene Antwort löst keinen erneuten +Testlauf aus. Alle 158 Quellbindungen und sämtliche vier ursprünglichen und +bereitgestellten PE-Dateien werden auch vor jedem Readback geprüft. + +Das native Testenvironment ist geleert; `WINDIR` und `SystemRoot` werden gegen +das native OS-Systemverzeichnis geprüft und `SystemDrive` daraus abgeleitet und +mit einem gegebenen vorhandenen Wert verglichen. Die Unitprogramme verwenden +einen privaten temporären Fallpfad. Keine SQL-, Helper-, Dienst-, Zeitrichtlinien-, +Capability- oder RMM-Jobänderung gehört zu dieser Prüfung. Ein erfolgreicher +Administrator-Unitlauf ist kein LocalService-/SYSTEM-Runtimenachweis. +Die Flags zu unveränderten SQL-/Produktdaten beziehen sich auf bestehende +Produktdatenbanken und Journale; private temporäre Unitdatenbanken gehören zu +den Bootstrap-Testartefakten.