Merge pull request #1442 from crytic/medariox-patch-1

Fix detection of library events
pull/1460/head
Feist Josselin 2 years ago committed by GitHub
commit ef61ca67a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      slither/slithir/convert.py
  2. BIN
      tests/ast-parsing/compile/library_event-0.8.16.sol-0.8.16-compact.zip
  3. 6
      tests/ast-parsing/expected/library_event-0.8.16.sol-0.8.16-compact.json
  4. 12
      tests/ast-parsing/library_event-0.8.16.sol
  5. 1
      tests/test_ast_parsing.py

@ -827,7 +827,7 @@ def extract_tmp_call(ins: TmpCall, contract: Optional[Contract]): # pylint: dis
# lib L { event E()} # lib L { event E()}
# ... # ...
# emit L.E(); # emit L.E();
if str(ins.ori.variable_right) in ins.ori.variable_left.events_as_dict: if str(ins.ori.variable_right) in [f.name for f in ins.ori.variable_left.events]:
eventcall = EventCall(ins.ori.variable_right) eventcall = EventCall(ins.ori.variable_right)
eventcall.set_expression(ins.expression) eventcall.set_expression(ins.expression)
eventcall.call_id = ins.call_id eventcall.call_id = ins.call_id

@ -0,0 +1,6 @@
{
"Lib": {},
"Test": {
"foo()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n}\n"
}
}

@ -0,0 +1,12 @@
pragma solidity 0.8.16;
library Lib {
event Event();
}
contract Test {
function foo() external {
emit Lib.Event(); // This line specifically
}
}

@ -424,6 +424,7 @@ ALL_TESTS = [
Test("free_functions/new_operator.sol", ["0.8.12"]), Test("free_functions/new_operator.sol", ["0.8.12"]),
Test("free_functions/library_constant_function_collision.sol", ["0.8.12"]), Test("free_functions/library_constant_function_collision.sol", ["0.8.12"]),
Test("ternary-with-max.sol", ["0.8.15"]), Test("ternary-with-max.sol", ["0.8.15"]),
Test("library_event-0.8.16.sol", ["0.8.16"]),
] ]
# create the output folder if needed # create the output folder if needed
try: try:

Loading…
Cancel
Save