Package modules :: Package reporting :: Module jsondump
[hide private]
[frames] | no frames]

Source Code for Module modules.reporting.jsondump

 1  # Copyright (C) 2010-2014 Cuckoo Foundation. 
 2  # This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org 
 3  # See the file 'docs/LICENSE' for copying permission. 
 4   
 5  import os 
 6  import json 
 7  import codecs 
 8   
 9  from lib.cuckoo.common.abstracts import Report 
10  from lib.cuckoo.common.exceptions import CuckooReportError 
11   
12 -class JsonDump(Report):
13 """Saves analysis results in JSON format.""" 14
15 - def run(self, results):
16 """Writes report. 17 @param results: Cuckoo results dict. 18 @raise CuckooReportError: if fails to write report. 19 """ 20 try: 21 path = os.path.join(self.reports_path, "report.json") 22 report = codecs.open(path, "w", "utf-8") 23 json.dump(results, report, sort_keys=False, indent=4) 24 report.close() 25 except (UnicodeError, TypeError, IOError) as e: 26 raise CuckooReportError("Failed to generate JSON report: %s" % e)
27