mirror of
https://github.com/Pennyw0rth/NetExec
synced 2026-06-06 16:34:30 +00:00
feat(cmedb): update get_credentials to use proper sqlalchemy syntax
This commit is contained in:
@@ -696,24 +696,23 @@ class database:
|
||||
"""
|
||||
# if we're returning a single credential by ID
|
||||
if self.is_credential_valid(filter_term):
|
||||
results = self.conn.query(self.UsersTable).filter(
|
||||
q = select(self.UsersTable).filter(
|
||||
self.UsersTable.c.id == filter_term
|
||||
).all()
|
||||
)
|
||||
elif cred_type:
|
||||
results = self.conn.query(self.UsersTable).filter(
|
||||
q = select(self.UsersTable).filter(
|
||||
self.UsersTable.c.credtype == cred_type
|
||||
).all()
|
||||
)
|
||||
# if we're filtering by username
|
||||
elif filter_term and filter_term != '':
|
||||
results = self.conn.query(self.UsersTable).filter(
|
||||
q = select(self.UsersTable).filter(
|
||||
func.lower(self.UsersTable.c.username).like(func.lower(f"%{filter_term}%"))
|
||||
).all()
|
||||
)
|
||||
# otherwise return all credentials
|
||||
else:
|
||||
results = self.conn.query(self.UsersTable).all()
|
||||
q = select(self.UsersTable)
|
||||
|
||||
self.conn.commit()
|
||||
self.conn.close()
|
||||
results = asyncio.run(self.conn.execute(q)).all()
|
||||
return results
|
||||
|
||||
def is_user_valid(self, user_id):
|
||||
|
||||
Reference in New Issue
Block a user