Skip to content

Conversation

DavidBakerEffendi
Copy link
Contributor

This PR implements the other component of regex matching defining global variables. In Ruby, $1, $2, etc. correspond to the group matched in the last match. This is synonymous to how a MatchData object could refer to these matches.

This PR models these nref objects to $[1] and, during a match lowering, defines them to the corresponding index position of the lowered temp match object, i.e., $[1] = <tmp-0>[1] where N is determined by the number of opening parenthesis (simple heuristic).

Additionally, the lowered match calls have their methodFullName defined for convenient policy/semantic definition creation.

This PR implements the other component of regex matching defining global variables. In Ruby, `$1`, `$2`, etc. correspond to the group matched in the last match. This is synonymous to how a `MatchData` object could refer to these matches.

This PR models these `nref` objects to `$[1]` and, during a match lowering, defines them to the corresponding index position of the lowered temp match object, i.e., `$[1] = <tmp-0>[1]` where `N` is determined by the number of opening parenthesis (simple heuristic).

Additionally, the lowered `match` calls have their `methodFullName` defined for convenient policy/semantic definition creation.
@DavidBakerEffendi DavidBakerEffendi added the ruby Relates to rubysrc2cpg label Feb 12, 2025
@DavidBakerEffendi DavidBakerEffendi self-assigned this Feb 12, 2025
@DavidBakerEffendi DavidBakerEffendi merged commit c72d37d into master Feb 12, 2025
5 checks passed
@DavidBakerEffendi DavidBakerEffendi deleted the dave/ruby/indexed-group-global-vars branch February 12, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Relates to rubysrc2cpg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants