-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_script.py
More file actions
38 lines (29 loc) · 1.55 KB
/
fix_script.py
File metadata and controls
38 lines (29 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
"""
Script to fix syntax errors in scan_executor.py and helpers.py files
"""
import os
import re
# Fix scan_executor.py
print("Fixing scan_executor.py...")
with open("backend/core/scan_executor.py", "r") as file:
content = file.read()
# Fix 1: Fix indentation error on line 190
content = re.sub(r'logger\.info\(f"Executing \{tool\.get\(\'name\'\)\} on \{target\}"\)\s+\n\s+tool_id = tool\.get\(\'id\', \'unknown\'\)\s+\n\s+start_time',
'logger.info(f"Executing {tool.get(\'name\')} on {target}")\n \n tool_id = tool.get(\'id\', \'unknown\')\n start_time',
content)
# Write fixed content back to file
with open("backend/core/scan_executor.py", "w") as file:
file.write(content)
# Fix helpers.py
print("Fixing helpers.py...")
with open("backend/utils/helpers.py", "r") as file:
content = file.read()
# Fix 2: Fix f-string backslash issue by converting it to regular string concatenation
content = re.sub(r'return code\.replace\(\s+f"function \{function_match\.group\(1\)\}",\s+f"function \{function_match\.group\(1\)\}\\n\s+\{\\n\s+require\(msg\.sender == owner, \\"Not authorized\\"',
'return code.replace(\n f"function {function_match.group(1)}",\n "function " + function_match.group(1) + "\\n {\\n require(msg.sender == owner, \\"Not authorized\\""',
content)
# Write fixed content back to file
with open("backend/utils/helpers.py", "w") as file:
file.write(content)
print("Fixes applied successfully!")