Skip to content

Commit 0eca18f

Browse files
senamakelmedullabot
andcommitted
test(audit): classify native child stdin encoding without content
Co-authored-by: Medulla <medulla@tinyhumans.ai>
1 parent 7935fd9 commit 0eca18f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎crates/tinysecurity-audit/src/sink_windows_negative_tests.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ exit 0
352352
$file = Join-Path $PSHOME 'powershell.exe'
353353
$start = [Diagnostics.ProcessStartInfo]::new()
354354
$start.FileName = $file
355-
$start.Arguments = '-NoProfile -NonInteractive -Command "try { [Console]::WriteLine(''audit-account-stage=94 bootstrap=1''); $s=[Console]::In.ReadToEnd(); [Console]::WriteLine(''audit-account-stage=94 bootstrap=2 source-length=''+$s.Length); $b=[ScriptBlock]::Create($s); [Console]::WriteLine(''audit-account-stage=94 bootstrap=3''); & $b } catch { $k=0; if($_.Exception -is [System.Management.Automation.ParseException]){$k=4}; [Console]::WriteLine(''audit-account-stage=95 category=''+$k+'' hresult=''+$_.Exception.HResult); if($null -ne $_.Exception.InnerException){[Console]::WriteLine(''audit-account-stage=95 inner-hresult=''+$_.Exception.InnerException.HResult)}; exit 89 }"'
355+
$start.Arguments = '-NoProfile -NonInteractive -Command "try { $o=[Console]::Out; $o.WriteLine(''audit-account-stage=94 bootstrap=1''); $s=[Console]::In.ReadToEnd(); $p=([int[]][char[]]$s.Substring(0,[Math]::Min(3,$s.Length)) -join ''-''); $e=[int]$s.StartsWith(''$ErrorActionPreference''); $o.WriteLine(''audit-account-stage=94 bootstrap=2 source-length=''+$s.Length+'' reader-codepage=''+[Console]::InputEncoding.CodePage+'' prefix=''+$p+'' expected-prefix=''+$e); $b=[ScriptBlock]::Create($s); $o.WriteLine(''audit-account-stage=94 bootstrap=3''); & $b } catch { $k=0; if($_.Exception -is [System.Management.Automation.ParseException]){$k=4}; if($_.Exception -is [System.Management.Automation.CommandNotFoundException]){$k=5}; $o.WriteLine(''audit-account-stage=95 category=''+$k+'' hresult=''+$_.Exception.HResult); if($null -ne $_.Exception.InnerException){$o.WriteLine(''audit-account-stage=95 inner-hresult=''+$_.Exception.InnerException.HResult)}; exit 89 }"'
356356
$start.UseShellExecute = $false
357357
$start.UserName = $network.UserName
358358
$start.Domain = $network.Domain
@@ -374,6 +374,7 @@ exit 0
374374
$started = $true
375375
$stdout = $process.StandardOutput.ReadToEndAsync()
376376
$stderr = $process.StandardError.ReadToEndAsync()
377+
Write-Output ('audit-account-stage=97 writer-codepage=' + $process.StandardInput.Encoding.CodePage + ' preamble-length=' + $process.StandardInput.Encoding.GetPreamble().Length)
377378
$process.StandardInput.WriteLine($childScript)
378379
$process.StandardInput.Close()
379380
$stage = 40
@@ -383,7 +384,7 @@ exit 0
383384
$requiredPhases = @('audit-account-stage=90 foreign-identity=1 nonadmin=1', 'audit-account-stage=91 exact-control-read=1', 'audit-account-stage=92 private-file-denials=6', 'audit-account-stage=93 namespace-denial=1')
384385
$allLines = @($stdout.Result.Split([char]10) | ForEach-Object { $_.TrimEnd([char]13) } | Where-Object { $_.Length -gt 0 })
385386
$lines = @($allLines | Where-Object { $requiredPhases -ccontains $_ })
386-
$diagnostics = @($allLines | Where-Object { $_ -cmatch '^audit-account-stage=94 bootstrap=[123]( source-length=[0-9]+)?$|^audit-account-stage=95 (category=[0-9]+ hresult=-?[0-9]+|inner-hresult=-?[0-9]+)$|^audit-account-stage=96 (child-entry|identity-read)=1$' })
387+
$diagnostics = @($allLines | Where-Object { $_ -cmatch '^audit-account-stage=94 bootstrap=[13]$|^audit-account-stage=94 bootstrap=2 source-length=[0-9]+ reader-codepage=[0-9]+ prefix=[0-9-]* expected-prefix=[01]$|^audit-account-stage=95 (category=[0-9]+ hresult=-?[0-9]+|inner-hresult=-?[0-9]+)$|^audit-account-stage=96 (child-entry|identity-read)=1$' })
387388
foreach ($line in $allLines) {
388389
if (($requiredPhases -ccontains $line) -or ($diagnostics -ccontains $line)) { Write-Output $line }
389390
}

0 commit comments

Comments
 (0)