Skip to content

Add RCN Mutator (require(...) Condition Negation)#2998

Open
sidarth16 wants to merge 2 commits intocrytic:masterfrom
sidarth16:rcn-require-condition-negation
Open

Add RCN Mutator (require(...) Condition Negation)#2998
sidarth16 wants to merge 2 commits intocrytic:masterfrom
sidarth16:rcn-require-condition-negation

Conversation

@sidarth16
Copy link
Copy Markdown
Contributor

Summary

This PR adds a new mutator: RCN (Require Condition Negation).

RCN negates the first condition argument of require(...) calls.

Examples:

  • require(x > 0 && x < 10) -> require(!(x > 0 && x < 10))
  • require(msg.sender == owner, "not owner") -> require(!(msg.sender == owner), "not owner")
  • require(!isOwner, "owner-not-allowed") -> require(!(!isOwner), "owner-not-allowed")

Changes

  • Added RCN mutator:
    • slither/tools/mutator/mutators/RCN.py
  • Registered RCN in:
    • slither/tools/mutator/mutators/all_mutators.py
  • Added tests in:
    • tests/tools/mutator/test_mutator.py
      • mutator discovery check (_get_mutators(["RCN"]))
      • patch generation check for require(...) condition negation

Notes

  • This is scoped to require(...) only.
  • assert(...) condition negation (ACN) will be handled in a separate PR.
  • RCN is listed with # severity medium in all_mutators.py for consistency with the existing mutator list comments.
  • RCN is counted as tweak mutant by current framework rules (RR/CR special-cased)

Fixes #2997

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.

Enhancement: Add RCN Mutator (require(...) Condition Negation)

1 participant