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
10 changes: 6 additions & 4 deletions lib/cuckoo/common/web_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def load_vms_tags(force: bool = False):
global _all_vms_tags
with _load_vms_tags_lock:
if _all_vms_tags is not None and not force:
return _all_vms_tags
return _all_vms_tags or []
all_tags = []
if HAVE_DIST and dist_conf.distributed.enabled:
try:
Expand All @@ -242,11 +242,13 @@ def load_vms_tags(force: bool = False):
except Exception as e:
print(e)

for machine in Database().list_machines(include_reserved=True):
machines = Database().list_machines(include_reserved=True)
for machine in machines:
all_tags += [tag.name for tag in machine.tags if tag not in all_tags]

_all_vms_tags = list(sorted(set(all_tags)))
return _all_vms_tags
if machines:
_all_vms_tags = list(sorted(set(all_tags)))
Comment on lines +249 to +250
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current condition if machines: correctly prevents caching an empty tag list when no machines are returned by Database().list_machines(). However, if machines are present but none of them have any associated tags, all_tags will still be an empty list. In this scenario, _all_vms_tags would be updated to [], which could still lead to the "permanently cache an empty tag list" issue described in the pull request. To fully address this, _all_vms_tags should only be updated if all_tags actually contains tags.

Suggested change
if machines:
_all_vms_tags = list(sorted(set(all_tags)))
if all_tags:
_all_vms_tags = list(sorted(set(all_tags)))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is intentional, some deployments may not use tags

return _all_vms_tags or []


def top_asn(date_since: datetime = False, results_limit: int = 20) -> dict:
Expand Down
Loading