Skip to content

Commit a63de55

Browse files
committed
Filter files to only include non deleted ones in descending order
1 parent 12af8ba commit a63de55

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

mythic/mythic.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ async def get_all_uploaded_files(
15991599

16001600
async def get_uploaded_file_by_name(
16011601
mythic: mythic_classes.Mythic, custom_return_attributes: str = None, filename: str = None,
1602-
) -> AsyncGenerator:
1602+
) -> dict:
16031603
"""
16041604
Execute a query to get metadata about the uploaded file by name.
16051605
To download the contents of a file, use the `download_file` function with the agent_file_id.
@@ -1608,7 +1608,7 @@ async def get_uploaded_file_by_name(
16081608
"""
16091609
file_query = f"""
16101610
query uploaded_file_by_name($filename: String!){{
1611-
filemeta(where: {{is_screenshot: {{_eq: false}}, is_download_from_agent: {{_eq: false}}, is_payload: {{_eq: false}}, filename_utf8: {{_eq: $filename}}}}, limit: 1){{
1611+
filemeta(where: {{is_screenshot: {{_eq: false}}, is_download_from_agent: {{_eq: false}}, is_payload: {{_eq: false}}, deleted: {{_eq: false}}, filename_utf8: {{_eq: $filename}}}}, order_by: {{id: desc}}, limit: 1){{
16121612
{custom_return_attributes if custom_return_attributes is not None else '...file_data_fragment'}
16131613
}}
16141614
}}
@@ -1617,8 +1617,7 @@ async def get_uploaded_file_by_name(
16171617
output = await mythic_utilities.graphql_post(
16181618
mythic=mythic, query=file_query,
16191619
)
1620-
if len(output["filemeta"]) > 0:
1621-
return output["filemeta"]
1620+
return output["filemeta"]
16221621

16231622

16241623
async def update_file_comment(

0 commit comments

Comments
 (0)