Support hyphenated operations and negative constants in ROPChain parser (#38) - #39
Merged
Merged
Conversation
…er (#38) REGEX_OP restricted operation names to [a-zA-Z]+ and operands to [a-zA-Z0-9]+, so it rejected operations with a hyphen in the name (e.g. jmp-rel) and a minus sign before a constant operand (e.g. -1), failing with "Unable to parse operation". Allow '-' in both the operation name and the operands. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Fixes #38. The ROPChain file parser rejected two legitimate cases with
Unable to parse operation:jmp-rel(a real operation defined inrop3/roplang/jmp-rel.yaml).REGEX_OPlimited the operation name to[a-zA-Z]+.sub(REG1, -1). Operands were limited to[a-zA-Z0-9]+, so the leading minus sign broke the match. Immediates are parsed downstream viaint(reg, 0)inoperation.py, so negatives are otherwise valid.The fix allows
-in both the operation name and the operands inREGEX_OP, as suggested in the issue.Testing
tests/test_ropchain.pyexercising_parse_ropfileend to end:test_parse_negative_constant_source—sub(rax, -1)parses withsrc == '-1'.test_parse_hyphenated_operation_name—jmp-rel(rax)parses and expands into its concrete steps.🤖 Generated with Claude Code