コード例 #1
0
 def ruleAdd(self, profile_id, name, category, platform, create_user, rule,
             method):
     with self._lock:
         r = self._db.table('rules').insert({
             'profile_id':
             profile_id,
             'id':
             str(secure_uuid4()),
             'state':
             0,
             'method':
             method,
             'name':
             name,
             'category':
             category,
             'platform':
             platform,
             'create_timestamp':
             datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
             'update_timestamp':
             datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
             'create_user':
             create_user,
             'update_user':
             create_user,
             'log': [],
             'rule':
             rule
         })
         return r
コード例 #2
0
	def taskProfileAdd(self, name, actor, params):
		return self._db_taskprofiles.insert_one({'taskprofile_id' : str(secure_uuid4()), 
													'name': str(name), 
													'actor' : str(actor),
													'params' : params, 
													'create_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow()), 
													'update_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow())})
コード例 #3
0
	def oiocCreate(self, iocname, ioc, username):
		return self._db_openioc.insert_one({'ioc_id' : str(secure_uuid4()), 
													'iocname': str(iocname), 
													'username' : str(username),
													'ioc' : str(ioc), 
													'create_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow()), 
													'update_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow())})		
コード例 #4
0
	def scriptCreate(self, scriptname, script, username):
		return self._db_scripts.insert_one({'script_id' : str(secure_uuid4()), 
													'scriptname': str(scriptname), 
													'username' : str(username),
													'script' : str(script), 
													'create_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow()), 
													'update_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow())})		
コード例 #5
0
	def oiocCreate(self, iocname, ioc, username):
		with self._lock:
			return self._db.table('openioc').insert({'ioc_id' : str(secure_uuid4()), 
														'iocname': str(iocname), 
														'username' : str(username),
														'ioc' : str(ioc), 
														'create_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow()), 
														'update_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow())})		
コード例 #6
0
	def scriptCreate(self, scriptname, script, username):
		with self._lock:
			return self._db.table('scripts').insert({'script_id' : str(secure_uuid4()), 
														'scriptname': str(scriptname), 
														'username' : str(username),
														'script' : str(script), 
														'create_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow()), 
														'update_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow())})		
コード例 #7
0
	def hostGroupAdd(self, profile_id, name, actor, agent_ids = []):
		return self._db_hostgroups.insert_one({'profile_id' : profile_id,
												'hostgroup_id' : str(secure_uuid4()), 
												'name': str(name), 
												'actor' : str(actor),
												'agent_ids' : agent_ids, 
												'create_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow()), 
												'update_timestamp' : HXAPI.dt_to_str(datetime.datetime.utcnow())})
コード例 #8
0
	def auditCreate(self, profile_id, host_id, hostname, generator, start_time, end_time, results):
		return self._db_audits.insert_one({'profile_id' : profile_id,
												'audit_id'	: str(secure_uuid4()),
												'host_id:'	: host_id,
												'hostname'	: hostname,
												'generator'	: generator,
												'start_time': start_time,
												'end_time'	: end_time,
												'results'	: results})
コード例 #9
0
ファイル: hxtool_mongodb.py プロジェクト: moshekaplan/HXTool
 def profileCreate(self, hx_name, hx_host, hx_port):
     # Generate a unique profile id
     profile_id = str(secure_uuid4())
     return self._db_profile.insert_one({
         'profile_id': profile_id,
         'hx_name': hx_name,
         'hx_host': hx_host,
         'hx_port': hx_port
     })
コード例 #10
0
	def profileCreate(self, hx_name, hx_host, hx_port):
		# Generate a unique profile id
		profile_id = str(secure_uuid4())
		r = None
		with self._lock:
			try:
				r = self._db.table('profile').insert({'profile_id' : profile_id, 'hx_name' : hx_name, 'hx_host' : hx_host, 'hx_port' : hx_port})
			except:	
				self._db.table('profile').remove(doc_ids = [r])
				raise
		return r
コード例 #11
0
    def __init__(self,
                 profile_id,
                 name,
                 task_id=None,
                 start_time=None,
                 end_time=None,
                 next_run=None,
                 enabled=True,
                 immutable=False,
                 stop_on_fail=True,
                 parent_id=None,
                 wait_for_parent=True,
                 defer_interval=30):

        self._lock = threading.Lock()
        self.profile_id = profile_id
        self.profile_name = "Unknown"
        self.task_id = task_id or str(secure_uuid4())
        self.parent_id = parent_id
        self.scheduler = None
        self.wait_for_parent = wait_for_parent
        self.parent_complete = False
        self.name = name
        self.enabled = enabled
        self.immutable = immutable
        self.state = None
        self.last_run_state = None
        self.schedule = {}
        self.start_time = start_time or datetime.datetime.utcnow().replace(
            microsecond=1)
        self.end_time = end_time
        self.last_run = None
        if parent_id and wait_for_parent:
            self.next_run = None
        else:
            self.next_run = next_run or self.start_time
        self.stop_on_fail = stop_on_fail
        self.steps = []
        self.stored_result = {}
        self.defer_interval = defer_interval

        self._stored = False
        self._stop_signal = False
        self._defer_signal = False

        profile = hxtool_global.hxtool_db.profileGet(self.profile_id)
        if profile is not None:
            self.profile_name = profile['hx_name']