test: avoid regex in multipart boundary test#304
Merged
Conversation
ffd8a9f to
472ddec
Compare
HAYDEN-OAI
approved these changes
Jul 13, 2026
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
thanks, this is a clean fix. the direct prefix check is stricter than the removed regex, keeps the non-empty and boundary-length assertions, and avoids the codeql sink without changing runtime code. the ruby 3.2 through 4.0 test matrix is green. approving!
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.
Summary
Addresses code scanning alert #1.
Root cause
The multipart encoding test extracted a library-generated boundary with
/boundary=(.+)$/. CodeQL classified that regex as potentially polynomial on uncontrolled data. The boundary is fixed-length and generated internally, and the gem requires Ruby 3.2+, but the regex is unnecessary; direct prefix validation and removal express the invariant more precisely and avoid the flagged sink entirely.Validation
bundle exec rake test TEST=test/openai/internal/util_test.rb— 36 runs, 156 assertions, 0 failuresbundle exec rake lint:rubocop— 2,537 files inspected, no offensesbundle exec ruby -c test/openai/internal/util_test.rb— syntax OKgit diff --check— passedThe full generated-resource suite was also attempted, but it requires the external Steady mock server at
localhost:4010; without that server, unrelated API tests fail with connection errors.