Skip to content

Commit

Permalink
🔨 fallback to Foundry remappings
Browse files Browse the repository at this point in the history
  • Loading branch information
GianfrancoBazzani authored Apr 3, 2024
1 parent ba33ab9 commit 01a2ac1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fuzz_utils/utils/remappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@ def find_remappings(include_attacks: bool) -> dict:
properties = r"(\S+)=lib\/properties\/(?!\S*lib\/)(\S*)"
remappings: str = ""

remappings = ""

if os.path.exists("remappings.txt"):
with open("remappings.txt", "r", encoding="utf-8") as file:
remappings = file.read()
else:
output = subprocess.run(["forge", "remappings"], capture_output=True, text=True, check=True)
remappings = str(output.stdout)

output = subprocess.run(["forge", "remappings"], capture_output=True, text=True, check=True)
forge_remappings = str(output.stdout)

oz_matches = re.findall(openzeppelin, remappings)
if len(oz_matches) == 0:
oz_matches = re.findall(openzeppelin, forge_remappings)
sol_matches = re.findall(solmate, remappings)
if len(sol_matches) == 0:
sol_matches = re.findall(solmate, forge_remappings)
prop_matches = re.findall(properties, remappings)
if len(prop_matches) == 0:
prop_matches = re.findall(properties, forge_remappings)

if include_attacks and len(oz_matches) == 0 and len(sol_matches) == 0:
handle_exit(
Expand Down

0 comments on commit 01a2ac1

Please sign in to comment.