Skip to content

Support hyphenated operations and negative constants in ROPChain parser (#38) - #39

Merged
ricardojrdez merged 1 commit into
masterfrom
fix-issue38-hyphens-negative-constants
Aug 12, 2026
Merged

Support hyphenated operations and negative constants in ROPChain parser (#38)#39
ricardojrdez merged 1 commit into
masterfrom
fix-issue38-hyphens-negative-constants

Conversation

@ricardojrdez

Copy link
Copy Markdown
Member

Summary

Fixes #38. The ROPChain file parser rejected two legitimate cases with Unable to parse operation:

  • Hyphenated operation names, e.g. jmp-rel (a real operation defined in rop3/roplang/jmp-rel.yaml). REGEX_OP limited the operation name to [a-zA-Z]+.
  • Negative constant operands, e.g. sub(REG1, -1). Operands were limited to [a-zA-Z0-9]+, so the leading minus sign broke the match. Immediates are parsed downstream via int(reg, 0) in operation.py, so negatives are otherwise valid.

The fix allows - in both the operation name and the operands in REGEX_OP, as suggested in the issue.

Testing

  • Added two regression tests in tests/test_ropchain.py exercising _parse_ropfile end to end:
    • test_parse_negative_constant_sourcesub(rax, -1) parses with src == '-1'.
    • test_parse_hyphenated_operation_namejmp-rel(rax) parses and expands into its concrete steps.
  • Full suite passes: 100 passed, 5 skipped (unrelated macOS Mach-O tests).

🤖 Generated with Claude Code

…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>
@ricardojrdez
ricardojrdez merged commit 0ada619 into master Aug 12, 2026
3 checks passed
@ricardojrdez
ricardojrdez deleted the fix-issue38-hyphens-negative-constants branch August 12, 2026 08:40
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.

ROPChain file parser fails for operations with hyphens and negative constants

1 participant