Hotfix: Replace regex with function#866
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5326f5e92
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR mitigates a potential ReDoS risk in asciinema text extraction by replacing an ANSI escape stripping regex with a linear-scan function, and adds an agent/onboarding guideline document for the repository.
Changes:
- Replaced the ANSI escape sequence regex with
_strip_ansi_escapes()and updatedextract_cast_text()to use it. - Added/expanded unit tests for OSC (BEL/ST), Fe escapes, and malformed OSC fragments.
- Added a repository-level
AGENTS.mdwith project structure, commands, and style/testing guidelines.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
ghostwriter/oplog/utils.py |
Introduces _strip_ansi_escapes() and uses it during asciicast event extraction. |
ghostwriter/oplog/tests/test_utils.py |
Adds test coverage for additional ANSI/OSC stripping scenarios and malformed inputs. |
AGENTS.md |
Adds onboarding guidance for AI agents (structure, commands, style, and PR expectations). |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #866 +/- ##
==========================================
- Coverage 92.22% 92.21% -0.01%
==========================================
Files 384 384
Lines 23896 23983 +87
==========================================
+ Hits 22038 22116 +78
- Misses 1858 1867 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR replaces the ANSI escape regex with a new function called
_strip_ansi_escapes(). This change addresses a potential issue with that original expression's use of backtracking when parsing Asciinema recordings. While we did not encounter any issues with simulated terminal recordings, the backtracking could result in a ReDOS scenario. The function retains all the same escaping and behavior without the regex.I am also using this to introduce the AGENTS.md files for onboarding AI agents to the repository and fixing the packages lock file.