mirror of
https://github.com/Pennyw0rth/NetExec
synced 2026-06-06 16:34:30 +00:00
feat(cmedb): update get_groups to use proper sqlalchemy syntax
This commit is contained in:
@@ -778,23 +778,26 @@ class database:
|
||||
group_domain = group_domain.split('.')[0].upper()
|
||||
|
||||
if self.is_group_valid(filter_term):
|
||||
results = self.conn.query(self.GroupsTable).filter(
|
||||
# results = self.conn.query(self.GroupsTable).filter(
|
||||
# self.GroupsTable.c.id == filter_term
|
||||
# ).first()
|
||||
q = select(self.GroupsTable).filter(
|
||||
self.GroupsTable.c.id == filter_term
|
||||
).first()
|
||||
)
|
||||
elif group_name and group_domain:
|
||||
results = self.conn.query(self.GroupsTable).filter(
|
||||
q = select(self.GroupsTable).filter(
|
||||
func.lower(self.GroupsTable.c.username) == func.lower(group_name),
|
||||
func.lower(self.GroupsTable.c.domain) == func.lower(group_domain)
|
||||
).all()
|
||||
)
|
||||
elif filter_term and filter_term != "":
|
||||
results = self.conn.query(self.GroupsTable).filter(
|
||||
q = select(self.GroupsTable).filter(
|
||||
func.lower(self.GroupsTable.c.name).like(func.lower(f"%{filter_term}%"))
|
||||
).all()
|
||||
)
|
||||
else:
|
||||
results = self.conn.query(self.GroupsTable).all()
|
||||
q = select(self.GroupsTable).filter()
|
||||
|
||||
results = asyncio.run(self.conn.execute(q)).all()
|
||||
|
||||
self.conn.commit()
|
||||
self.conn.close()
|
||||
logging.debug(f"get_groups(filterTerm={filter_term}, groupName={group_name}, groupDomain={group_domain}) => {results}")
|
||||
return results
|
||||
|
||||
|
||||
Reference in New Issue
Block a user