a boolean flag is added if a policy is executed

This commit is contained in:
Hasan Kara 2020-07-16 13:02:47 +03:00
parent 73ece8417d
commit bd890f2ce1

View file

@ -221,6 +221,7 @@ class ExecutionManager(object):
def execute_policy(self, arg): def execute_policy(self, arg):
try: try:
j = json.loads(str(arg)) j = json.loads(str(arg))
self.policy_executed[j['username']] = True
for i in range(len(j['executePolicyList'])): for i in range(len(j['executePolicyList'])):
policy = self.json_to_PolicyBean(json.loads(json.dumps(j['executePolicyList'][i]))) policy = self.json_to_PolicyBean(json.loads(json.dumps(j['executePolicyList'][i])))
self.logger.debug('Updating policies...') self.logger.debug('Updating policies...')
@ -240,7 +241,6 @@ class ExecutionManager(object):
self.db_service.delete('policy', 'type = \'U\' and name = \'' + policy.get_username() + '\'' + self.db_service.delete('policy', 'type = \'U\' and name = \'' + policy.get_username() + '\'' +
'and policy_id = ' + str(policy.get_policy_id())) 'and policy_id = ' + str(policy.get_policy_id()))
else: else:
self.policy_executed[policy.get_username()] = True
machine_uid = self.db_service.select_one_result('registration', 'jid', 'registered=1') machine_uid = self.db_service.select_one_result('registration', 'jid', 'registered=1')
user_policy_version = self.db_service.select_one_result('policy', 'version', user_policy_version = self.db_service.select_one_result('policy', 'version',
'type = \'U\' and name = \'' + policy.get_username() + '\'' + 'type = \'U\' and name = \'' + policy.get_username() + '\'' +