Skip to content

Commit

Permalink
Merge pull request zaproxy#5848 from camswords/develop
Browse files Browse the repository at this point in the history
Update Python docker scripts to be Python 3 compatible
  • Loading branch information
kingthorin authored Feb 7, 2020
2 parents c37a8e9 + 867728a commit 962a209
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 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.

### 2020-02-07
- Change zap-full-scan.py and zap-api-scan.py to be Python3 compatible

### 2020-01-22
- Change `live`, `stable`, and `weekly` images to set the locale and lang to `C.UTF-8`,
to improve interoperability with Python 3 (e.g. `zap-cli`).
Expand Down
10 changes: 5 additions & 5 deletions docker/zap-api-scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def main(argv):
f.write('# Active scan rules set to IGNORE will not be run which will speed up the scan\n')
f.write('# Only the rule identifiers are used - the names are just for info\n')
f.write('# You can add your own messages to each rule by appending them after a tab on each line.\n')
for key, rule in sorted(all_dict.iteritems()):
for key, rule in sorted(all_dict.items()):
f.write(key + '\tWARN\t(' + rule + ')\n')

# print out the passing rules
Expand All @@ -467,17 +467,17 @@ def main(argv):
plugin_id = rule.get('id')
if plugin_id in blacklist:
continue
if (not alert_dict.has_key(plugin_id)):
if plugin_id not in alert_dict:
pass_dict[plugin_id] = rule.get('name')
for rule in all_ascan_rules:
plugin_id = rule.get('id')
if plugin_id in blacklist:
continue
if not alert_dict.has_key(plugin_id) and not(config_dict.has_key(plugin_id) and config_dict[plugin_id] == 'IGNORE'):
if plugin_id not in alert_dict and not(plugin_id in config_dict and config_dict[plugin_id] == 'IGNORE'):
pass_dict[plugin_id] = rule.get('name')

if min_level == zap_conf_lvls.index("PASS") and detailed_output:
for key, rule in sorted(pass_dict.iteritems()):
for key, rule in sorted(pass_dict.items()):
print('PASS: ' + rule + ' [' + key + ']')

pass_count = len(pass_dict)
Expand All @@ -488,7 +488,7 @@ def main(argv):
plugin_id = rule.get('id')
if plugin_id in blacklist:
continue
if config_dict.has_key(plugin_id) and config_dict[plugin_id] == 'IGNORE':
if plugin_id in config_dict and config_dict[plugin_id] == 'IGNORE':
print('SKIP: ' + rule.get('name') + ' [' + plugin_id + ']')

# print out the ignored rules
Expand Down
10 changes: 5 additions & 5 deletions docker/zap-full-scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def main(argv):
f.write('# Active scan rules set to IGNORE will not be run which will speed up the scan\n')
f.write('# Only the rule identifiers are used - the names are just for info\n')
f.write('# You can add your own messages to each rule by appending them after a tab on each line.\n')
for key, rule in sorted(all_dict.iteritems()):
for key, rule in sorted(all_dict.items()):
f.write(key + '\tWARN\t(' + rule + ')\n')

# print out the passing rules
Expand All @@ -395,17 +395,17 @@ def main(argv):
plugin_id = rule.get('id')
if plugin_id in blacklist:
continue
if (not alert_dict.has_key(plugin_id)):
if plugin_id not in alert_dict:
pass_dict[plugin_id] = rule.get('name')
for rule in all_ascan_rules:
plugin_id = rule.get('id')
if plugin_id in blacklist:
continue
if not alert_dict.has_key(plugin_id) and not(config_dict.has_key(plugin_id) and config_dict[plugin_id] == 'IGNORE'):
if plugin_id not in alert_dict and not(plugin_id in config_dict and config_dict[plugin_id] == 'IGNORE'):
pass_dict[plugin_id] = rule.get('name')

if min_level == zap_conf_lvls.index("PASS") and detailed_output:
for key, rule in sorted(pass_dict.iteritems()):
for key, rule in sorted(pass_dict.items()):
print('PASS: ' + rule + ' [' + key + ']')

pass_count = len(pass_dict)
Expand All @@ -416,7 +416,7 @@ def main(argv):
plugin_id = rule.get('id')
if plugin_id in blacklist:
continue
if config_dict.has_key(plugin_id) and config_dict[plugin_id] == 'IGNORE':
if plugin_id in config_dict and config_dict[plugin_id] == 'IGNORE':
print('SKIP: ' + rule.get('name') + ' [' + plugin_id + ']')

# print out the ignored rules
Expand Down
4 changes: 0 additions & 4 deletions docker/zap_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,6 @@ def get_latest_zap_client_version():
logging.warning('Error fetching latest ZAP Python API client version: %s' % e)
return None

if version_info is None:
logging.warning('Error fetching latest ZAP Python API client version: %s' % e)
return None

version_json = json.loads(version_info.read().decode('utf-8'))

if 'info' not in version_json:
Expand Down

0 comments on commit 962a209

Please sign in to comment.