[PR #4333] [CLOSED] fix(artifact): accept POSIX names beginning with letter-colon on non-Windows hosts #6176

Closed
opened 2026-10-31 01:12:27 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4333
Author: @KimChow
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: fix/artifact-posix-colon-path


📝 Commits (1)

  • 5469217 fix(artifact): accept POSIX names beginning with letter-colon on non-Windows hosts

📊 Changes

2 files changed (+72 additions, -3 deletions)

View changed files

📝 src/artifacts/ArtifactPaths.test.ts (+52 -0)
📝 src/artifacts/ArtifactPaths.ts (+20 -3)

📄 Description

Summary

On a POSIX host, inspect-artifact and extract-artifact aborted with artifact_operation_failed (reason path) whenever a top-level archive member's literal name began with an ASCII letter followed by a colon, because normalizeArtifactPath unconditionally treated the leading [A-Za-z]: as a Windows drive prefix. A valid ASAR produced by the official @electron/asar package containing the ordinary POSIX file a:b.txt could not be inventoried or extracted, even though the official ASAR reader lists and reads it (#3874).

Root cause

src/artifacts/ArtifactPaths.ts applied the drive-prefix check DRIVE_PREFIX.test(input) (/^[A-Za-z]:/u) on every platform. A leading [A-Za-z]: is a Windows drive letter only on Windows hosts; on POSIX hosts it is an ordinary, legal filename component. The controls ab:c.txt (two-letter start does not match the anchor) and nested/a:b.txt (the colon is not at the start of the logical path) were accepted, confirming the rejection keyed on the whole logical path's start rather than an invalid component.

Fix

normalizeArtifactPath now takes an optional platform: NodeJS.Platform = process.platform parameter and runs the drive-prefix check only when platform === "win32". Every one of the eight existing call sites passes a single argument, so the host platform is matched by default with no behavioral change on Windows (fail-closed: a literal a:b.txt still trips the rule there). POSIX hosts accept a:b.txt, nested/a:b.txt, and ab:c.txt.

Tests

src/artifacts/ArtifactPaths.test.ts gains a normalizeArtifactPath block that injects platform, asserting the issue member is accepted on POSIX and still rejected on win32, absolute paths and null bytes are still rejected on POSIX, and ordinary relative paths are accepted on win32.

Real POSIX evidence

Verified on a Linux host (Ubuntu 24.04, Node v24.15.0) by building this branch, generating the issue's fixture with the official @electron/asar, and running the real CLI:

$ node scripts/rea.mjs inspect-artifact fixture.asar   # contains a:b.txt
exit=0   (no "absolute or unsafe"; output lists a:b.txt; inventory_artifact substep completed)

$ node scripts/rea.mjs inspect-artifact control.asar   # contains ab:c.txt, nested/a:b.txt
exit=0   (both members listed)

$ node -e 'normalizeArtifactPath("a:b.txt")'            # process.platform === "linux"
=> "a:b.txt"   (accepted)

$ node -e 'normalizeArtifactPath("a:b.txt", "win32")'
=> throws Artifact path is absolute or unsafe: "a:b.txt"   (fail-closed)

Fixes #3874


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4333 **Author:** [@KimChow](https://github.com/KimChow) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/artifact-posix-colon-path` --- ### 📝 Commits (1) - [`5469217`](https://github.com/morluto/rea/commit/5469217c56fe8c1e01e31e6e6319adaf3f687c35) fix(artifact): accept POSIX names beginning with letter-colon on non-Windows hosts ### 📊 Changes **2 files changed** (+72 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/artifacts/ArtifactPaths.test.ts` (+52 -0) 📝 `src/artifacts/ArtifactPaths.ts` (+20 -3) </details> ### 📄 Description ## Summary On a POSIX host, `inspect-artifact` and `extract-artifact` aborted with `artifact_operation_failed` (reason `path`) whenever a top-level archive member's literal name began with an ASCII letter followed by a colon, because `normalizeArtifactPath` unconditionally treated the leading `[A-Za-z]:` as a Windows drive prefix. A valid ASAR produced by the official `@electron/asar` package containing the ordinary POSIX file `a:b.txt` could not be inventoried or extracted, even though the official ASAR reader lists and reads it (#3874). ## Root cause `src/artifacts/ArtifactPaths.ts` applied the drive-prefix check `DRIVE_PREFIX.test(input)` (`/^[A-Za-z]:/u`) on every platform. A leading `[A-Za-z]:` is a Windows drive letter only on Windows hosts; on POSIX hosts it is an ordinary, legal filename component. The controls `ab:c.txt` (two-letter start does not match the anchor) and `nested/a:b.txt` (the colon is not at the start of the logical path) were accepted, confirming the rejection keyed on the whole logical path's start rather than an invalid component. ## Fix `normalizeArtifactPath` now takes an optional `platform: NodeJS.Platform = process.platform` parameter and runs the drive-prefix check only when `platform === "win32"`. Every one of the eight existing call sites passes a single argument, so the host platform is matched by default with no behavioral change on Windows (fail-closed: a literal `a:b.txt` still trips the rule there). POSIX hosts accept `a:b.txt`, `nested/a:b.txt`, and `ab:c.txt`. ## Tests `src/artifacts/ArtifactPaths.test.ts` gains a `normalizeArtifactPath` block that injects `platform`, asserting the issue member is accepted on POSIX and still rejected on win32, absolute paths and null bytes are still rejected on POSIX, and ordinary relative paths are accepted on win32. ## Real POSIX evidence Verified on a Linux host (Ubuntu 24.04, Node v24.15.0) by building this branch, generating the issue's fixture with the official `@electron/asar`, and running the real CLI: ``` $ node scripts/rea.mjs inspect-artifact fixture.asar # contains a:b.txt exit=0 (no "absolute or unsafe"; output lists a:b.txt; inventory_artifact substep completed) $ node scripts/rea.mjs inspect-artifact control.asar # contains ab:c.txt, nested/a:b.txt exit=0 (both members listed) $ node -e 'normalizeArtifactPath("a:b.txt")' # process.platform === "linux" => "a:b.txt" (accepted) $ node -e 'normalizeArtifactPath("a:b.txt", "win32")' => throws Artifact path is absolute or unsafe: "a:b.txt" (fail-closed) ``` Fixes #3874 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:12:27 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6176
No description provided.