Skip to content

Commit 7be4637

Browse files
committed
fix "slow mongo"
1 parent 634e0a9 commit 7be4637

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### [28.01.2026]
2+
* Search optimization: General search terms now use exact match by default for better MongoDB performance.
3+
* Use regex characters (e.g., `^ $ | ? * + ( ) [ ] { }`) to trigger a regex search.
4+
* Updated search UI help and placeholders.
5+
16
### [16.01.2026] CAPE v2.5
27
* Bootstrap 5 upgrade and some visual WEBGUI rewamp. Some improvements still might come soon!
38
* htmlreport - rewamp!

lib/cuckoo/common/web_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,13 +1384,11 @@ def perform_search(
13841384
raise ValueError("Invalid TTP enterred")
13851385
elif term == "malscore":
13861386
query_val = {"$gte": float(value)}
1387-
elif term == "name":
1387+
else:
13881388
if re.search(r"[\^\$\|\?\*\+\(\)\[\]\{\}]", value):
13891389
query_val = {"$regex": value, "$options": "i"}
13901390
else:
13911391
query_val = value
1392-
else:
1393-
query_val = {"$regex": value, "$options": "i"}
13941392

13951393
if term not in search_term_map:
13961394
return None

web/templates/analysis/search.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="card-body">
77
<form role="form" action="{% url "search" %}" method="get">
88
<div class="input-group w-50 mx-auto">
9-
<input type="text" class="form-control bg-dark text-white border-secondary" id="form_search" name="search" placeholder="Search term as regex..." aria-label="Search">
9+
<input type="text" class="form-control bg-dark text-white border-secondary" id="form_search" name="search" placeholder="Search term (use regex for partial match)..." aria-label="Search">
1010
<button class="btn btn-outline-info" type="submit"><i class="fas fa-search"></i> Search</button>
1111
</div>
1212
</form>
@@ -24,6 +24,7 @@ <h5 class="mb-0 text-white"><i class="fas fa-info-circle me-2"></i> Search Help<
2424
<div class="card-body">
2525
<p class="text-white-50">ElasticSearch queries do not use a prefix. e.g., <code>*windows.*</code> matches 'time.windows.com'.</p>
2626
<p class="text-white-50">For MD5, SHA1, SHA256, etc., no prefix is needed (matches any file generated by analysis).</p>
27+
<p class="text-white-50">By default, searches are exact matches. Use regex characters (e.g., <code>^ $ | ? * + ( ) [ ] { }</code>) to force a regex search.</p>
2728
<div class="table-responsive">
2829
<table class="table table-striped table-dark table-hover table-sm">
2930
<thead>

0 commit comments

Comments
 (0)