Skip to content

Commit

Permalink
Added CLI option for (optional) outputting content to file
Browse files Browse the repository at this point in the history
  • Loading branch information
hvqzao committed May 9, 2017
1 parent 7602717 commit 43d89b8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
12 changes: 10 additions & 2 deletions src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def is_yaml (filename):
kb_file = value('-k')
scan_files = values('-s')
report_file = value('-r')
output_content_file = value('-o')

if template_file and report_file:
report = Report()
Expand All @@ -76,14 +77,21 @@ def is_yaml (filename):
report.kb_load_yaml(kb_file)
else:
report.kb_load_json(kb_file)
if output_content_file:
json_ext = '.json'
with open(output_content_file, 'w') as h:
if output_content_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'))
report.xml_apply_meta()
report.save_report_xml(report_file)
print 'Report saved.'
else:
print 'Usage: '
print
print ' ' + self.title + '.exe -t template-file [-c content-file] [-k kb-file] [[-s scan-file] ...] -r report-file'
print ' generate report'
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
print ' ' + self.title + '.exe [--help]'
print ' display usage and exit'
Expand Down
11 changes: 5 additions & 6 deletions src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,12 +693,11 @@ def Save_Content_As(self, e):
json_ext = '.json'
filename = openFileDialog.GetPath()
self.status('Saving Content...')
h = open(filename, 'w')
if filename[-len(json_ext):] == json_ext:
h.write(self.report.content_dump_json().encode('utf-8'))
else:
h.write(self.report.content_dump_yaml().encode('utf-8'))
h.close()
with open(filename, 'w') as h:
if filename[-len(json_ext):] == json_ext:
h.write(self.report.content_dump_json().encode('utf-8'))
else:
h.write(self.report.content_dump_yaml().encode('utf-8'))
self.status('Content saved')

def Save_Scan_As(self, e):
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.7'
date = 'Wed Apr 5 08:19:48 2017'
version = '0.9.8'
date = 'Tue May 9 10:21:47 2017'
changelog = '''
0.9.8 - Tue May 9 10:21:47 2017
- Added CLI option for (optional) outputting content to file (yaml / json)
0.9.7 - Tue May 9 09:35:48 2017
- Added default sections for Burp / WebInspect imports (standarization)
Expand Down

0 comments on commit 43d89b8

Please sign in to comment.