Skip to content

Commit

Permalink
Merge branch 'v0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Grunny committed Oct 9, 2016
2 parents dd6957d + 4af5ad6 commit d68b89a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Release History
===============

v0.4.0 (2016-10-09)
-------------------
* Add a report command to save a HTML or XML report

v0.3.0 (2016-08-28)
-------------------
* Add a status command to check if ZAP is running (#14)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Daniel Grunwell
Copyright (c) 2015-2016 Daniel Grunwell

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ ZAP CLI can then be used with the following commands:
open-url Open a URL using the ZAP proxy.
policies Enable or list a set of policies.
quick-scan Run a quick scan.
report Generate XML or HTML report.
scanners Enable, disable, or list a set of scanners.
session Manage sessions.
shutdown Shutdown the ZAP daemon.
Expand Down
2 changes: 1 addition & 1 deletion zapcli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
.. moduleauthor:: Daniel Grunwell (grunny)
"""

__version__ = '0.3.0'
__version__ = '0.4.0'
4 changes: 3 additions & 1 deletion zapcli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def exclude_from_scanners(zap_helper, pattern):
zap_helper.exclude_from_all(pattern)


@cli.command('report', short_help='Generate XML or HTML report.')
@cli.command('report')
@click.option('--output', '-o', help='Output file for report.')
@click.option('--output-format', '-f', default='xml', type=click.Choice(['xml', 'html']),
help='Report format.')
Expand All @@ -427,6 +427,8 @@ def report(zap_helper, output, output_format):
else:
zap_helper.xml_report(output)

console.info('Report saved to "{0}"'.format(output))


def report_alerts(alerts, output_format='table'):
"""
Expand Down
12 changes: 7 additions & 5 deletions zapcli/zap_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,19 @@ def load_session(self, file_path):
self.zap.core.load_session(file_path, apikey=self.api_key)

def xml_report(self, file_path):
"""Generate xml report"""
"""Generate and save XML report"""
self.logger.debug('Generating XML report')
report = self.zap.core.xmlreport(apikey=self.api_key)
self.write_report(report, file_path)
self._write_report(report, file_path)

def html_report(self, file_path):
"""Generate html report"""
"""Generate and save HTML report."""
self.logger.debug('Generating HTML report')
report = self.zap.core.htmlreport(apikey=self.api_key)
self.write_report(report, file_path)
self._write_report(report, file_path)

def write_report(self, report, file_path):
@staticmethod
def _write_report(report, file_path):
"""Write report to the given file path."""
with open(file_path, 'w') as f:
f.write(report)

0 comments on commit d68b89a

Please sign in to comment.