Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/cuckoo/common/web_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,7 @@ def perform_search(
query_val = {"$exists": True}

retval = []
mongo_search_query = None
if repconf.mongodb.enabled and query_val:
if term in hash_searches:
# The file details are uniq, and we store 1 to many. So where hash type is uniq, IDs are list
Expand Down Expand Up @@ -1436,11 +1437,9 @@ def perform_search(
projection = dict(**projection)
projection[f"target.file.{FILE_REF_KEY}"] = 1
if term in search_term_map_repetetive_blocks:
or_conditions = []
for path, condition in search_term_map_repetetive_blocks.items():
or_conditions.append({path: condition})
mongo_search_query = {"$or": or_conditions}
retval = list(mongo_find("analysis", mongo_search_query, projection, limit=search_limit))
mongo_search_query = {"$or": [{path: condition} for path, condition in mongo_search_query.items()]}
if not retval and mongo_search_query:
retval = list(mongo_find("analysis", mongo_search_query, projection, limit=search_limit))
for doc in retval:
target_file = doc.get("target", {}).get("file", {})
if FILE_REF_KEY in target_file and "sha256" not in target_file:
Expand Down