From 389a2cc810da3452474f610f2f45e20a3e969764 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 9 Sep 2019 10:06:14 -0400 Subject: [PATCH] Add trial mode messaging --- mythril/mythx/__init__.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/mythril/mythx/__init__.py b/mythril/mythx/__init__.py index 3f2b9616..80d60e7d 100644 --- a/mythril/mythx/__init__.py +++ b/mythril/mythx/__init__.py @@ -1,6 +1,9 @@ +import sys + import os import time +from mythx_models.exceptions import MythXAPIError from typing import List, Dict, Any from mythril.analysis.report import Issue, Report @@ -30,6 +33,11 @@ def analyze(contracts: List[SolidityContract], analysis_mode: str = "quick") -> password=os.environ.get("MYTHX_PASSWORD", "trial"), ) + if c.eth_address == "0x0000000000000000000000000000000000000000": + print( + "You are currently running MythX in Trial mode. This mode reports only a partial analysis of your smart contracts, limited to three vulnerabilities. To get a more complete analysis, sign up for a free account at https://mythx.io." + ) + issues = [] # type: List[Issue] # TODO: Analyze multiple contracts asynchronously. @@ -61,15 +69,18 @@ def analyze(contracts: List[SolidityContract], analysis_mode: str = "quick") -> pass assert contract.creation_code, "Creation bytecode must exist." - resp = c.analyze( - contract_name=contract.name, - analysis_mode=analysis_mode, - bytecode=contract.creation_code or None, - deployed_bytecode=contract.code or None, - sources=sources or None, - main_source=main_source, - source_list=source_list or None, - ) + try: + resp = c.analyze( + contract_name=contract.name, + analysis_mode=analysis_mode, + bytecode=contract.creation_code or None, + deployed_bytecode=contract.code or None, + sources=sources or None, + main_source=main_source, + source_list=source_list or None, + ) + except MythXAPIError as e: + log.critical(e) while not c.analysis_ready(resp.uuid): log.info(c.status(resp.uuid).analysis)