|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
from pathlib import Path |
|
|
|
|
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.slithir.operations import InternalCall, LibraryCall |
|
|
|
@ -12,8 +11,8 @@ TEST_DATA_DIR = Path(__file__).resolve().parent / "test_data" |
|
|
|
|
USING_FOR_TEST_DATA_DIR = Path(TEST_DATA_DIR, "using_for") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_using_for_global_collision(use_solc_version) -> None: |
|
|
|
|
solc_path = next(use_solc_version("0.8.15")) |
|
|
|
|
def test_using_for_global_collision(solc_binary_path) -> None: |
|
|
|
|
solc_path = solc_binary_path("0.8.15") |
|
|
|
|
standard_json = SolcStandardJson() |
|
|
|
|
for source_file in Path(USING_FOR_TEST_DATA_DIR, "using_for_global_collision").rglob("*.sol"): |
|
|
|
|
standard_json.add_source_file(Path(source_file).as_posix()) |
|
|
|
@ -22,9 +21,11 @@ def test_using_for_global_collision(use_solc_version) -> None: |
|
|
|
|
_run_all_detectors(sl) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_using_for_top_level_same_name(use_solc_version) -> None: |
|
|
|
|
solc_path = next(use_solc_version("0.8.15")) |
|
|
|
|
slither = Slither(Path(USING_FOR_TEST_DATA_DIR, "using-for-3-0.8.0.sol").as_posix(), solc=solc_path) |
|
|
|
|
def test_using_for_top_level_same_name(solc_binary_path) -> None: |
|
|
|
|
solc_path = solc_binary_path("0.8.15") |
|
|
|
|
slither = Slither( |
|
|
|
|
Path(USING_FOR_TEST_DATA_DIR, "using-for-3-0.8.0.sol").as_posix(), solc=solc_path |
|
|
|
|
) |
|
|
|
|
contract_c = slither.get_contract_from_name("C")[0] |
|
|
|
|
libCall = contract_c.get_function_from_full_name("libCall(uint256)") |
|
|
|
|
for ir in libCall.all_slithir_operations(): |
|
|
|
@ -33,9 +34,11 @@ def test_using_for_top_level_same_name(use_solc_version) -> None: |
|
|
|
|
assert False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_using_for_top_level_implicit_conversion(use_solc_version) -> None: |
|
|
|
|
solc_path = next(use_solc_version("0.8.15")) |
|
|
|
|
slither = Slither(Path(USING_FOR_TEST_DATA_DIR, "using-for-4-0.8.0.sol").as_posix(), solc=solc_path) |
|
|
|
|
def test_using_for_top_level_implicit_conversion(solc_binary_path) -> None: |
|
|
|
|
solc_path = solc_binary_path("0.8.15") |
|
|
|
|
slither = Slither( |
|
|
|
|
Path(USING_FOR_TEST_DATA_DIR, "using-for-4-0.8.0.sol").as_posix(), solc=solc_path |
|
|
|
|
) |
|
|
|
|
contract_c = slither.get_contract_from_name("C")[0] |
|
|
|
|
libCall = contract_c.get_function_from_full_name("libCall(uint16)") |
|
|
|
|
for ir in libCall.all_slithir_operations(): |
|
|
|
@ -44,10 +47,11 @@ def test_using_for_top_level_implicit_conversion(use_solc_version) -> None: |
|
|
|
|
assert False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_using_for_alias_top_level(use_solc_version) -> None: |
|
|
|
|
solc_path = next(use_solc_version("0.8.15")) |
|
|
|
|
def test_using_for_alias_top_level(solc_binary_path) -> None: |
|
|
|
|
solc_path = solc_binary_path("0.8.15") |
|
|
|
|
slither = Slither( |
|
|
|
|
Path(USING_FOR_TEST_DATA_DIR, "using-for-alias-top-level-0.8.0.sol").as_posix(), solc=solc_path |
|
|
|
|
Path(USING_FOR_TEST_DATA_DIR, "using-for-alias-top-level-0.8.0.sol").as_posix(), |
|
|
|
|
solc=solc_path, |
|
|
|
|
) |
|
|
|
|
contract_c = slither.get_contract_from_name("C")[0] |
|
|
|
|
libCall = contract_c.get_function_from_full_name("libCall(uint256)") |
|
|
|
@ -64,10 +68,11 @@ def test_using_for_alias_top_level(use_solc_version) -> None: |
|
|
|
|
assert False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_using_for_alias_contract(use_solc_version) -> None: |
|
|
|
|
solc_path = next(use_solc_version("0.8.15")) |
|
|
|
|
def test_using_for_alias_contract(solc_binary_path) -> None: |
|
|
|
|
solc_path = solc_binary_path("0.8.15") |
|
|
|
|
slither = Slither( |
|
|
|
|
Path(USING_FOR_TEST_DATA_DIR, "using-for-alias-contract-0.8.0.sol").as_posix(), solc=solc_path |
|
|
|
|
Path(USING_FOR_TEST_DATA_DIR, "using-for-alias-contract-0.8.0.sol").as_posix(), |
|
|
|
|
solc=solc_path, |
|
|
|
|
) |
|
|
|
|
contract_c = slither.get_contract_from_name("C")[0] |
|
|
|
|
libCall = contract_c.get_function_from_full_name("libCall(uint256)") |
|
|
|
@ -84,9 +89,11 @@ def test_using_for_alias_contract(use_solc_version) -> None: |
|
|
|
|
assert False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_using_for_in_library(use_solc_version) -> None: |
|
|
|
|
solc_path = next(use_solc_version("0.8.15")) |
|
|
|
|
slither = Slither(Path(USING_FOR_TEST_DATA_DIR, "using-for-in-library-0.8.0.sol").as_posix(), solc=solc_path) |
|
|
|
|
def test_using_for_in_library(solc_binary_path) -> None: |
|
|
|
|
solc_path = solc_binary_path("0.8.15") |
|
|
|
|
slither = Slither( |
|
|
|
|
Path(USING_FOR_TEST_DATA_DIR, "using-for-in-library-0.8.0.sol").as_posix(), solc=solc_path |
|
|
|
|
) |
|
|
|
|
contract_c = slither.get_contract_from_name("A")[0] |
|
|
|
|
libCall = contract_c.get_function_from_full_name("a(uint256)") |
|
|
|
|
for ir in libCall.all_slithir_operations(): |
|
|
|
|