From b275bcc824b1b932310cf03b6bfb1a1fef0ebae1 Mon Sep 17 00:00:00 2001 From: Josselin Date: Thu, 13 Jun 2019 11:27:37 +0200 Subject: [PATCH] Add demo utility --- utils/demo/README.md | 6 ++++++ utils/demo/__init__.py | 0 utils/demo/__main__.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 utils/demo/README.md create mode 100644 utils/demo/__init__.py create mode 100644 utils/demo/__main__.py diff --git a/utils/demo/README.md b/utils/demo/README.md new file mode 100644 index 000000000..00bdec0b4 --- /dev/null +++ b/utils/demo/README.md @@ -0,0 +1,6 @@ +## Demo + +This directory contains an example of Slither utility. + +See the [utility documentation](https://github.com/crytic/slither/wiki/Adding-a-new-utility) + diff --git a/utils/demo/__init__.py b/utils/demo/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/utils/demo/__main__.py b/utils/demo/__main__.py new file mode 100644 index 000000000..4bee3b449 --- /dev/null +++ b/utils/demo/__main__.py @@ -0,0 +1,38 @@ +import os +import argparse +import logging +from slither import Slither +from crytic_compile import cryticparser + +logging.basicConfig() +logging.getLogger("Slither").setLevel(logging.INFO) + +logger = logging.getLogger("Slither-demo") + +def parse_args(): + """ + Parse the underlying arguments for the program. + :return: Returns the arguments for the program. + """ + parser = argparse.ArgumentParser(description='Demo', + usage='slither-demo filename') + + parser.add_argument('filename', + help='The filename of the contract or truffle directory to analyze.') + + # Add default arguments from crytic-compile + cryticparser.init(parser) + + return parser.parse_args() + + +def main(): + args = parse_args() + + # Perform slither analysis on the given filename + slither = Slither(args.filename, **vars(args)) + + logger.info('Analysis done!') + +if __name__ == '__main__': + main()