mirror of https://github.com/ConsenSys/mythril
blockchainethereumsmart-contractssoliditysecurityprogram-analysissecurity-analysissymbolic-execution
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.5 KiB
37 lines
1.5 KiB
from unittest import TestCase
|
|
from pathlib import Path
|
|
|
|
from mythril.analysis.report import Report
|
|
from mythril.analysis.security import fire_lasers
|
|
from mythril.analysis.symbolic import SymExecWrapper
|
|
from mythril.ether import util
|
|
from mythril.ether.soliditycontract import SolidityContract
|
|
|
|
TEST_FILES = Path(__file__).parents[1] / "testdata"
|
|
|
|
def _fix_path(text):
|
|
return text.replace(str(TEST_FILES), "<TEST_FILES>")
|
|
|
|
class AnalysisReportTest(TestCase):
|
|
|
|
def test_reports(self):
|
|
for input_file in TEST_FILES.iterdir():
|
|
if input_file.is_file and input_file.suffix == '.sol':
|
|
contract = SolidityContract(str(input_file), name=None, solc_args=None)
|
|
sym = SymExecWrapper(contract, address=(util.get_indexed_address(0)))
|
|
issues = fire_lasers(sym)
|
|
|
|
for issue in issues:
|
|
issue.add_code_info(contract)
|
|
|
|
report = Report()
|
|
for issue in issues:
|
|
report.append_issue(issue)
|
|
|
|
text = (TEST_FILES / (input_file.name + ".text")).read_text()
|
|
json = (TEST_FILES / (input_file.name + ".json")).read_text()
|
|
markdown = (TEST_FILES / (input_file.name + ".markdown")).read_text()
|
|
|
|
self.assertEqual(_fix_path(report.as_text()), text)
|
|
self.assertEqual(_fix_path(report.as_json()), json)
|
|
self.assertEqual(_fix_path(report.as_markdown()), markdown)
|
|
|