Skip to content

Hotfix: Replace regex with function#866

Merged
chrismaddalena merged 7 commits intomasterfrom
hotfix/regex-fix
Apr 13, 2026
Merged

Hotfix: Replace regex with function#866
chrismaddalena merged 7 commits intomasterfrom
hotfix/regex-fix

Conversation

@chrismaddalena
Copy link
Copy Markdown
Collaborator

@chrismaddalena chrismaddalena commented Apr 13, 2026

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.

Copilot AI review requested due to automatic review settings April 13, 2026 19:53
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread ghostwriter/oplog/utils.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 updated extract_cast_text() to use it.
  • Added/expanded unit tests for OSC (BEL/ST), Fe escapes, and malformed OSC fragments.
  • Added a repository-level AGENTS.md with 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).

Comment thread ghostwriter/oplog/utils.py
Comment thread AGENTS.md Outdated
Comment thread AGENTS.md Outdated
chrismaddalena and others added 3 commits April 13, 2026 13:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.21%. Comparing base (9e18d59) to head (57e35df).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
ghostwriter/oplog/utils.py 83.63% 9 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chrismaddalena chrismaddalena merged commit aafa978 into master Apr 13, 2026
5 of 6 checks passed
@chrismaddalena chrismaddalena deleted the hotfix/regex-fix branch April 13, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants