-
Fawwaz Anugrah Wiradhika Dharmasatya authored67cf12c0
MainMenu.py 2.36 KiB
from lib.utils import format_log
from lib.ACReader import ACReader,ACLData
from lib.FileReader import FileReader
from lib.RouteSanitizationAnalyzer import RouteSanitizationAnalyzer
from lib.ACLAnalyzer import ACLAnalyzer
from lib.VulnerabilitReporter import VulnerabilityReporter
import time
# @ACL(explore_decorator_no_args)
from lib.experiment import explore_decorator_no_args,explore_decorator
# Supaya support up arrow di linux, perlu import readlines
from sys import platform
if platform=='linux':
import readline
def roue():
return True
class MainMenu():
def __init__(self):
self.project_path:str = ""
self.acl_path:str = ""
# @Routes
def start(self):
self.print_header()
# Dapatkan Path Menuju File dan Konfigurasi ACL
is_correct:bool = False
while not is_correct:
self.project_path = input("Enter the path to the project: ")
self.acl_path = input("Enter the path to the ACL file: ")
is_correct = input("Is this correct? (y/n): ").lower() == "y"
# Mulai analisis
format_log("Starting Analysis...")
start_time = time.time()
# Baca file ACL
try:
self.acl_data = ACReader(self.acl_path).read()
format_log("ACL data acquired.")
self.project_ctx = FileReader(self.project_path).analyze_project()
format_log("ACL and routes context gathered...")
except FileNotFoundError:
format_log("File not found. Exiting...",status='error')
else:
# Inisialisasi Reporter
reporter = VulnerabilityReporter(self.acl_data)
# Analisis sanitasi router
format_log("Starting route sanitization analysis...")
reporter.add_unsanitized_routes(RouteSanitizationAnalyzer().set_project(self.project_ctx).analyze())
# Analisis kontrol akses
format_log("Starting access control analysis...")
reporter.add_acl_data(ACLAnalyzer(self.project_ctx,self.acl_data).analyze())
# Tampilkan hasil analisis
print("=====================ANALYSIS RESULT=====================")
reporter.get_unsanitized_element_report()
reporter.get_acl_table()
finally:
format_log(f"Analysis finished in {time.time()-start_time} seconds.",end="\n\n")
# @Routes
@explore_decorator_no_args
# @explore_decorator
def print_header(self):
print("Welcome to SCA Tool")
print("V.1.0")