fix(security): resolve CodeQL warnings#380
Merged
pkuczynski merged 1 commit intorubyconfig:masterfrom Jul 15, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
Fix CodeQL security warnings by replacing regex patterns with safer, clearer alternatives.
- Replace a complex regex in
method_missingwithString#end_with?to detect setter methods. - Update the environment parser regex to use an atomic grouping to prevent backtracking.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/config/options.rb | Swapped regex check for setter methods with method_name.to_s.end_with?('='). |
| lib/config/integrations/heroku.rb | Changed the trailing-word regex to use an atomic group (?>\w+) instead of (\w+). |
Comments suppressed due to low confidence (2)
lib/config/options.rb:153
- Consider adding unit tests for missing setter methods to ensure
fail_on_missingis correctly bypassed for setter calls and raises aKeyErrorfor undefined getters.
if Config.fail_on_missing && !method_name.to_s.end_with?('=')
lib/config/integrations/heroku.rb:29
- [nitpick] Add a brief comment explaining the use of the atomic grouping
(?>\w+)to clarify that it prevents regex backtracking and addresses the CodeQL warning.
heroku("run 'echo $RAILS_ENV'").chomp[/(?>\w+)\z/]
pkuczynski
approved these changes
Jul 15, 2025
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.
Fixed codeql security warnings: