Additional updates

pull/1528/head
Josselin Feist 2 years ago
parent f12e367f29
commit d9ea635a83
  1. 2
      slither/detectors/attributes/constant_pragma.py
  2. 10
      slither/slithir/convert.py
  3. 10
      tests/test_source_unit.py

@ -32,7 +32,7 @@ class ConstantPragma(AbstractDetector):
info = ["Different versions of Solidity are used:\n"] info = ["Different versions of Solidity are used:\n"]
info += [f"\t- Version used: {[str(v) for v in versions]}\n"] info += [f"\t- Version used: {[str(v) for v in versions]}\n"]
for p in pragma: for p in sorted(pragma, key=lambda x: x.version):
info += ["\t- ", p, "\n"] info += ["\t- ", p, "\n"]
res = self.generate_result(info) res = self.generate_result(info)

@ -454,17 +454,21 @@ def _convert_type_contract(ir: Member) -> Assignment:
assert isinstance(ir.variable_left.type, TypeInformation) assert isinstance(ir.variable_left.type, TypeInformation)
contract = ir.variable_left.type.type contract = ir.variable_left.type.type
scope = ir.node.scope scope = ir.node.file_scope
if ir.variable_right == "creationCode": if ir.variable_right == "creationCode":
bytecode = scope.bytecode_init(contract.name) bytecode = scope.bytecode_init(
ir.node.compilation_unit.crytic_compile_compilation_unit, contract.name
)
assignment = Assignment(ir.lvalue, Constant(str(bytecode)), ElementaryType("bytes")) assignment = Assignment(ir.lvalue, Constant(str(bytecode)), ElementaryType("bytes"))
assignment.set_expression(ir.expression) assignment.set_expression(ir.expression)
assignment.set_node(ir.node) assignment.set_node(ir.node)
assignment.lvalue.set_type(ElementaryType("bytes")) assignment.lvalue.set_type(ElementaryType("bytes"))
return assignment return assignment
if ir.variable_right == "runtimeCode": if ir.variable_right == "runtimeCode":
bytecode = scope.bytecode_runtime(contract.name) bytecode = scope.bytecode_runtime(
ir.node.compilation_unit.crytic_compile_compilation_unit, contract.name
)
assignment = Assignment(ir.lvalue, Constant(str(bytecode)), ElementaryType("bytes")) assignment = Assignment(ir.lvalue, Constant(str(bytecode)), ElementaryType("bytes"))
assignment.set_expression(ir.expression) assignment.set_expression(ir.expression)
assignment.set_node(ir.node) assignment.set_node(ir.node)

@ -1,15 +1,7 @@
import inspect
from crytic_compile import CryticCompile
from crytic_compile.platform.solc_standard_json import SolcStandardJson
from solc_select import solc_select
from slither import Slither from slither import Slither
from slither.detectors import all_detectors
from slither.detectors.abstract_detector import AbstractDetector
def test_contract_info(): def test_contract_info() -> None:
slither = Slither("./tests/source_unit") slither = Slither("./tests/source_unit")
assert len(slither.compilation_units) == 1 assert len(slither.compilation_units) == 1

Loading…
Cancel
Save