Add tests for port and protocol validation and update changelog
This commit is contained in:
@@ -48,11 +48,11 @@ _default_frequency_set: Dict[str, Dict] = {
|
||||
"""Frequency configuration that is automatically used for any new airspace."""
|
||||
|
||||
|
||||
def register_default_frequency(freq_name: str, freq_hz: float, data_rate_bps: float):
|
||||
def register_default_frequency(freq_name: str, freq_hz: float, data_rate_bps: float) -> None:
|
||||
"""Add to the default frequency configuration. This is intended as a plugin hook.
|
||||
|
||||
If your plugin makes use of bespoke frequencies for wireless communication, you should make a call to this method
|
||||
whereever you define components that rely on the bespoke frequencies. That way, as soon as your components are
|
||||
wherever you define components that rely on the bespoke frequencies. That way, as soon as your components are
|
||||
imported, this function automatically updates the default frequency set.
|
||||
|
||||
This should also be run before instances of AirSpace are created.
|
||||
@@ -93,7 +93,7 @@ class AirSpace(BaseModel):
|
||||
return self.frequencies[freq_name]["data_rate_bps"] / (1024.0 * 1024.0)
|
||||
return 0.0
|
||||
|
||||
def set_frequency_max_capacity_mbps(self, cfg: Dict[int, float]):
|
||||
def set_frequency_max_capacity_mbps(self, cfg: Dict[int, float]) -> None:
|
||||
"""
|
||||
Sets custom maximum data transmission capacities for multiple frequencies.
|
||||
|
||||
|
||||
@@ -1839,15 +1839,14 @@ class Node(SimComponent):
|
||||
|
||||
def show_open_ports(self, markdown: bool = False):
|
||||
"""Prints a table of the open ports on the Node."""
|
||||
table = PrettyTable(["Port", "Name"])
|
||||
table = PrettyTable(["Port"])
|
||||
if markdown:
|
||||
table.set_style(MARKDOWN)
|
||||
table.align = "l"
|
||||
table.title = f"{self.hostname} Open Ports"
|
||||
for port in self.software_manager.get_open_ports():
|
||||
if port > 0:
|
||||
# TODO: do a reverse lookup for port name, or change this to only show port int
|
||||
table.add_row([port, port])
|
||||
table.add_row([port])
|
||||
print(table.get_string(sortby="Port"))
|
||||
|
||||
@property
|
||||
|
||||
@@ -366,7 +366,7 @@ class AbstractC2(Application, identifier="AbstractC2"):
|
||||
:return: True on successful configuration, false otherwise.
|
||||
:rtype: bool
|
||||
"""
|
||||
# Validating that they are valid Enums.
|
||||
# Validating that they are valid Ports and Protocols.
|
||||
if not is_valid_port(payload.masquerade_port) or not is_valid_protocol(payload.masquerade_protocol):
|
||||
self.sys_log.warning(
|
||||
f"{self.name}: Received invalid Masquerade Values within Keep Alive."
|
||||
|
||||
Reference in New Issue
Block a user