feat(filename): suffix Windows reserved names - #83
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 11:11 PM ET / August 2, 2026, 03:11 UTC. ClawSweeper reviewWhat this changesThe PR changes Merge readinessKeep this PR open for normal maintainer review. Current Priority: P2 Review scores
Verification
How this fits togetherThe filename sanitizer reduces attacker-controlled input to one portable filename segment before external-output and sibling-temp helpers use it in filesystem operations. The device-path module already defines Windows device names for guarded reads; this PR reuses that data to prevent sanitized names from resolving to Windows devices. flowchart LR
A[Untrusted filename] --> B[Filename sanitizer]
B --> C[Character and path cleanup]
C --> D[Windows reserved-name check]
D --> E[Portable filename segment]
E --> F[Output and temp-file helpers]
E --> G[Filesystem write target]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the shared reserved-name suffix rule with its focused tests and documentation so untrusted filename inputs remain usable while avoiding Windows device basenames across platforms. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds an explicitly described filename-portability behavior rather than repairing a current-main reproduction. Is this the best way to solve the issue? Yes. Reusing the device-path reserved-name set avoids divergent Windows-name lists, and suffixing preserves a usable filename segment while preventing a reserved basename from reaching later filesystem helpers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0965b89390ad. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Summary
_while preserving original case and extensions on every platformWINDOWS_RESERVED_DEVICE_NAMESset between device-path checks and filename sanitizationApproved contract
Examples:
CON→CON_nul.txt→nul_.txtaux.c→aux_.cconin$→conin$_Detection is case-insensitive, transformation preserves case, the suffix is inserted before the first extension, and the result is then capped at 200 characters. Empty,
., and..results retain the existing fallback behavior.Proof
pnpm exec vitest run test/filename.test.ts test/device-path.test.ts— 47 passedpnpm check— 645 passed, 25 skipped; packaged-consumer check passedpnpm test:security— 62 passedpnpm docs:site— built successfully{ CON: 'CON_', 'nul.txt': 'nul_.txt', 'aux.c': 'aux_.c' }Release note
This portability-contract addition makes the next release minor:
0.6.0. No release is authorized until Peter gives the release word.