Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2014-2016 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 import datetime 7 import calendar 8 9 try: 10 import requests 11 HAVE_REQUESTS = True 12 except ImportError: 13 HAVE_REQUESTS = False 14 15 from lib.cuckoo.common.abstracts import Report 16 from lib.cuckoo.common.exceptions import CuckooReportError 17 from lib.cuckoo.common.exceptions import CuckooOperationalError 1820 if isinstance(obj, datetime.datetime): 21 if obj.utcoffset() is not None: 22 obj = obj - obj.utcoffset() 23 return calendar.timegm(obj.timetuple()) + obj.microsecond / 1000000.0 24 raise TypeError("%r is not JSON serializable" % obj)2527 """Notifies external service about finished analysis via URL.""" 284930 if not HAVE_REQUESTS: 31 raise CuckooOperationalError( 32 "The Notification reporting module requires the requests " 33 "library (install with `pip install requests`)" 34 ) 35 36 post = { 37 "identifier": self.options.get("identifier"), 38 "data": json.dumps( 39 results.get("info"), default=default, sort_keys=False 40 ) 41 } 42 43 try: 44 requests.post(self.options.get("url"), data=post) 45 except Exception as e: 46 raise CuckooReportError( 47 "Failed posting message via Notification: %s" % e 48 )
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Nov 4 23:22:01 2016 | http://epydoc.sourceforge.net |