From 372bc9e6a673a5582363fc4332bc729a20dca56c Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 22 Jul 2018 07:05:22 -0400 Subject: [PATCH 1/2] Add -V and --version myth CLI option --- mythril/interfaces/cli.py | 9 ++++++++- mythril/version.py | 3 +++ setup.py | 9 +++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 mythril/version.py diff --git a/mythril/interfaces/cli.py b/mythril/interfaces/cli.py index b9a910e0..efda3b53 100644 --- a/mythril/interfaces/cli.py +++ b/mythril/interfaces/cli.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# -*- coding: UTF-8 -*- +# -*- coding: utf-8 -*- """mythril.py: Bug hunting on the Ethereum blockchain http://www.github.com/ConsenSys/mythril @@ -14,6 +14,7 @@ import argparse from mythril.exceptions import CriticalError from mythril.mythril import Mythril +from mythril.version import VERSION def exit_with_error(format, message): @@ -31,6 +32,8 @@ def main(): commands = parser.add_argument_group('commands') commands.add_argument('-g', '--graph', help='generate a control flow graph') + commands.add_argument('-V', '--version', action='store_true', + help='print the Mythril version number and exit') commands.add_argument('-x', '--fire-lasers', action='store_true', help='detect vulnerabilities, use with -c, -a or solidity file(s)') commands.add_argument('-t', '--truffle', action='store_true', @@ -84,6 +87,10 @@ def main(): args = parser.parse_args() + if args.version: + print("Mythril version {}".format(VERSION)) + sys.exit() + # -- args sanity checks -- # Detect unsupported combinations of command line args diff --git a/mythril/version.py b/mythril/version.py new file mode 100644 index 00000000..c0d1b140 --- /dev/null +++ b/mythril/version.py @@ -0,0 +1,3 @@ +# This file is suitable for sourcing inside POSIX shell, e.g. bash as +# well as for importing into Python +VERSION = "v0.18.9" diff --git a/setup.py b/setup.py index ec606d3e..dd8d79ec 100755 --- a/setup.py +++ b/setup.py @@ -1,13 +1,18 @@ from setuptools import setup, find_packages from setuptools.command.install import install +from pathlib import Path import sys import os +# To make lint checkers happy we set VERSION here, but +# it is redefined by the exec below +VERSION = None + # Package version (vX.Y.Z). It must match git tag being used for CircleCI # deployment; otherwise the build will failed. -VERSION = "v0.18.9" - +version_path = (Path(__file__).parent / 'mythril' / 'version.py').absolute() +exec(open(version_path, 'r').read()) class VerifyVersionCommand(install): """Custom command to verify that the git tag matches our version""" From 203edcf1ff25556f04db37dfb8c0734f2e5358f8 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 22 Jul 2018 07:10:39 -0400 Subject: [PATCH 2/2] Make code dual Python/POSIX --- mythril/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mythril/version.py b/mythril/version.py index c0d1b140..e606aa4c 100644 --- a/mythril/version.py +++ b/mythril/version.py @@ -1,3 +1,3 @@ # This file is suitable for sourcing inside POSIX shell, e.g. bash as # well as for importing into Python -VERSION = "v0.18.9" +VERSION="v0.18.9" # NOQA