fix: sanitize filenames to prevent ANSI escape injection#306
Open
Koan-Bot wants to merge 1 commit intoTest-More:masterfrom
Open
fix: sanitize filenames to prevent ANSI escape injection#306Koan-Bot wants to merge 1 commit intoTest-More:masterfrom
Koan-Bot wants to merge 1 commit intoTest-More:masterfrom
Conversation
Add sanitize_filename() to Test2::Harness::Util that strips ANSI escape sequences (CSI/OSC) and replaces remaining control characters with caret notation. Applied at all display entry points: renderer, formatter, auditor, and command output. Fixes Test-More#286
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sanitize test filenames before displaying them in terminal output, preventing ANSI escape sequence injection.
Why
Filenames containing ANSI escape sequences can execute arbitrary terminal commands when displayed by yath (see #286, inspired by CVE-2025-XXXX). A malicious CPAN dist could include test files with crafted names that clear the screen, reposition the cursor, or worse when
yathruns them.How
sanitize_filename()toTest2::Harness::Util— strips CSI/OSC sequences, replaces remaining control characters with caret notation (e.g.\x01→^A)Renderer::Formatter(LAUNCH/RETRY/PASSED/FAILED tags)Formatter::Test2(active files status line)Auditor(final summary data: failed/retried/halted/unseen)Command::test,Command::failed,Command::abort,Command::status(direct prints)Testing
t/unit/Test2/Harness/Util.tcovering CSI stripping, OSC stripping, control char escaping, and combined casesFixes #286
Quality Report
Changes: 9 files changed, 62 insertions(+), 16 deletions(-)
Code scan: clean
Tests: failed (timeout (120s))
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline