Skip to content

Commit

Permalink
Merge pull request zaproxy#7852 from psiinon/docker/silent
Browse files Browse the repository at this point in the history
Don't install/update add-ons if '-silent' option specified
  • Loading branch information
thc202 authored May 5, 2023
2 parents 37ac081 + 5287b1f commit 7259b47
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 44 deletions.
3 changes: 3 additions & 0 deletions docker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to the docker containers will be documented in this file.

### 2023-05-05
- Do not install/update add-ons if ZAP '-silent' option specified (Issue 4633).

### 2023-02-03
- Alert_on_Unexpected_Content_Types.js > Added Content-Type application/hal+json to the list of expected types.

Expand Down
27 changes: 18 additions & 9 deletions docker/zap-api-scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ def main(argv):
usage()
sys.exit(3)

if "-silent" in zap_options and zap_alpha:
logging.warning('You cannot use the \'-a\' option with the ZAP \'-silent\' option')
sys.exit(3)

if running_in_docker():
base_dir = '/zap/wrk/'
if config_file or generate or report_html or report_xml or report_json or report_md or progress_file or context_file:
Expand Down Expand Up @@ -329,13 +333,15 @@ def main(argv):

if running_in_docker():
try:
params = [
'-addonupdate',
'-addoninstall', 'pscanrulesBeta'] # In case we're running in the stable container
params = []

if zap_alpha:
params.append('-addoninstall')
params.append('pscanrulesAlpha')
if "-silent" not in zap_options:
params.append('-addonupdate')
# In case we're running in the stable container
params.extend(['-addoninstall', 'pscanrulesBeta'])

if zap_alpha:
params.extend(['-addoninstall', 'pscanrulesAlpha'])

add_zap_options(params, zap_options)

Expand All @@ -351,10 +357,13 @@ def main(argv):
if context_file:
mount_dir = os.path.dirname(os.path.abspath(context_file))

params = ['-addonupdate']
params = []

if "-silent" not in zap_options:
params.append('-addonupdate')

if (zap_alpha):
params.extend(['-addoninstall', 'pscanrulesAlpha'])
if (zap_alpha):
params.extend(['-addoninstall', 'pscanrulesAlpha'])

add_zap_options(params, zap_options)

Expand Down
43 changes: 25 additions & 18 deletions docker/zap-baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ def main(argv):
usage()
sys.exit(3)

if "-silent" in zap_options and zap_alpha:
logging.warning('You cannot use the \'-a\' option with the ZAP \'-silent\' option')
sys.exit(3)

if running_in_docker():
base_dir = '/zap/wrk/'
if config_file or generate or report_html or report_xml or report_json or report_md or progress_file or context_file:
Expand Down Expand Up @@ -402,13 +406,13 @@ def main(argv):
logging.warning('Unable to copy yaml file to ' + yaml_copy_file + ' ' + str(err))

try:
# Run ZAP inline to update the add-ons
install_opts = ['-addonupdate', '-addoninstall', 'pscanrulesBeta']
if zap_alpha:
install_opts.append('-addoninstall')
install_opts.append('pscanrulesAlpha')
if "-silent" not in zap_options:
# Run ZAP inline to update the add-ons
install_opts = ['-addonupdate', '-addoninstall', 'pscanrulesBeta']
if zap_alpha:
install_opts.extend(['-addoninstall', 'pscanrulesAlpha'])

run_zap_inline(port, install_opts)
run_zap_inline(port, install_opts)

# Run ZAP inline with the yaml file
params = ['-autorun', yaml_file]
Expand Down Expand Up @@ -453,14 +457,15 @@ def main(argv):

else:
try:
params = [
'-config', 'spider.maxDuration=' + str(mins),
'-addonupdate',
'-addoninstall', 'pscanrulesBeta'] # In case we're running in the stable container
params = ['-config', 'spider.maxDuration=' + str(mins)]

if "-silent" not in zap_options:
params.append('-addonupdate')
# In case we're running in the stable container
params.extend(['-addoninstall', 'pscanrulesBeta'])

if zap_alpha:
params.append('-addoninstall')
params.append('pscanrulesAlpha')
if zap_alpha:
params.extend(['-addoninstall', 'pscanrulesAlpha'])

add_zap_options(params, zap_options)

Expand All @@ -476,12 +481,14 @@ def main(argv):
if context_file:
mount_dir = os.path.dirname(os.path.abspath(context_file))

params = [
'-config', 'spider.maxDuration=' + str(mins),
'-addonupdate']

if (zap_alpha):
params.extend(['-addoninstall', 'pscanrulesAlpha'])
params = ['-config', 'spider.maxDuration=' + str(mins)]

if "-silent" not in zap_options:
params.append('-addonupdate')

if (zap_alpha):
params.extend(['-addoninstall', 'pscanrulesAlpha'])

add_zap_options(params, zap_options)

Expand Down
42 changes: 25 additions & 17 deletions docker/zap-full-scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ def main(argv):
usage()
sys.exit(3)

if "-silent" in zap_options and zap_alpha:
logging.warning('You cannot use the \'-a\' option with the ZAP \'-silent\' option')
sys.exit(3)

if running_in_docker():
base_dir = '/zap/wrk/'
if config_file or generate or report_html or report_xml or report_json or report_md or progress_file or context_file:
Expand Down Expand Up @@ -277,15 +281,17 @@ def main(argv):

if running_in_docker():
try:
params = [
'-config', 'spider.maxDuration=' + str(mins),
'-addonupdate',
'-addoninstall', 'pscanrulesBeta', # In case we're running in the stable container
'-addoninstall', 'ascanrulesBeta']

if zap_alpha:
params.extend(['-addoninstall', 'pscanrulesAlpha'])
params.extend(['-addoninstall', 'ascanrulesAlpha'])
params = ['-config', 'spider.maxDuration=' + str(mins)]

if "-silent" not in zap_options:
params.append('-addonupdate')
# In case we're running in the stable container
params.extend(['-addoninstall', 'pscanrulesBeta'])
params.extend(['-addoninstall', 'ascanrulesBeta'])

if zap_alpha:
params.extend(['-addoninstall', 'pscanrulesAlpha'])
params.extend(['-addoninstall', 'ascanrulesAlpha'])

add_zap_options(params, zap_options)

Expand All @@ -301,15 +307,17 @@ def main(argv):
if context_file:
mount_dir = os.path.dirname(os.path.abspath(context_file))

params = [
'-config', 'spider.maxDuration=' + str(mins),
'-addonupdate',
'-addoninstall', 'pscanrulesBeta', # In case we're running in the stable container
'-addoninstall', 'ascanrulesBeta']
params = ['-config', 'spider.maxDuration=' + str(mins)]

if "-silent" not in zap_options:
params.append('-addonupdate')
# In case we're running in the stable container
params.extend(['-addoninstall', 'pscanrulesBeta'])
params.extend(['-addoninstall', 'ascanrulesBeta'])

if (zap_alpha):
params.extend(['-addoninstall', 'pscanrulesAlpha'])
params.extend(['-addoninstall', 'ascanrulesAlpha'])
if (zap_alpha):
params.extend(['-addoninstall', 'pscanrulesAlpha'])
params.extend(['-addoninstall', 'ascanrulesAlpha'])

add_zap_options(params, zap_options)

Expand Down

0 comments on commit 7259b47

Please sign in to comment.