allow checking contract source against known OZ source hashes

pull/1134/head
Alexander Remie 3 years ago
parent 5fd5d4f6ce
commit 666e8136c3
  1. 1571
      slither/utils/oz_hashes.py
  2. 12
      slither/utils/standard_libraries.py

File diff suppressed because it is too large Load Diff

@ -1,5 +1,7 @@
from pathlib import Path
from typing import Optional, TYPE_CHECKING
from hashlib import sha1
from slither.utils.oz_hashes import oz_hashes
if TYPE_CHECKING:
from slither.core.declarations import Contract
@ -65,6 +67,16 @@ def is_openzepellin(contract: "Contract") -> bool:
return is_zep
def is_openzepellin_strict(contract: "Contract") -> bool:
start = contract.source_mapping['start']
end = start + contract.source_mapping['length']
# we need a way to get the source code, from a Contract
# source_code = slither.source_code[contract.source_mapping['filename_absolute']][start:end]
# source_hash = sha1(source_code.encode('utf-8')).hexdigest()
# return source_hash in oz_hashes
def is_zos(contract: "Contract") -> bool:
if not contract.is_from_dependency():
return False

Loading…
Cancel
Save