-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTest-CodexControlOtherDevices.ps1
More file actions
103 lines (92 loc) · 4.07 KB
/
Copy pathTest-CodexControlOtherDevices.ps1
File metadata and controls
103 lines (92 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
[CmdletBinding()]
param(
[switch]$Json,
[string[]]$NodePath
)
$ErrorActionPreference = 'Stop'
$projectRoot = $PSScriptRoot
$checker = Join-Path $projectRoot 'src\check-package.mjs'
Import-Module (Join-Path $projectRoot 'src\persistence\modules\CompatibilityProbe.psm1') -Force
$reasons = [System.Collections.Generic.List[string]]::new()
$warnings = [System.Collections.Generic.List[string]]::new()
$result = [ordered]@{
Ready = $false
OperatingSystem = [System.Environment]::OSVersion.VersionString
IsWindows = $env:OS -eq 'Windows_NT' -or $PSVersionTable.PSEdition -eq 'Desktop'
PackageInstalled = $false
PackageFullName = $null
PackageFamilyName = $null
PackageInstallLocation = $null
PackageVersion = $null
ExecutablePath = $null
AppAsarPath = $null
NodePath = $null
NodeVersion = $null
NodeMajor = $null
NodeSupported = $false
NodeCapabilities = $null
SchemaVersion = $null
StaticClassification = 'UnknownOrIncompatible'
AppAsarSha256 = $null
PackageSignatures = $null
AffectedBuildDetected = $false
Code = $null
Message = $null
Reasons = $reasons
Warnings = $warnings
}
try {
if (-not $result.IsWindows) {
$reasons.Add('This workaround supports Windows only.')
}
if (-not [string]::IsNullOrWhiteSpace($env:CODEX_HOME) -and
-not [System.IO.Path]::IsPathRooted($env:CODEX_HOME)) {
$reasons.Add('CODEX_HOME must be an absolute path so launch and rollback resolve the same key store.')
}
$nodeCandidates = @($NodePath)
if (-not $PSBoundParameters.ContainsKey('NodePath')) {
$nodeCommand = Get-Command node.exe -ErrorAction SilentlyContinue
if ($nodeCommand) {
$nodeCandidates = @([IO.Path]::GetFullPath([string]$nodeCommand.Source))
}
}
$probe = Invoke-CcodStaticProbe -NodeCandidates $nodeCandidates -CheckerPath $checker
foreach ($name in @('PackageInstalled', 'PackageFullName', 'PackageFamilyName', 'PackageInstallLocation', 'PackageVersion', 'ExecutablePath', 'AppAsarPath', 'NodePath', 'NodeVersion', 'NodeMajor', 'NodeSupported', 'NodeCapabilities', 'SchemaVersion', 'StaticClassification', 'AppAsarSha256', 'PackageSignatures', 'AffectedBuildDetected', 'Code', 'Message')) {
$result[$name] = $probe.$name
}
$formattedProbe = Get-CcodPublicProbeResult -Probe $probe -CheckerPath $checker
foreach ($reason in $formattedProbe.Reasons) { $reasons.Add($reason) }
$warnings.Add('Account authentication cannot be verified locally. Complete any MFA, SSO, or passkey required by the account/workspace; the tested account required MFA before enrollment.')
$warnings.Add('The renderer debug endpoint remains on 127.0.0.1 until Codex exits; run only on a trusted machine.')
$result.Ready = $result.IsWindows -and
$result.PackageInstalled -and
$result.NodeSupported -and
$result.AffectedBuildDetected -and
$reasons.Count -eq 0
} catch {
$reasons.Add($_.Exception.Message)
$result.Ready = $false
}
if ($Json) {
$result | ConvertTo-Json -Depth 8 -Compress
} else {
Write-Host ''
Write-Host 'CodexRemote-fix - compatibility check' -ForegroundColor Cyan
Write-Host (' Ready: {0}' -f $result.Ready)
$packageDisplay = if ($null -eq $result.PackageVersion) { 'not found' } else { $result.PackageVersion }
$nodeDisplay = if ($null -eq $result.NodeVersion) { 'not found' } else { $result.NodeVersion }
Write-Host (' Codex package: {0}' -f $packageDisplay)
Write-Host (' Node.js: {0}' -f $nodeDisplay)
Write-Host (' Heuristic match: {0}' -f $result.AffectedBuildDetected)
Write-Host (' Static class: {0}' -f $result.StaticClassification)
if ($reasons.Count -gt 0) {
Write-Host ''
Write-Host 'Blocking findings:' -ForegroundColor Red
foreach ($reason in $reasons) { Write-Host " - $reason" }
}
Write-Host ''
Write-Host 'Security notes:' -ForegroundColor Yellow
foreach ($warning in $warnings) { Write-Host " - $warning" }
Write-Host ''
}
if (-not $result.Ready) { exit 1 }