Skip to content
Open
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
4 changes: 2 additions & 2 deletions lib/cuckoo/core/analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def route_network(self):
)
self.rooter_response = rooter("libvirt_fwo_enable", self.machine.interface, self.machine.ip)

elif self.route in ("none", "None", "drop"):
elif self.route in ("none", "None", "drop", "false"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The tuple of routing values ("none", "None", "drop", "false") is now duplicated in three places within this file (lines 540, 609, and 746). To improve maintainability and robustness, consider using a case-insensitive check. This approach also handles variations like "False" or "DROP" and correctly processes boolean False values that might be passed via API calls.

Suggested change
elif self.route in ("none", "None", "drop", "false"):
elif str(self.route).lower() in ("none", "drop", "false"):

self.rooter_response = rooter("drop_enable", self.machine.ip, str(self.machine.resultserver_port))
elif self.route[:3] == "tun" and is_network_interface(self.route):
self.log.info("Network interface %s is tunnel", self.interface)
Expand Down Expand Up @@ -743,7 +743,7 @@ def unroute_network(self):
)
self.rooter_response = rooter("libvirt_fwo_disable", self.machine.interface, self.machine.ip)

elif self.route in ("none", "None", "drop"):
elif self.route in ("none", "None", "drop", "false"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with the logic in route_network, consider using a case-insensitive check here as well. This ensures that the cleanup process correctly identifies all variations of the 'no routing' state.

Suggested change
elif self.route in ("none", "None", "drop", "false"):
elif str(self.route).lower() in ("none", "drop", "false"):

self.rooter_response = rooter("drop_disable", self.machine.ip, str(self.machine.resultserver_port))
elif self.route[:3] == "tun":
self.log.info("Disable tunnel interface: %s", self.interface)
Expand Down
Loading