diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..1098402 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Shellphish + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/greed/memory/partial_concrete_storage.py b/greed/memory/partial_concrete_storage.py index 572ccb1..c69c697 100644 --- a/greed/memory/partial_concrete_storage.py +++ b/greed/memory/partial_concrete_storage.py @@ -46,8 +46,9 @@ def __init__(self, tag=None, value_sort=None, state=None, partial_init=False): self.state = state # Initialize the web3 connection - self.w3 = web3.Web3(web3.Web3.HTTPProvider(opt.WEB3_PROVIDER)) - assert(self.w3.is_connected()) + self.w3 = state.project.w3 + assert(self.w3 is not None), "Web3 provider not initialized. Cannot use the partial concrete storage" + assert(self.w3.is_connected()), "Web3 connection not connected. Cannot use the partial concrete storage" if "ADDRESS" not in self.state.ctx: raise GreedException("Cannot initialize the PartialConcreteStorage with no contract address") diff --git a/greed/project.py b/greed/project.py index be75bcc..a1d51cc 100644 --- a/greed/project.py +++ b/greed/project.py @@ -1,12 +1,14 @@ import logging import networkx as nx +import web3 from collections import defaultdict from greed.TAC.TAC_parser import TAC_parser from greed.TAC.gigahorse_ops import TAC_Callprivateargs from greed.factory import Factory +from greed import options as opt log = logging.getLogger(__name__) @@ -54,6 +56,14 @@ def __init__(self, target_dir: str): target_function = self.factory.function(target_function_id) self.callgraph.add_edge(source_function, target_function) + # trying to connect to the w3 + try: + self.w3 = web3.Web3(web3.Web3.HTTPProvider(opt.WEB3_PROVIDER)) + if not self.w3.is_connected(): + self.w3 = None + except Exception as e: + self.w3 = None + def dump_callgraph(self, filename): """ Dump the callgraph in a dot file. diff --git a/setup.py b/setup.py index a3b1ba4..b9df49b 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,11 @@ 'solc-select>=0.2.1', 'sympy>=1.9', 'web3>=5.31.1', + 'alive-progress', + 'mkdocs', + 'mkdocs-click', + 'pymdown-extensions', + 'lazydocs' ], python_requires='>=3.8', )