Skip to content

Commit

Permalink
Added CLI option to convert scan xml to yaml or json
Browse files Browse the repository at this point in the history
  • Loading branch information
hvqzao committed May 10, 2017
1 parent 43d89b8 commit 452c75b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
26 changes: 21 additions & 5 deletions src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def is_yaml (filename):
kb_file = value('-k')
scan_files = values('-s')
report_file = value('-r')
output_content_file = value('-o')
output_file = value('-o')

if template_file and report_file:
report = Report()
Expand All @@ -77,21 +77,37 @@ def is_yaml (filename):
report.kb_load_yaml(kb_file)
else:
report.kb_load_json(kb_file)
if output_content_file:
if output_file:
json_ext = '.json'
with open(output_content_file, 'w') as h:
if output_content_file[-len(json_ext):] == json_ext:
with open(output_file, 'w') as h:
if output_file[-len(json_ext):] == json_ext:
h.write(report.content_dump_json().encode('utf-8'))
else:
h.write(report.content_dump_yaml().encode('utf-8'))
print 'Output content file saved.'
report.xml_apply_meta()
report.save_report_xml(report_file)
print 'Report saved.'
elif scan_files and output_file:
if len(scan_files) > 1:
print 'Only single scan-file can be provided!'
else:
scan = Scan(scan_files[0])
json_ext = '.json'
with open(output_file, 'w') as h:
if output_file[-len(json_ext):] == json_ext:
h.write(scan.dump_json().encode('utf-8'))
else:
h.write(scan.dump_yaml().encode('utf-8'))
print 'Output scan file saved.'
else:
print 'Usage: '
print
print ' ' + self.title + '.exe -t template-file [-c content-file] [-k kb-file] [[-s scan-file] ...] -r output-report-file [-o output-content-file]'
print ' generate report (and optionally - content yaml)'
print ' generate report (and optionally - content as yaml / json)'
print
print ' ' + self.title + '.exe -s scan-file -o output-scan-file'
print ' convert scan xml to yaml or json format (derived from output file extension)'
print
print ' ' + self.title + '.exe [--help]'
print ' display usage and exit'
Expand Down
7 changes: 5 additions & 2 deletions src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ class Version(object):
Generate reports based on HP WebInspect, BurpSuite Pro scans,
own custom data, knowledge base and Microsoft Office Word templates.
'''
version = '0.9.8'
date = 'Tue May 9 10:21:47 2017'
version = '0.9.9'
date = 'Wed May 10 09:42:18 2017'
changelog = '''
0.9.9 - Wed May 10 09:42:18 2017
- Added CLI option for converting scan xml file to yaml or json
0.9.8 - Tue May 9 10:21:47 2017
- Added CLI option for (optional) outputting content to file (yaml / json)
Expand Down

0 comments on commit 452c75b

Please sign in to comment.