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

Source Code for Module modules.reporting.hpfclient

 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 json 
 6   
 7  from lib.cuckoo.common.abstracts import Report 
 8  from lib.cuckoo.common.exceptions import CuckooDependencyError 
 9  from lib.cuckoo.common.exceptions import CuckooReportError 
10   
11  try: 
12          import lib.hpfeeds as hpfeeds 
13  except: 
14          raise CuckooDependencyError("Unable to import HPFeeds library") 
15   
16 -class HPFClient(Report):
17 """Publishes the results on an HPFeeds broker channel.""" 18
19 - def run(self, results):
20 """Sends JSON report to HPFeeds channel. 21 @param results: Cuckoo results dict. 22 @raise CuckooReportError: if fails to write report. 23 """ 24 try: 25 hpc = hpfeeds.HPC(self.options["host"], self.options["port"], self.options["ident"], self.options["secret"], timeout=60) 26 hpc.publish(self.options["channel"], json.dumps(results, sort_keys=False, indent=4)) 27 hpc.close() 28 except hpfeeds.FeedException as e: 29 raise CuckooReportError("Failed to publish on HPFeeds channel: %s" % e)
30