mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 08:03:13 +00:00
* Fix Codex WSL project trust conflating case-distinct Linux paths normalizeCodexProjectPathForLookup lowercased the entire Windows/UNC path, including the case-sensitive Linux portion under \\wsl$\<distro>. Two distinct WSL project dirs (.../Repo vs .../repo) collapsed onto one trust key, and the mirror dedupe (codex-config-mirror) inherited it. Preserve case for the Linux path after the case-insensitive \\wsl$\<distro> / \\wsl.localhost\<distro> share prefix; true Windows drive letters and normal UNC shares still case-fold as before. Co-authored-by: Orca <help@stably.ai> * Apply the same WSL case-fold fix to hook-trust key lookup normalizeHookTrustKeyForLookup had the identical latent bug: on a win32 host it lowercased the whole Windows-shaped path, folding the case-sensitive Linux tail of a \\wsl$\<distro> UNC hook path — contrary to its own comment that WSL sources stay case-sensitive. Extract foldWindowsCaseInsensitivePath (shared with the project-path normalizer): fold only the case-insensitive drive/\\wsl$ share prefix, preserve the Linux tail. Existing suffix (event:group:handler) is already lowercase, so behavior is unchanged there. Co-authored-by: Orca <help@stably.ai> * Fix Codex WSL trust revocation and hook-key case folding - Case-drifted or share-spelling-varied WSL revocations were being ignored on merge, letting stale "trusted" entries survive; fold revocation lookups fully so matching errs toward revoked. - Hook-trust key folding was gated on process.platform === 'win32', so WSL/SSH-remote hook sources weren't folded when Orca itself ran on macOS/Linux; fold by path shape instead, via the new shared foldWslUncPathCaseInsensitiveParts helper (also covers /mnt drvfs automounts and wsl$/wsl.localhost share aliasing). * Fix Codex WSL trust key case-folding regressions - Don't fold case-variant `/MNT` dirs as if they were the drvfs automount; only literal lowercase `/mnt/<drive>` folds. - Preserve an exact-cased trusted project entry in ~/.codex during runtime merge instead of letting a loosely-matched, case-drifted revocation clobber a user's re-granted trust on every mirror pass. - Minor cleanup: inline foldWindowsCaseInsensitivePath and hoist the repeated normalizeHookTrustKeyForLookup call in findTrustBlockRanges. * Refactor case-fold WSL trust test to assert real serializer output Extract path variables and assert against escapeTomlString(incomingPath) instead of a hardcoded escaped string literal, so the fixture can't silently drift from the actual TOML header serialization. --------- Co-authored-by: Orca <help@stably.ai>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
export type WslUncPathInfo = {
|
|
distro: string
|
|
linuxPath: string
|
|
}
|
|
|
|
export function parseWslUncPath(path: string): WslUncPathInfo | null {
|
|
const normalized = path.replace(/\\/g, '/')
|
|
const match = normalized.match(/^\/\/(wsl\.localhost|wsl\$)\/([^/]+)(\/.*)?$/i)
|
|
if (!match) {
|
|
return null
|
|
}
|
|
|
|
return {
|
|
distro: match[2],
|
|
linuxPath: match[3] || '/'
|
|
}
|
|
}
|
|
|
|
export function isWslUncPath(path: string): boolean {
|
|
return parseWslUncPath(path) !== null
|
|
}
|
|
|
|
// Why: Windows folds the share (\\wsl$ aliases \\wsl.localhost), the distro, and
|
|
// drvfs /mnt/<drive> tails case-insensitively; the rest of the Linux path is not.
|
|
export function foldWslUncPathCaseInsensitiveParts(path: string): string | null {
|
|
const parsed = parseWslUncPath(path)
|
|
if (!parsed) {
|
|
return null
|
|
}
|
|
// Why: the drvfs automount is literally lowercase /mnt — a case-variant like
|
|
// /MNT is an ordinary case-sensitive Linux dir and must not be folded.
|
|
const linuxPath = /^\/mnt\/[a-zA-Z](?:\/|$)/.test(parsed.linuxPath)
|
|
? parsed.linuxPath.toLowerCase()
|
|
: parsed.linuxPath
|
|
return `//wsl.localhost/${parsed.distro.toLowerCase()}${linuxPath === '/' ? '' : linuxPath}`
|
|
}
|