From cfa189657909c2594f4c2dd4722cdf95dca91d31 Mon Sep 17 00:00:00 2001 From: midwestKC-coder <97243819+midwestKC-coder@users.noreply.github.com> Date: Tue, 28 Nov 2023 03:00:19 -0600 Subject: [PATCH] Copy all ZAP logs in `export_session.py` scan hook (#414) Zap rotates log files which results in multiple log files. Updated code to copy all of the log files. Signed-off-by: midwestKC-coder <97243819+midwestKC-coder@users.noreply.github.com> --- other/scan-hooks/export_session.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/other/scan-hooks/export_session.py b/other/scan-hooks/export_session.py index fa62d826..42c6422b 100644 --- a/other/scan-hooks/export_session.py +++ b/other/scan-hooks/export_session.py @@ -4,6 +4,7 @@ from shutil import copy2, copytree import os.path +import glob # This assumes that you are running as zap - if you run as root change to use /root/.ZAP(_D) dev_path = '/home/zap/.ZAP_D' @@ -14,4 +15,5 @@ def pre_exit(fail_count, warn_count, pass_count): if os.path.exists(dev_path + '/session'): dir = dev_path copytree(dir + '/session', '/zap/wrk/session') - copy2(dir + '/zap.log', '/zap/wrk') + for zap_file in glob.iglob(dir + '/zap.log*'): + copy2(zap_file, '/zap/wrk')