Skip to content

Commit

Permalink
feat: Updated scanners/zap_scanner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Oct 30, 2023
1 parent 5a379da commit 0ffce44
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scanners/zap_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class ZapScanner(Scanner):
def __init__(self):
self.zap = ZAPv2(apikey=API_KEY)
self.storage_service = StorageService()
self.scan_status = None
self.scan_results = None

def start(self, scan_name, target):
print(f'[{self.name}] Starting Scan for Target: {target}')
Expand Down Expand Up @@ -63,6 +65,11 @@ def resume(self, scan_name):

# self.storage_service.update_by_name(scan_name, { status: 'RESUMED' })
return scan
def get_scan_status(self):
return self.scan_status

def get_scan_results(self):
return self.scan_results

def stop(self, scan_name):
if not self.is_valid_scan(scan_name):
Expand Down Expand Up @@ -104,6 +111,8 @@ def scan(self, scan_name, target):
# a_scan_id = self.zap.ascan.scan(target, recurse=True, inscopeonly=None, scanpolicyname=None, method=None, postdata=True)

scan_data = self.storage_service.get_by_name(scan_name)
self.scan_results = scan_data
self.scan_status = 'INPROGRESS'

if not scan_data:
scan_data = {
Expand Down Expand Up @@ -143,6 +152,7 @@ def get_scan_status(self, scan_name, scan_status_list=[]):
spider_scan_status = self.zap.spider.status(zap_id)
passive_scan_records_pending = self.zap.pscan.records_to_scan
active_scan_status = self.zap.ascan.status(zap_id)
self.scan_status = 'INPROGRESS' if int(spider_scan_status) < 100 or int(active_scan_status) < 100 else 'COMPLETE'

scan_status['spider_scan'] = self._parse_status(spider_scan_status)
scan_status['active_scan'] = self._parse_status(active_scan_status)
Expand Down

0 comments on commit 0ffce44

Please sign in to comment.