Package modules :: Package processing :: Module analysisinfo
[hide private]
[frames] | no frames]

Source Code for Module modules.processing.analysisinfo

 1  # Copyright (C) 2010-2014 Cuckoo Sandbox Developers. 
 2  # This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org 
 3  # See the file 'docs/LICENSE' for copying permission. 
 4   
 5  import time 
 6  import logging 
 7  from datetime import datetime 
 8   
 9  from lib.cuckoo.common.abstracts import Processing 
10  from lib.cuckoo.common.constants import CUCKOO_VERSION 
11   
12  log = logging.getLogger(__name__) 
13   
14   
15 -class AnalysisInfo(Processing):
16 """General information about analysis session.""" 17
18 - def run(self):
19 """Run information gathering. 20 @return: information dict. 21 """ 22 self.key = "info" 23 24 try: 25 started = time.strptime(self.task["started_on"], 26 "%Y-%m-%d %H:%M:%S") 27 started = datetime.fromtimestamp(time.mktime(started)) 28 29 ended = time.strptime(self.task["completed_on"], 30 "%Y-%m-%d %H:%M:%S") 31 ended = datetime.fromtimestamp(time.mktime(ended)) 32 except: 33 log.critical("Failed to get start/end time from Task.") 34 # just set it to default timeout 35 duration = -1 36 else: 37 duration = (ended - started).seconds 38 39 info = { 40 "version": CUCKOO_VERSION, 41 "started": self.task["started_on"], 42 "ended": self.task.get("completed_on", "none"), 43 "duration": duration, 44 "id": int(self.task["id"]), 45 "category": self.task["category"], 46 "custom": self.task["custom"] 47 } 48 49 return info
50