From e4cfc2712b997c92f7532a982325e586521d4648 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 8 Oct 2024 15:34:49 +1000 Subject: [PATCH] Add error handling for when zap is not installed --- scanners/zap/zap_none.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scanners/zap/zap_none.py b/scanners/zap/zap_none.py index bb17110..a5fca9e 100644 --- a/scanners/zap/zap_none.py +++ b/scanners/zap/zap_none.py @@ -2,7 +2,9 @@ import os import platform import pprint +import shutil import subprocess +import sys from shutil import disk_usage from .zap import MODULE_DIR @@ -277,7 +279,12 @@ def _check_plugin_status(self): """ logging.info("Zap: verifying the viability of ZAP") - command = [self.my_conf("container.parameters.executable")] + cmd = self.my_conf("container.parameters.executable") + if shutil.which(cmd) is None: + logging.error(f"{cmd} not found in PATH, is ZAP installed?") + sys.exit(1) + + command = [cmd] command.extend(self._get_standard_options()) command.extend(["-dir", self.container_home_dir]) command.append("-cmd")