def count_objects_in_vault(vaultid): nr = 0 cursor.execute("select status from ss_objects where groupid = {}".format(vaultid)) res = cursor.fetchall() for row in res: if s_db_objects.obj_status(row[0]).is_active(): nr += 1 return nr
def get_active_objects_in_vault(vaultid): query = "select id, objectname, status from ss_objects where groupid = {}".format(vaultid) cursor.execute(query) obj_list = [] for row in cursor: if s_db_objects.obj_status(row[2]).is_active(): obj_list.append([row[0],row[1]]) if len(obj_list) == 0: return False return obj_list
def is_user_active(user): u_id = s_h.get_user_id(user) if not u_id: return False cursor.execute('select status from ss_userbase where id = %s',u_id) res = cursor.fetchone()[0] cursor.fetchall() if res is not None: return s_db_objects.obj_status(res) .is_active() else: return False
def get_object_id_by_name(vaultname, objectname): #gets the _latest_ created _active_ object with that name v_id = s_h.get_vault_id(vaultname) if not v_id: v_id = get_vault_id_by_name(vaultname) if not v_id: return False query = "select id, status from ss_objects where groupid = {} and objectname = '{}' order by id desc".format(v_id, objectname) cursor.execute(query) res = cursor.fetchall() for row in res: if s_db_objects.obj_status(row[1]) .is_active(): return row[0] return False
def count_members_of_vault(vaultid,privilege): nr = 0 cursor.execute("select status from ss_groupkeys where groupid = {}".format(vaultid)) res = cursor.fetchall() if privilege == 'admin': add = lambda status: status.has_admin() elif privilege == 'write': add = lambda status: status.has_write() elif privilege == 'read': add = lambda status: status .has_read() elif privilege is None: add = lambda val: True for row in res: if add(s_db_objects.obj_status(row[0])): nr+=1 return nr
def verify_member_of_vault(userid,vaultid): cursor.execute("select status from ss_groupkeys where userid={} and groupid = {}".format(userid,vaultid)) res = cursor.fetchall() for row in res: return s_db_objects.obj_status(row[0]) return False