Skip to content

feat: add SAOR mutator to swap same-typed function arguments#2975

Open
ep0chzer0 wants to merge 2 commits intocrytic:masterfrom
ep0chzer0:feat/saor-mutator
Open

feat: add SAOR mutator to swap same-typed function arguments#2975
ep0chzer0 wants to merge 2 commits intocrytic:masterfrom
ep0chzer0:feat/saor-mutator

Conversation

@ep0chzer0
Copy link
Contributor

Summary

  • Adds a new SAOR (Swap Arguments Order Replacement) mutator that generates mutations by swapping function call arguments when they share the same type
  • Walks the IR to find HighLevelCall, InternalCall, and LibraryCall operations, then identifies parameter pairs with matching types and swaps the corresponding source-level arguments
  • Skips identical arguments (no-op swaps) and validates source mapping offsets before patching
  • Includes test contract and unit test

Closes #2947

Test plan

  • CI passes (ruff, pylint, pytest)
  • test_saor_generates_patches verifies patches are generated for same-typed args
  • test_get_mutators continues to discover all registered mutators
  • Manual verification: slither-mutate with --mutators-to-run SAOR on a contract with same-typed function parameters

🤖 Generated with Claude Code

Adds the Swap Arguments Order Replacement (SAOR) mutator that generates
mutations by swapping function call arguments when they share the same
type. This helps detect test suites that don't verify argument ordering.

Closes crytic#2947

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The _mutate() method returns {'patches': {file: [...]}} not {file: [...]}.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

add mutator to swap argument calling order if arguments are of the same type

1 participant