Merge accepted Linux script console and refresh actual MVP status
Rust development slice / linux (push) Failing after 6s
Rust development slice / linux (push) Failing after 6s
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#requires -Version 5.1
|
||||
<#
|
||||
Build-only, fixed MSI 1.0.0 fixture. Writes only a NEW private child directory.
|
||||
Build-only, fixed MSI1.0.0 or1.1.0 major-upgrade fixture. Writes only a NEW private child directory.
|
||||
Never calls InstallProduct/OpenPackage/msiexec, modifies installed products,
|
||||
services, execution policy, certificate trust or reboot state. No downloads.
|
||||
No upgrade/EXE package is authored by this version.
|
||||
1.1 removes only the exact known1.0 predecessor; no EXE/repair mode.
|
||||
|
||||
Primary API/format contracts:
|
||||
https://learn.microsoft.com/en-us/windows/win32/msi/installer-opendatabase
|
||||
@@ -17,7 +17,8 @@ https://learn.microsoft.com/en-us/windows/win32/msi/package-codes
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$OutputParent,
|
||||
[Guid]$CaseId=([Guid]::NewGuid())
|
||||
[Guid]$CaseId=([Guid]::NewGuid()),
|
||||
[ValidateSet('1.0.0','1.1.0')][string]$FixtureVersion='1.0.0'
|
||||
)
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference='Stop'
|
||||
@@ -25,14 +26,18 @@ $case=$null;$created=$false;$installer=$null;$database=$null;$summary=$null;$mak
|
||||
$product='{3F070B4B-9C08-4D65-BD41-13D81B884AEC}'
|
||||
$upgrade='{C9BF1FB8-E31D-4BD7-BA0D-AB46539BBBAA}'
|
||||
$component='{4D1CA80F-9AF8-4F54-B426-450AFBAFF92E}'
|
||||
$version='1.0.0'
|
||||
$version=$FixtureVersion
|
||||
$isUpgrade=$version -ceq '1.1.0'
|
||||
$oldProduct=$product
|
||||
if($isUpgrade){$product='{D42BD387-079B-4BBF-A134-0DA7B7A97011}'}
|
||||
$upgradeCondition='Installed OR (RMM_OLD_PRODUCTS = "{3F070B4B-9C08-4D65-BD41-13D81B884AEC}" AND RMM_ALL_PRODUCTS = "{3F070B4B-9C08-4D65-BD41-13D81B884AEC}")'
|
||||
# Product/family/component identities are fixed. Nonidentical MSI bytes must
|
||||
# have distinct PackageCodes, so each new authoring case gets its own code.
|
||||
$package='{'+([Guid]::NewGuid().ToString().ToUpperInvariant())+'}'
|
||||
$artifact=[Guid]::NewGuid().ToString()
|
||||
$report=[ordered]@{schema_version=1;case_id=$CaseId.ToString();completed=$false;stage='preflight';
|
||||
build_only=$true;native_installation_tested=$false;product_changes=$false;services_changed=$false;
|
||||
reboot_requested=$false;trust_changed=$false;downloads=$false;upgrade_authored=$false;
|
||||
reboot_requested=$false;trust_changed=$false;downloads=$false;upgrade_authored=$isUpgrade;
|
||||
product_code=$product;upgrade_code=$upgrade;component_code=$component;package_code=$package;version=$version}
|
||||
|
||||
function Require([bool]$Value,[string]$Code) {if (!$Value) {throw $Code}}
|
||||
@@ -169,7 +174,7 @@ try {
|
||||
$report.tools=$tools
|
||||
$report.stage='payload_and_cabinet'
|
||||
$payload=Join-Path $case 'msi-payload.txt'
|
||||
$payloadBytes=[Text.Encoding]::ASCII.GetBytes("RustDiscovery MSI fixture 1.0.0`r`n")
|
||||
$payloadBytes=[Text.Encoding]::ASCII.GetBytes("RustDiscovery MSI fixture $version`r`n")
|
||||
Write-New $payload $payloadBytes
|
||||
$ddf=Join-Path $case 'fixture.ddf'
|
||||
$ddfText=@"
|
||||
@@ -190,7 +195,7 @@ try {
|
||||
$cab=Join-Path $case 'fixture.cab';No-Reparse $cab
|
||||
Require ((Get-Item -LiteralPath $cab).Length -gt 0 -and (Get-Item -LiteralPath $cab).Length -le 65536) 'MSI_CABINET_LIMIT'
|
||||
$report.stage='database_authoring:com_activation'
|
||||
$msi=Join-Path $case 'RustDiscoveryFixture-1.0.0-x64.msi';Require (!(Test-Path -LiteralPath $msi)) 'MSI_OUTPUT_EXISTS'
|
||||
$msi=Join-Path $case ('RustDiscoveryFixture-'+$version+'-x64.msi');Require (!(Test-Path -LiteralPath $msi)) 'MSI_OUTPUT_EXISTS'
|
||||
$installer=New-Object -ComObject WindowsInstaller.Installer
|
||||
$report.stage='database_authoring:open_create'
|
||||
$database=Com-Method $installer 'OpenDatabase' @($msi,[int]3)
|
||||
@@ -205,9 +210,11 @@ try {
|
||||
InstallExecuteSequence='`Action` CHAR(72) NOT NULL, `Condition` CHAR(255), `Sequence` SHORT PRIMARY KEY `Action`'
|
||||
LaunchCondition='`Condition` CHAR(255) NOT NULL, `Description` CHAR(255) NOT NULL LOCALIZABLE PRIMARY KEY `Condition`'
|
||||
}
|
||||
if($isUpgrade){$tables.Upgrade='`UpgradeCode` CHAR(38) NOT NULL, `VersionMin` CHAR(20), `VersionMax` CHAR(20), `Language` CHAR(255), `Attributes` SHORT NOT NULL, `Remove` CHAR(255), `ActionProperty` CHAR(72) NOT NULL PRIMARY KEY `UpgradeCode`, `VersionMin`, `VersionMax`, `Language`, `Attributes`'}
|
||||
foreach ($table in $tables.Keys) {$report.stage='database_authoring:create_table:'+$table;Sql ('CREATE TABLE `'+$table+'` ('+$tables[$table]+')')}
|
||||
$report.stage='database_authoring:insert_rows'
|
||||
$properties=[ordered]@{ProductCode=$product;UpgradeCode=$upgrade;ProductVersion=$version;ProductLanguage='1033';ProductName='RustDiscovery MSI Fixture';Manufacturer='Ease Technologies';ALLUSERS='1';INSTALLLEVEL='1';REBOOT='ReallySuppress'}
|
||||
if($isUpgrade){$properties.SecureCustomProperties='RMM_ALL_PRODUCTS;RMM_OLD_PRODUCTS'}
|
||||
foreach ($key in $properties.Keys) {Sql ("INSERT INTO ``Property`` (``Property``,``Value``) VALUES ('$key','$($properties[$key])')")}
|
||||
Sql 'INSERT INTO `Directory` (`Directory`,`DefaultDir`) VALUES (''TARGETDIR'',''SourceDir'')'
|
||||
Sql 'INSERT INTO `Directory` (`Directory`,`Directory_Parent`,`DefaultDir`) VALUES (''ProgramFiles64Folder'',''TARGETDIR'',''.'')'
|
||||
@@ -218,8 +225,17 @@ try {
|
||||
Sql ("INSERT INTO ``File`` (``File``,``Component_``,``FileName``,``FileSize``,``Attributes``,``Sequence``) VALUES ('PayloadFile','PayloadComponent','MSIPAY~1.TXT|msi-payload.txt',$($payloadBytes.Length),16896,1)")
|
||||
Sql 'INSERT INTO `Media` (`DiskId`,`LastSequence`,`Cabinet`) VALUES (1,1,''#fixture.cab'')'
|
||||
Sql 'INSERT INTO `LaunchCondition` (`Condition`,`Description`) VALUES (''VersionNT64'',''This fixture requires 64-bit Windows.'')'
|
||||
if($isUpgrade){
|
||||
Sql ("INSERT INTO ``Upgrade`` (``UpgradeCode``,``VersionMin``,``VersionMax``,``Attributes``,``Remove``,``ActionProperty``) VALUES ('$upgrade','1.0.0','1.0.0',768,'ALL','RMM_OLD_PRODUCTS')")
|
||||
Sql ("INSERT INTO ``Upgrade`` (``UpgradeCode``,``VersionMin``,``Attributes``,``Remove``,``ActionProperty``) VALUES ('$upgrade','0.0.0',258,'ALL','RMM_ALL_PRODUCTS')")
|
||||
Sql ("INSERT INTO ``LaunchCondition`` (``Condition``,``Description``) VALUES ('$upgradeCondition','Only the exact approved fixture1.0 predecessor may be upgraded.')")
|
||||
}
|
||||
$sequence=[ordered]@{LaunchConditions=100;CostInitialize=800;FileCost=900;CostFinalize=1000;InstallValidate=1400;InstallInitialize=1500;ProcessComponents=1600;UnpublishFeatures=1800;RemoveFiles=3500;RemoveFolders=3600;CreateFolders=3700;InstallFiles=4000;RegisterUser=6000;RegisterProduct=6100;PublishFeatures=6300;PublishProduct=6400;InstallFinalize=6600}
|
||||
foreach ($action in $sequence.Keys) {Sql ("INSERT INTO ``InstallExecuteSequence`` (``Action``,``Sequence``) VALUES ('$action',$($sequence[$action]))")}
|
||||
if($isUpgrade){$sequence.FindRelatedProducts=25;$sequence.RemoveExistingProducts=1550}
|
||||
foreach ($action in $sequence.Keys) {
|
||||
if($action -ceq 'RemoveExistingProducts'){Sql ("INSERT INTO ``InstallExecuteSequence`` (``Action``,``Condition``,``Sequence``) VALUES ('$action','NOT Installed',$($sequence[$action]))")}
|
||||
else {Sql ("INSERT INTO ``InstallExecuteSequence`` (``Action``,``Sequence``) VALUES ('$action',$($sequence[$action]))")}
|
||||
}
|
||||
$view=Com-Method $database 'OpenView' @('INSERT INTO `_Streams` (`Name`,`Data`) VALUES (?,?)');$record=$null
|
||||
try {$record=Com-Method $installer 'CreateRecord' @([int]2);Com-Set $record 'StringData' @([int]1,'fixture.cab');[void](Com-Method $record 'SetStream' @([int]2,$cab));[void](Com-Method $view 'Execute' @($record));[void](Com-Method $view 'Close')}
|
||||
finally {Release-Com $record;Release-Com $view}
|
||||
@@ -236,7 +252,23 @@ try {
|
||||
foreach ($key in $properties.Keys) {$row=Rows ("SELECT ``Value`` FROM ``Property`` WHERE ``Property``='$key'");Require ($row.Count -eq 1 -and $row[0][0] -ceq $properties[$key]) 'MSI_PROPERTY_READBACK'}
|
||||
$allTables=Rows 'SELECT `Name` FROM `_Tables`';$names=@($allTables|ForEach-Object {$_[0]})
|
||||
Require ($names.Count -eq $tables.Count -and @($names|Where-Object {$_ -notin $tables.Keys}).Count -eq 0) 'MSI_UNEXPECTED_TABLE'
|
||||
Require ('CustomAction' -notin $names -and 'Upgrade' -notin $names -and 'Registry' -notin $names -and 'ServiceInstall' -notin $names) 'MSI_FORBIDDEN_TABLE'
|
||||
Require ('CustomAction' -notin $names -and 'Registry' -notin $names -and 'ServiceInstall' -notin $names -and ($isUpgrade -or 'Upgrade' -notin $names)) 'MSI_FORBIDDEN_TABLE'
|
||||
# Independently read committed upgrade/sequence metadata; no install APIs.
|
||||
foreach($action in $sequence.Keys){
|
||||
$row=Rows ("SELECT ``Condition``,``Sequence`` FROM ``InstallExecuteSequence`` WHERE ``Action``='$action'")
|
||||
$condition=if($action -ceq 'RemoveExistingProducts'){'NOT Installed'}else{''}
|
||||
Require ($row.Count -eq 1 -and $row[0][0] -ceq $condition -and $row[0][1] -ceq [string]$sequence[$action]) 'MSI_SEQUENCE_READBACK'
|
||||
}
|
||||
if($isUpgrade){
|
||||
$rows=Rows 'SELECT `UpgradeCode`,`VersionMin`,`VersionMax`,`Attributes`,`Remove`,`ActionProperty` FROM `Upgrade` WHERE `Language` IS NULL ORDER BY `ActionProperty`'
|
||||
Require ($rows.Count -eq 2) 'MSI_UPGRADE_ROW_COUNT'
|
||||
$expected=@(@($upgrade,'0.0.0','','258','ALL','RMM_ALL_PRODUCTS'),@($upgrade,'1.0.0','1.0.0','768','ALL','RMM_OLD_PRODUCTS'))
|
||||
for($i=0;$i -lt 2;$i++){for($j=0;$j -lt 6;$j++){Require ($rows[$i][$j] -ceq $expected[$i][$j]) 'MSI_UPGRADE_ROW_READBACK'}}
|
||||
$nullMax=Rows 'SELECT `ActionProperty` FROM `Upgrade` WHERE `VersionMax` IS NULL'
|
||||
Require ($nullMax.Count -eq 1 -and $nullMax[0][0] -ceq 'RMM_ALL_PRODUCTS') 'MSI_UPGRADE_NULL_MAX_READBACK'
|
||||
$launch=Rows ("SELECT ``Description`` FROM ``LaunchCondition`` WHERE ``Condition``='$upgradeCondition'")
|
||||
Require ($launch.Count -eq 1 -and $launch[0][0] -ceq 'Only the exact approved fixture1.0 predecessor may be upgraded.' -and $readback.LaunchCondition.Count -eq 2) 'MSI_UPGRADE_LAUNCH_READBACK'
|
||||
}
|
||||
$summary=Com-Get $database 'SummaryInformation' @([int]0)
|
||||
Require ((Com-Get $summary 'Property' @([int]7)) -ceq 'x64;1033' -and (Com-Get $summary 'Property' @([int]9)) -ceq $package -and [int](Com-Get $summary 'Property' @([int]15)) -eq 2) 'MSI_SUMMARY_READBACK'
|
||||
Release-Com $summary;$summary=$null
|
||||
@@ -253,12 +285,17 @@ try {
|
||||
$extra=Com-Method $view 'Fetch';Require ($null -eq $extra) 'MSI_DUPLICATE_CAB_STREAM';[void](Com-Method $view 'Close')
|
||||
} finally {Release-Com $record;Release-Com $view}
|
||||
Release-Com $database;$database=$null
|
||||
$recipe=[ordered]@{schema_version=1;recipe_id='rmm-windows-msi-fixture-install-1.0';recipe_version='1';platform='windows';upgrade_code=$upgrade;architecture='x64';context='machine';command_profile='fixture_quiet_no_reboot_v1';artifact=[ordered]@{artifact_id=$artifact;sha256=(Hash $msi);bytes=$length};postcondition=[ordered]@{product_code=$product;product_version=$version;payload_path='C:\Program Files\RustDiscoveryFixtures\msi-payload.txt';payload_sha256=(Hash $payload);payload_bytes=$payloadBytes.Length};no_reboot=$true}
|
||||
$recipe=[ordered]@{schema_version=1;recipe_id=$(if($isUpgrade){'rmm-windows-msi-fixture-upgrade-1.1'}else{'rmm-windows-msi-fixture-install-1.0'});recipe_version='1';platform='windows';upgrade_code=$upgrade;architecture='x64';context='machine';command_profile='fixture_quiet_no_reboot_v1';artifact=[ordered]@{artifact_id=$artifact;sha256=(Hash $msi);bytes=$length};postcondition=[ordered]@{product_code=$product;product_version=$version;payload_path='C:\Program Files\RustDiscoveryFixtures\msi-payload.txt';payload_sha256=(Hash $payload);payload_bytes=$payloadBytes.Length};no_reboot=$true}
|
||||
if($isUpgrade){
|
||||
$recipe.package_code=$package
|
||||
$oldBytes=[Text.Encoding]::ASCII.GetBytes("RustDiscovery MSI fixture 1.0.0`r`n")
|
||||
$recipe.predecessor=[ordered]@{product_code=$oldProduct;product_version='1.0.0';payload_path=$recipe.postcondition.payload_path;payload_sha256=(Hash-Bytes $oldBytes);payload_bytes=$oldBytes.Length}
|
||||
}
|
||||
$recipeJson=$recipe|ConvertTo-Json -Depth 12 -Compress
|
||||
Write-New (Join-Path $case 'recipe.json') ([Text.Encoding]::UTF8.GetBytes($recipeJson))
|
||||
Write-Json (Join-Path $case 'tables.json') $readback
|
||||
$report.artifact=[ordered]@{path=$msi;sha256=(Hash $msi);bytes=$length;artifact_id_proposal=$artifact}
|
||||
$report.payload=[ordered]@{sha256=(Hash $payload);bytes=$payloadBytes.Length;content_ascii="RustDiscovery MSI fixture 1.0.0`r`n";installed_path=$recipe.postcondition.payload_path}
|
||||
$report.payload=[ordered]@{sha256=(Hash $payload);bytes=$payloadBytes.Length;content_ascii="RustDiscovery MSI fixture $version`r`n";installed_path=$recipe.postcondition.payload_path}
|
||||
$report.cabinet=[ordered]@{sha256=(Hash $cab);bytes=(Get-Item -LiteralPath $cab).Length;embedded_hash_verified=$true;stream='fixture.cab'}
|
||||
$report.tables_sha256=Hash (Join-Path $case 'tables.json');$report.table_names=$names
|
||||
$report.resolved_recipe=[ordered]@{recipe=$recipe;recipe_sha256=(Hash (Join-Path $case 'recipe.json'))}
|
||||
@@ -267,7 +304,7 @@ try {
|
||||
Require ((Hash $PSCommandPath) -ceq $report.builder_sha256) 'MSI_BUILDER_CHANGED'
|
||||
$report.completed=$true;$report.stage='authored_and_read_back_not_installed'
|
||||
Write-Json (Join-Path $case 'result.json') $report
|
||||
[ordered]@{completed=$true;build_only=$true;report_path=(Join-Path $case 'result.json');artifact=$report.artifact;native_installation_tested=$false;upgrade_authored=$false}|ConvertTo-Json -Depth 5
|
||||
[ordered]@{completed=$true;build_only=$true;report_path=(Join-Path $case 'result.json');artifact=$report.artifact;native_installation_tested=$false;upgrade_authored=$isUpgrade}|ConvertTo-Json -Depth 5
|
||||
} catch {
|
||||
$report.completed=$false;$report.error_type=$_.Exception.GetType().FullName;$report.error_hresult=$_.Exception.HResult
|
||||
$report.error_line=$_.InvocationInfo.ScriptLineNumber
|
||||
|
||||
@@ -0,0 +1,368 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Source-bound Pipe-v2 pack and create-once native units, never deployment.
|
||||
|
||||
The access root only supplies the existing pinned SSH transport and immutable
|
||||
native Core proofs. No credentials/devstate symlinks, copies, services or jobs.
|
||||
"""
|
||||
import argparse
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
CODE = Path(__file__).resolve().parents[2]
|
||||
ACCESS = Path('/home/kevin/Schreibtisch/Coding/rust-discovery')
|
||||
sys.path.insert(0, str(ACCESS / 'deploy/windows'))
|
||||
sys.path.insert(0, str(ACCESS / 'deploy'))
|
||||
import client_bootstrap as cb
|
||||
import auto_transport_acceptance as auto
|
||||
import runtime_upgrade as previous
|
||||
|
||||
require = cb.contract.require
|
||||
BUILD = CODE / 'devstate/windows-pipe-drain-build'
|
||||
NATIVE = CODE / 'devstate/windows-client/native-pipe-v2'
|
||||
# These imported transports read their original protected access configuration.
|
||||
# Their new local upload/error receipts belong to this isolated checkout.
|
||||
cb.EVIDENCE = CODE / 'devstate/windows-client'
|
||||
CORE = ACCESS / 'devstate/core-no-start/build-de37ee99-11bf-465b-9519-45ad8f6e5b87/manifest.json'
|
||||
CORE_SHA = '1bc082031fcad20d5a519b0004f63d499dbba2ea9ce25d56230d48d2556d474b'
|
||||
LOCAL = CODE / 'devstate/windows-pipe-drain/qualification-1e0f2b22-1e74-41af-b8ed-0a356be054ba/qualification.json'
|
||||
LOCAL_SHA = 'a7e3c604d4ad19feed0323ac23aa7a0290b6fb93bc57649cafbadbe5f293b1d4'
|
||||
TARGET = 'x86_64-pc-windows-gnu'
|
||||
NAMES = {'agent': 'rmm-agent-windows.exe', 'helper': 'rmm-helper-windows.exe',
|
||||
'probe': 'RuntimeStateProbe.exe', 'system_probe': 'SystemStateProbe.exe',
|
||||
'lib': 'windows-tests-lib.exe', 'bin': 'windows-tests-bin.exe'}
|
||||
# Expected V2 native lists: unchanged names, two existing codec cases extended.
|
||||
TESTS = {
|
||||
'lib': sorted([
|
||||
'clock::tests::gate_requires_all_status_and_uncertainty_evidence',
|
||||
'clock::tests::production_clock_stays_closed_until_native_adapter_qualification',
|
||||
'clock::tests::suspend_closes_until_actual_post_resume_sync',
|
||||
'clock::tests::timeout_worker_stays_closed_without_a_second_call',
|
||||
'clock::tests::wall_step_and_overflow_fail_closed',
|
||||
'helper_ipc::tests::pipe_client_rights_cannot_create_an_instance',
|
||||
'helper_ipc::tests::protocol_does_not_accept_a_shell_operation',
|
||||
'helper_ipc::tests::reconfigured_service_cannot_adopt_an_old_running_identity',
|
||||
'helper_ipc::tests::serialization_refuses_oversized_frame',
|
||||
'helper_ipc::tests::untrusted_lengths_are_rejected_before_body_allocation',
|
||||
'helper_runtime::intent::tests::cancel_and_dispatch_cas_are_exclusive_and_history_cannot_be_rewritten',
|
||||
'helper_runtime::tests::system_route_binds_original_request_shape_budget_and_reply_scope',
|
||||
'helper_system::tests::completed_scm_state_cannot_override_elapsed_runtime',
|
||||
'helper_system::tests::fixture_recovery_cannot_add_commands_reboots_or_restart_attempts',
|
||||
'helper_system::tests::service_adapter_exposes_only_implemented_states',
|
||||
'helper_system::tests::single_fixture_cannot_start_services_or_groups_as_dependencies',
|
||||
'journal::tests::bounded_existing_journal_preserves_identity_sequence_and_unacked_bytes',
|
||||
'journal::tests::durable_reopen_ack_identity_and_single_process',
|
||||
'journal::tests::migrates_original_passive_schema_without_rewriting_pending_envelopes',
|
||||
'journal::tests::unsupported_page_size_is_refused_without_mutating_existing_data',
|
||||
'native::tests::boot_identity_survives_independent_native_queries',
|
||||
'native::tests::native_inventory_has_real_windows_sources_and_no_fake_inodes',
|
||||
'process::tests::arguments_never_become_shell_code_and_trailing_slashes_are_quoted']),
|
||||
'bin': sorted([
|
||||
'https_channel::endpoint_tests::configured_dns_identity_cannot_inject_a_url_or_disable_name_checks',
|
||||
'runtime::tests::bound_helper_unknown_repairs_generic_crash_gap_without_ack_or_duplicate_result',
|
||||
'runtime::tests::legacy_inventory_keeps_original_bytes_until_concrete_core_ack',
|
||||
'runtime::tests::old_passive_configuration_cannot_enable_jobs_or_read_the_clock',
|
||||
'runtime::tests::worker_fence_requires_same_generation_and_entire_clock_interval',
|
||||
'wire_channel::tests::auto_fallback_classifies_upgrade_refusal_but_never_authentication',
|
||||
'wire_channel::tests::explicit_transport_names_cannot_enable_verification_bypasses'])}
|
||||
COUNTS = {'lib': 23, 'bin': 7}
|
||||
|
||||
|
||||
def sha(path):
|
||||
return hashlib.sha256(Path(path).read_bytes()).hexdigest()
|
||||
|
||||
|
||||
def save(path, value):
|
||||
path.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
cb.contract.write_private(path, value)
|
||||
|
||||
|
||||
def private_file(path):
|
||||
path = Path(path)
|
||||
require(not path.is_symlink() and not path.parent.is_symlink(), 'private regular path')
|
||||
info = path.lstat()
|
||||
require(stat.S_ISREG(info.st_mode) and info.st_uid == os.getuid()
|
||||
and stat.S_IMODE(info.st_mode) == 0o600, 'private regular owner/mode')
|
||||
return path
|
||||
|
||||
|
||||
def sources():
|
||||
require(ACCESS.is_dir() and not ACCESS.is_symlink() and cb.ROOT == ACCESS,
|
||||
'original access checkout only; no copied configuration')
|
||||
names = {'Cargo.toml', 'Cargo.lock', 'rust-toolchain.toml', 'proto/agent.proto',
|
||||
'deploy/windows/system_pipe_acceptance.py', 'docs/windows-helper-pipe-drain.md'}
|
||||
names.update(str(p.relative_to(CODE)) for p in (CODE / 'crates').glob('*/Cargo.toml'))
|
||||
for crate in ('agent-windows', 'agent-core', 'domain', 'protocol'):
|
||||
names.update(str(p.relative_to(CODE)) for p in (CODE / 'crates' / crate).rglob('*')
|
||||
if p.is_file() and p.suffix in ('.rs', '.c', '.h', '.idl', '.toml'))
|
||||
names.update('crates/agent/src/' + n + '.rs' for n in ('https_channel', 'transport', 'wire_channel'))
|
||||
require(all((CODE / n).is_file() and not (CODE / n).is_symlink() for n in names), 'complete fixed build sources')
|
||||
transport = {}
|
||||
for module in tuple(sys.modules.values()):
|
||||
raw = getattr(module, '__file__', None)
|
||||
if raw:
|
||||
path = Path(raw).resolve()
|
||||
if path.is_relative_to(ACCESS / 'deploy') and path.suffix == '.py':
|
||||
transport[str(path.relative_to(ACCESS))] = sha(path)
|
||||
require('deploy/windows/client_bootstrap.py' in transport, 'actual transport source binding')
|
||||
return {'code': {n: sha(CODE / n) for n in sorted(names)}, 'access_transport': dict(sorted(transport.items()))}
|
||||
|
||||
|
||||
def core_proof():
|
||||
require(sha(CORE) == CORE_SHA, 'exact original Linux-first Core manifest')
|
||||
manifest = cb.contract.protected_json(CORE)
|
||||
result = {'manifest_sha256': CORE_SHA}
|
||||
for platform, count in (('linux', 80), ('windows', 58)):
|
||||
path = CORE.parent / (platform + '-passed.json')
|
||||
proof = cb.contract.protected_json(path)
|
||||
require(proof['verified'] is True and proof['platform'] == platform
|
||||
and proof['manifest_sha256'] == CORE_SHA, 'actual same-manifest native Core proof')
|
||||
actual = proof['native']['reports']
|
||||
require(set(actual) == set(manifest['test_counts'][platform])
|
||||
and sum(len(v['names']) for v in actual.values()) == count, 'all native Core reports')
|
||||
for kind, item in actual.items():
|
||||
n = manifest['test_counts'][platform][kind]
|
||||
output = base64.b64decode(item['stdout_b64'], validate=True)
|
||||
require(item['exit_code'] == 0 and item['timed_out'] is False
|
||||
and item['names'] == manifest['test_names'][platform][kind]
|
||||
and item['sha256'] == manifest['artifacts'][platform][kind]['sha256']
|
||||
and re.search(rb'test result: ok\. ' + str(n).encode()
|
||||
+ rb' passed; 0 failed; 0 ignored; 0 measured; 0 filtered out;', output),
|
||||
'complete actual native Core result')
|
||||
result[platform] = {'proof_sha256': sha(path), 'case_id': proof['case_id']}
|
||||
for name, digest in manifest['source_files'].items():
|
||||
if name.startswith(('crates/agent-core/', 'crates/domain/', 'crates/protocol/', 'proto/')):
|
||||
require(sha(CODE / name) == digest, 'isolated common source equals actual native Core proof')
|
||||
return result
|
||||
|
||||
|
||||
def reused_qualification():
|
||||
require(sha(LOCAL) == LOCAL_SHA, 'exact retained local qualification')
|
||||
value = cb.contract.protected_json(LOCAL)
|
||||
require(value['type'] == 'rmm.windows.pipe-drain-local-qualification'
|
||||
and value['source_before_after_equal'] is True and value['native_executed'] is False
|
||||
and value['clock_qualified'] is False and value['native_counts_expected'] == COUNTS
|
||||
and len(value['commands']) == 4 and all(c['exit_code'] == 0 for c in value['commands']),
|
||||
'actual previous cross-Clippy/release/unit-link qualification')
|
||||
for name, digest in value['source_files'].items():
|
||||
require(sha(CODE / name) == digest, 'all original qualified inputs remain unchanged')
|
||||
for item in list(value['artifacts'].values()) + list(value['unit_links'].values()):
|
||||
path = Path(item['path'])
|
||||
target = LOCAL.parent / 'target'
|
||||
require(path.is_relative_to(target), 'qualified link under private target')
|
||||
current = target
|
||||
for part in ('',) + path.relative_to(target).parts:
|
||||
if part:
|
||||
current = current / part
|
||||
info = current.lstat()
|
||||
require(not stat.S_ISLNK(info.st_mode) and info.st_uid in (0, os.getuid())
|
||||
and info.st_mode & 0o022 == 0, 'protected original compiler output')
|
||||
require(stat.S_ISREG(path.lstat().st_mode) and sha(path) == item['sha256']
|
||||
and path.stat().st_size == item['bytes'], 'retained exact qualified links')
|
||||
require(re.search(r'^pub const ADAPTER_QUALIFIED: bool = false;$',
|
||||
(CODE / 'crates/agent-windows/src/clock.rs').read_text(), re.M), 'production clock remains closed')
|
||||
return value
|
||||
|
||||
|
||||
def command(args, folder, name):
|
||||
with (folder / (name + '.stdout')).open('xb') as out, (folder / (name + '.stderr')).open('xb') as err:
|
||||
result = subprocess.run(args, stdout=out, stderr=err)
|
||||
save(folder / (name + '.json'), {'exit_code': result.returncode, 'local_only': True, 'arguments': args})
|
||||
require(result.returncode == 0, 'local build failed; original stdout/stderr retained')
|
||||
|
||||
|
||||
def build():
|
||||
before, common, prior = sources(), core_proof(), reused_qualification()
|
||||
folder = BUILD / ('build-' + str(uuid.uuid4()))
|
||||
folder.mkdir(mode=0o700, parents=True)
|
||||
save(folder / 'source-before.json', before)
|
||||
save(folder / 'reused-qualification.json', {'path': str(LOCAL), 'sha256': LOCAL_SHA, 'value': prior})
|
||||
image = prior['build_image']
|
||||
require(re.fullmatch(r'sha256:[a-f0-9]{64}', image), 'immutable compiler image')
|
||||
target = LOCAL.parent / 'target'
|
||||
# Only these two RELEASE examples were missing. Original Clippy, EXEs and
|
||||
# unit links are hash-bound above and are deliberately not rerun/rebuilt.
|
||||
command(['docker', 'run', '--rm', '--network', 'none', '--read-only', '--tmpfs', '/tmp:rw,size=512m',
|
||||
'-v', str(CODE) + ':/src:ro', '-v', str(target) + ':/target', '-e', 'CARGO_TARGET_DIR=/target',
|
||||
'--entrypoint', 'cargo', image, 'build', '--manifest-path', '/src/Cargo.toml', '--locked', '--offline',
|
||||
'--target', TARGET, '-p', 'rmm-agent-windows', '--features', 'system-helper', '--release',
|
||||
'--example', 'runtime_state', '--example', 'system_state'], folder, 'release-examples')
|
||||
selected = {'agent': Path(prior['artifacts']['agent']['path']), 'helper': Path(prior['artifacts']['helper']['path']),
|
||||
'lib': Path(prior['unit_links']['lib']['path']), 'bin': Path(prior['unit_links']['bin']['path']),
|
||||
'probe': target / TARGET / 'release/examples/runtime_state.exe',
|
||||
'system_probe': target / TARGET / 'release/examples/system_state.exe'}
|
||||
artifacts = {}
|
||||
for kind, original in selected.items():
|
||||
output, retained = folder / NAMES[kind], folder / (NAMES[kind] + '.linked')
|
||||
original_sha = sha(original)
|
||||
for destination in (retained, output):
|
||||
shutil.copyfile(original, destination)
|
||||
destination.chmod(0o600)
|
||||
if kind in COUNTS:
|
||||
command(['docker', 'run', '--rm', '--network', 'none', '--read-only', '-v', str(folder) + ':/artifacts',
|
||||
'--entrypoint', 'x86_64-w64-mingw32-strip', image, '--strip-debug', '/artifacts/' + NAMES[kind]],
|
||||
folder, 'strip-' + kind)
|
||||
require(sha(original) == sha(retained) == original_sha, 'original links retained unchanged')
|
||||
data = output.read_bytes()
|
||||
offset = int.from_bytes(data[60:64], 'little')
|
||||
require(data[:2] == b'MZ' and data[offset:offset + 6] == b'PE\0\0\x64\x86', 'Windows AMD64 PE')
|
||||
artifacts[kind] = {'path': str(output), 'name': NAMES[kind], 'sha256': sha(output), 'bytes': len(data),
|
||||
'original_link_path': str(retained), 'original_link_sha256': original_sha,
|
||||
'release_build': kind not in COUNTS, 'debug_stripped': kind in COUNTS}
|
||||
require(sources() == before and core_proof() == common and reused_qualification() == prior,
|
||||
'compiler inputs, original links and native Core proof unchanged before/after')
|
||||
manifest = {'schema_version': 1, 'type': 'rmm.windows.pipe-v2-build', 'source_files': before,
|
||||
'source_before_after_equal': True, 'code_root': str(CODE), 'access_root': str(ACCESS),
|
||||
'artifacts': artifacts, 'test_names_expected': TESTS, 'native_counts_expected': COUNTS,
|
||||
'core_native_proofs': common, 'reused_local_qualification': {'path': str(LOCAL), 'sha256': LOCAL_SHA},
|
||||
'build_image_id': image, 'transport_version': 2, 'raw_v1_controls_qualified': False,
|
||||
'production_clock_qualified': False, 'native_executed': False}
|
||||
save(folder / 'manifest.json', manifest)
|
||||
print(json.dumps({'manifest': str(folder / 'manifest.json'), 'native_executed': False}))
|
||||
|
||||
|
||||
SCRIPT = r'''
|
||||
$ErrorActionPreference='Stop';$p=([Console]::In.ReadLine()|ConvertFrom-Json)
|
||||
if([string]([guid]$p.id)-cne$p.id-or$p.action-notin@('run','read')-or$p.manifest_sha256-notmatch'^[a-f0-9]{64}$'){throw 'Fixed Pipe V2 unit case'}
|
||||
$root='C:\ProgramData\RustDiscoveryBootstrap';$case=Join-Path $root ('native-pipe-v2-'+$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 'Private unit type'};$a=Get-Acl -LiteralPath $path;if($a.GetOwner([Security.Principal.SecurityIdentifier]).Value-notin@('S-1-5-18','S-1-5-32-544')){throw 'Unit owner'};$rules=@($a.GetAccessRules($true,$true,[Security.Principal.SecurityIdentifier]));if(!$rules.Count){throw 'Empty unit ACL'};foreach($r in $rules){if($r.AccessControlType-ne'Allow'-or$r.IdentityReference.Value-notin@('S-1-5-18','S-1-5-32-544')){throw 'Unit ACL'}}}
|
||||
function WriteNew($path,$value){$b=[Text.Encoding]::UTF8.GetBytes(($value|ConvertTo-Json -Depth 16 -Compress));$f=[IO.File]::Open($path,'CreateNew','Write','Read');try{$f.Write($b,0,$b.Length);$f.Flush($true)}finally{$f.Dispose()}}
|
||||
function ReadPrivate($path){Safe $path $false;if((Get-Item -LiteralPath $path).Length-gt196608){throw 'Unit report bound'};return (Get-Content -LiteralPath $path -Raw|ConvertFrom-Json)}
|
||||
Safe $root $true
|
||||
if($p.action-eq'read'){
|
||||
if(!(Test-Path -LiteralPath $case)){@{case_exists=$false;completed=$false;readback_only=$true}|ConvertTo-Json -Compress;exit 0}
|
||||
Safe $case $true;$i=ReadPrivate (Join-Path $case 'intent.json');if($i.manifest_sha256-cne$p.manifest_sha256){throw 'Original unit intent'}
|
||||
$result=Join-Path $case 'result.json';if(Test-Path -LiteralPath $result){ReadPrivate $result|ConvertTo-Json -Depth 16 -Compress;exit 0}
|
||||
$lists=@{};$reports=@{};foreach($kind in @('lib','bin')){$file=Join-Path $case ('list-'+$kind+'.json');if(Test-Path -LiteralPath $file){$lists[$kind]=ReadPrivate $file};$file=Join-Path $case ('report-'+$kind+'.json');if(Test-Path -LiteralPath $file){$reports[$kind]=ReadPrivate $file}}
|
||||
@{case_exists=$true;completed=$false;readback_only=$true;started=(Test-Path -LiteralPath (Join-Path $case 'started.json'));lists=$lists;reports=$reports}|ConvertTo-Json -Depth 16 -Compress;exit 0
|
||||
}
|
||||
if(Test-Path -LiteralPath $case){throw 'Existing unit case: readback only'};New-Item -ItemType Directory -Path $case|Out-Null;Safe $case $true;WriteNew (Join-Path $case 'intent.json') $p
|
||||
function Run($exe,$arguments){$s=New-Object Diagnostics.ProcessStartInfo;$s.FileName=$exe;$s.Arguments=$arguments;$s.UseShellExecute=$false;$s.CreateNoWindow=$true;$s.RedirectStandardOutput=$true;$s.RedirectStandardError=$true;$c=New-Object Diagnostics.Process;$c.StartInfo=$s;if(!$c.Start()){throw 'Unit process 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-gt65536-or$e.Result.Length-gt65536){throw 'Bounded unit output collection'};return @{exit_code=$c.ExitCode;timed_out=$timed;stdout=$o.Result;stderr=$e.Result}}finally{$c.Dispose()}}
|
||||
$lists=@{};$paths=@{}
|
||||
foreach($kind in @('lib','bin')){
|
||||
$a=$p.artifacts.$kind;if($a.sha256-notmatch'^[a-f0-9]{64}$'-or$a.name-cne('windows-tests-'+$kind+'.exe')){throw 'Fixed test artifact'};$folder=Join-Path $root $a.sha256;Safe $folder $true;$exe=Join-Path $folder $a.name;Safe $exe $false;if((Get-FileHash -LiteralPath $exe -Algorithm SHA256).Hash.ToLowerInvariant()-cne$a.sha256-or(Get-Item -LiteralPath $exe).Length-ne$a.bytes){throw 'Exact unit artifact'}
|
||||
$listed=Run $exe '--list --format terse';[string[]]$names=@($listed.stdout-split'\r?\n'|Where-Object{$_-match': test$'}|ForEach-Object{$_-replace': test$',''});[Array]::Sort($names,[StringComparer]::Ordinal)
|
||||
$value=@{sha256=$a.sha256;names=$names;listed=$listed};WriteNew (Join-Path $case ('list-'+$kind+'.json')) $value
|
||||
if($listed.exit_code-ne0-or$listed.timed_out-or$names.Count-ne$p.counts.$kind-or(($names-join"`n")-cne(@($p.test_names.$kind)-join"`n"))){throw 'Exact complete native list before ANY tests'};$lists[$kind]=$value;$paths[$kind]=$exe
|
||||
}
|
||||
WriteNew (Join-Path $case 'both-lists-verified.json') @{manifest_sha256=$p.manifest_sha256;both_lists_verified_before_any_test=$true}
|
||||
WriteNew (Join-Path $case 'started.json') @{start_once=$true};$reports=@{}
|
||||
foreach($kind in @('lib','bin')){$run=Run $paths[$kind] '--test-threads=1';$value=@{sha256=$lists[$kind].sha256;names=$lists[$kind].names;listed=$lists[$kind].listed;result=$run};WriteNew (Join-Path $case ('report-'+$kind+'.json')) $value;$reports[$kind]=$value;if($run.exit_code-ne0-or$run.timed_out){throw 'Native unit execution failed; readback only'}}
|
||||
$value=@{completed=$true;manifest_sha256=$p.manifest_sha256;reports=$reports;both_lists_verified_before_any_test=$true;bootstrap_administrator_units=$true;local_service_proof=$false;native_pipe_proof=$false;rmm_jobs=$false;product_state_writes=$false};WriteNew (Join-Path $case 'result.json') $value;$value|ConvertTo-Json -Depth 16 -Compress
|
||||
'''
|
||||
|
||||
|
||||
def verified(path, current=True):
|
||||
path = private_file(path)
|
||||
require(path.parent.parent == BUILD and path.parent.name.startswith('build-')
|
||||
and str(uuid.UUID(path.parent.name[6:])) == path.parent.name[6:], 'fixed private build namespace')
|
||||
value = cb.contract.protected_json(path)
|
||||
require(value['type'] == 'rmm.windows.pipe-v2-build' and value['schema_version'] == 1
|
||||
and value['source_before_after_equal'] is True and value['production_clock_qualified'] is False
|
||||
and value['transport_version'] == 2 and value['raw_v1_controls_qualified'] is False
|
||||
and value['native_executed'] is False
|
||||
and value['reused_local_qualification'] == {'path': str(LOCAL), 'sha256': LOCAL_SHA}
|
||||
and value['native_counts_expected'] == COUNTS and value['test_names_expected'] == TESTS
|
||||
and value['code_root'] == str(CODE) and value['access_root'] == str(ACCESS), 'exact V2 build profile')
|
||||
if current:
|
||||
require(value['source_files'] == sources() and value['core_native_proofs'] == core_proof(), 'current source/Core proof binding')
|
||||
require(set(value['artifacts']) == set(NAMES), 'six exact artifacts')
|
||||
for kind, item in value['artifacts'].items():
|
||||
output, original = private_file(item['path']), private_file(item['original_link_path'])
|
||||
require(output == path.parent / NAMES[kind] and original == path.parent / (NAMES[kind] + '.linked')
|
||||
and sha(output) == item['sha256'] and output.stat().st_size == item['bytes']
|
||||
and sha(original) == item['original_link_sha256']
|
||||
and item['release_build'] is (kind not in COUNTS)
|
||||
and item['debug_stripped'] is (kind in COUNTS), 'exact retained delivery and original link')
|
||||
return value
|
||||
|
||||
|
||||
def native(path, ident=None):
|
||||
path = path.resolve()
|
||||
manifest = verified(path, current=ident is None)
|
||||
if ident is None:
|
||||
ident = str(uuid.uuid4());folder = NATIVE / ident;folder.mkdir(mode=0o700, parents=True)
|
||||
save(folder / 'intent.json', {'id': ident, 'manifest_path': str(path), 'manifest_sha256': sha(path),
|
||||
'runner_sha256': sha(__file__), 'script_sha256': hashlib.sha256(SCRIPT.encode()).hexdigest()})
|
||||
before = {'counts': auto.scopes(), 'flags': auto.status()}
|
||||
require(auto.flags_disabled(before['flags']), 'closed fault flags before native units')
|
||||
save(folder / 'server-before.json', before)
|
||||
for kind in COUNTS:
|
||||
previous.upload(manifest['artifacts'][kind])
|
||||
save(folder / 'started-local.json', {'start_once': True})
|
||||
action = 'run'
|
||||
else:
|
||||
require(str(uuid.UUID(ident)) == ident, 'canonical original native case')
|
||||
folder = NATIVE / ident;intent = cb.contract.protected_json(folder / 'intent.json')
|
||||
require(intent['manifest_sha256'] == sha(path) and intent['manifest_path'] == str(path)
|
||||
and intent['runner_sha256'] == sha(__file__)
|
||||
and intent['script_sha256'] == hashlib.sha256(SCRIPT.encode()).hexdigest(), 'same original case; readback only')
|
||||
action = 'read'
|
||||
result = cb.powershell(SCRIPT, {'id': ident, 'action': action, 'manifest_sha256': sha(path),
|
||||
'artifacts': {k: manifest['artifacts'][k] for k in COUNTS},
|
||||
'counts': COUNTS, 'test_names': TESTS}, timeout=150)
|
||||
save(folder / ('readback-' + str(uuid.uuid4()) + '.json'), result)
|
||||
if result.get('completed') is not True:
|
||||
print(json.dumps({'verified': False, 'case_id': ident, 'readback_only': True, 'completed': False,
|
||||
'case_exists': result.get('case_exists'), 'tests_repeated': False}))
|
||||
return
|
||||
require(result['manifest_sha256'] == sha(path) and set(result['reports']) == set(COUNTS)
|
||||
and result['both_lists_verified_before_any_test'] is True
|
||||
and result['rmm_jobs'] is False and result['product_state_writes'] is False
|
||||
and result['local_service_proof'] is False and result['native_pipe_proof'] is False,
|
||||
'actual narrow unit result, no runtime proof')
|
||||
for kind, actual in result['reports'].items():
|
||||
run, listed = actual['result'], actual['listed']
|
||||
names = re.findall(r'^(.+): test\r?$', listed['stdout'], re.M)
|
||||
require(actual['sha256'] == manifest['artifacts'][kind]['sha256']
|
||||
and names == actual['names'] == TESTS[kind] and len(set(names)) == COUNTS[kind]
|
||||
and listed['exit_code'] == run['exit_code'] == 0 and not listed['timed_out'] and not run['timed_out']
|
||||
and re.search(r'test result: ok\. ' + str(COUNTS[kind])
|
||||
+ r' passed; 0 failed; 0 ignored; 0 measured; 0 filtered out;', run['stdout']),
|
||||
'every exact named native unit passed, none skipped/filtered')
|
||||
before = cb.contract.protected_json(folder / 'server-before.json')
|
||||
require(auto.scopes() == before['counts'] and auto.status() == before['flags'], 'both central counts and closed flags unchanged')
|
||||
if action == 'run':
|
||||
verified(path) # Full before/after source and retained-artifact check.
|
||||
proof = {'verified': True, 'case_id': ident, 'manifest_path': str(path), 'manifest_sha256': sha(path),
|
||||
'native': result, 'no_jobs': True, 'clock_adapter_qualified': False,
|
||||
'local_service_proof': False, 'native_pipe_proof': False}
|
||||
destination = folder / 'passed.json'
|
||||
if destination.exists():
|
||||
require(cb.contract.protected_json(destination) == proof, 'retain exact original proof')
|
||||
else:
|
||||
save(destination, proof)
|
||||
print(json.dumps({'verified': True, 'case_id': ident, 'tests': COUNTS, 'proof': str(destination)}))
|
||||
|
||||
|
||||
def main():
|
||||
os.umask(0o077)
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('phase', choices=('build-local', 'native-units', 'readback'))
|
||||
parser.add_argument('--access-root', required=True, type=Path)
|
||||
parser.add_argument('--manifest', type=Path)
|
||||
parser.add_argument('--case')
|
||||
args = parser.parse_args()
|
||||
require(args.access_root == ACCESS and not args.access_root.is_symlink(), 'exact existing access root')
|
||||
if args.phase == 'build-local':
|
||||
require(args.manifest is None and args.case is None, 'build only')
|
||||
build()
|
||||
else:
|
||||
require(args.manifest is not None and ((args.phase == 'readback') == bool(args.case)), 'explicit manifest and original readback case')
|
||||
native(args.manifest, args.case)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except Exception as error:
|
||||
print('WINDOWS_PIPE_V2_QUALIFICATION_INCOMPLETE:' + type(error).__name__)
|
||||
raise SystemExit(2) from None
|
||||
Reference in New Issue
Block a user