This commit is contained in:
@@ -321,8 +321,9 @@ $rootSddl=(Get-Acl -LiteralPath $helperRoot).Sddl
|
||||
$heldAgent=[RmmPipeNative]::Open([int]$before.service.pid);$heldHelper=[RmmPipeNative]::Open([int]$before.helper_service.pid)
|
||||
try{
|
||||
$null=Kernel 'agent' $before.service $heldAgent;$null=Kernel 'helper' $before.helper_service $heldHelper
|
||||
$installNotBefore=[DateTime]::UtcNow.ToString('o')
|
||||
NewPrivateCase
|
||||
WriteNew (Join-Path $folder 'intent.json') @{id=$request.id;request=$request;before=$before;original_root_sddl=$rootSddl;no_retry=$true}
|
||||
WriteNew (Join-Path $folder 'intent.json') @{id=$request.id;request=$request;before=$before;original_root_sddl=$rootSddl;install_not_before=$installNotBefore;no_retry=$true}
|
||||
WriteNew $active @{id=$request.id;config_sha256=$request.config_sha256;script_sha256=$request.script_sha256;no_retry=$true}
|
||||
foreach($item in $request.provenance.PSObject.Properties){if($item.Name-cnotmatch'^(platform-provenance|public-platform|original-public-platform|agent-qualification|system_helper-qualification|qualified-time-public-key|public-binding)\.json$'){throw 'Closed public provenance leaves'};$raw=[Convert]::FromBase64String($item.Value);if($raw.Length-gt65536){throw 'Bounded public provenance'};WriteBytes (Join-Path $folder $item.Name) $raw}
|
||||
$staged=Join-Path $folder 'time-attestation.candidate.json';WriteBytes $staged $bytes;SetPinAcl $staged
|
||||
@@ -342,7 +343,7 @@ try{
|
||||
if(!(JsonEqual $published $stagedId)){throw 'Exact same file identity/hash/ACL after publication'}
|
||||
$after=ActualState $true;SameLive $before $after
|
||||
$null=Kernel 'agent' $before.service $heldAgent;$null=Kernel 'helper' $before.helper_service $heldHelper
|
||||
$result=@{id=$request.id;installed=$true;configuration=$published;native=$after;original_root_sddl=$rootSddl;root_sddl=(Get-Acl -LiteralPath $helperRoot).Sddl;no_jobs=$true;clock_runtime_qualified=$false;services_changed=$false;private_key_read=$false}
|
||||
$result=@{id=$request.id;installed=$true;install_not_before=$installNotBefore;configuration=$published;native=$after;original_root_sddl=$rootSddl;root_sddl=(Get-Acl -LiteralPath $helperRoot).Sddl;no_jobs=$true;clock_runtime_qualified=$false;services_changed=$false;private_key_read=$false}
|
||||
WriteNew (Join-Path $folder 'result.json') $result;$result|ConvertTo-Json -Depth 50 -Compress
|
||||
}finally{$heldAgent.Dispose();$heldHelper.Dispose()}
|
||||
'''.replace('exit0','exit 0')
|
||||
@@ -371,6 +372,15 @@ function WriteNew($path,$value){WriteBytes $path ([Text.Encoding]::UTF8.GetBytes
|
||||
STRUCTURAL = r'''function CanonicalStateValue($value,[int]$depth=0){
|
||||
if($depth-gt40){throw 'Bounded state comparison depth'}
|
||||
if($null-eq$value){return $null}
|
||||
# ETS wrapping does not turn a CLR JSON scalar into a JSON object.
|
||||
$base=$value.PSObject.BaseObject;$culture=[Globalization.CultureInfo]::InvariantCulture
|
||||
if($base-is[string]){return [string]::new($base.ToCharArray())}
|
||||
if($base-is[char]){return [string]::new([char[]]@($base))}
|
||||
if($base-is[bool]){return [bool]::Parse($base.ToString())}
|
||||
if($base-is[sbyte]-or$base-is[int16]-or$base-is[int32]-or$base-is[int64]){return [int64]::Parse($base.ToString($culture),$culture)}
|
||||
if($base-is[byte]-or$base-is[uint16]-or$base-is[uint32]-or$base-is[uint64]){return [uint64]::Parse($base.ToString($culture),$culture)}
|
||||
if($base-is[single]-or$base-is[double]){$number=[double]::Parse($base.ToString('R',$culture),$culture);if([double]::IsNaN($number)-or[double]::IsInfinity($number)){throw 'Finite JSON state number required'};return $number}
|
||||
if($base-is[decimal]){return [decimal]::Parse($base.ToString($culture),$culture)}
|
||||
if($value-is[Collections.IDictionary]){$result=[ordered]@{};foreach($key in @($value.Keys|Sort-Object -CaseSensitive)){if($key-isnot[string]-or$result.Contains($key)){throw 'Nonunique state object key'};$result[$key]=CanonicalStateValue $value[$key] ($depth+1)};return $result}
|
||||
if($value-is[pscustomobject]){$result=[ordered]@{};foreach($property in @($value.PSObject.Properties|Sort-Object -Property Name -CaseSensitive)){if($property.Name-isnot[string]-or$result.Contains($property.Name)){throw 'Nonunique state object key'};$result[$property.Name]=CanonicalStateValue $property.Value ($depth+1)};return $result}
|
||||
if($value-is[Collections.IEnumerable]-and$value-isnot[string]){$result=New-Object 'Collections.Generic.List[object]';foreach($item in $value){$result.Add((CanonicalStateValue $item ($depth+1)))};return ,$result.ToArray()}
|
||||
|
||||
Reference in New Issue
Block a user