Skip to content

Add ACN Mutator (assert(...) Condition Negation)#3000

Open
sidarth16 wants to merge 3 commits intocrytic:masterfrom
sidarth16:acn-assert-condition-negation
Open

Add ACN Mutator (assert(...) Condition Negation)#3000
sidarth16 wants to merge 3 commits intocrytic:masterfrom
sidarth16:acn-assert-condition-negation

Conversation

@sidarth16
Copy link
Copy Markdown
Contributor

Summary

This PR introduces ACN (Assert Condition Negation) to the mutator set.

The mutator rewrites the first condition argument of assert(...) by wrapping it in a negation, so assertion-style guards can be flipped during mutation testing.

Examples:

  • assert(x > 0 && x < 10) becomes assert(!(x > 0 && x < 10))
  • assert(msg.sender == owner) becomes assert(!(msg.sender == owner))
  • assert(!isOwner) becomes assert(!(!isOwner))

Changes

  • Added ACN mutator:
    • slither/tools/mutator/mutators/ACN.py
    • detects assert(...) calls & generates a patch that rewrites the condition as !(...)
  • Register ACN mutator in:
    • slither/tools/mutator/mutators/all_mutators.py
  • Updated test Contract:
    • Added assert(..) statement in tests/tools/mutator/test_data/test_source_unit/src/Counter.sol
  • Added tests in:
    • tests/tools/mutator/test_mutator.py testing the ACN mutator

Notes

  • This PR is intentionally limited to assert(...) mutations.
  • The require(...) variant is being handled separately in PR Add RCN Mutator (require(...) Condition Negation) #2998.
  • ACN is listed with # severity medium in all_mutators.py for consistency with the existing mutator list comments.
  • ACN is counted as tweak mutant by current framework rules (RR/CR special-cased)

Fixes #2999

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 ACN Mutator (assert(...) Condition Negation)

1 participant