BB: Create copy of agent configuration when updating it for different tests

This commit is contained in:
Shreya Malviya 2022-09-01 12:54:54 +05:30
parent 446524b5b8
commit 637023c568
1 changed files with 25 additions and 17 deletions

View File

@ -9,70 +9,78 @@ def add_exploiters(
vulnerability: Sequence[PluginConfiguration] = [], vulnerability: Sequence[PluginConfiguration] = [],
) -> AgentConfiguration: ) -> AgentConfiguration:
agent_configuration.propagation.exploitation.brute_force = brute_force agent_configuration_copy = agent_configuration.copy()
agent_configuration.propagation.exploitation.vulnerability = vulnerability agent_configuration_copy.propagation.exploitation.brute_force = brute_force
agent_configuration_copy.propagation.exploitation.vulnerability = vulnerability
return agent_configuration return agent_configuration_copy
def add_fingerprinters( def add_fingerprinters(
agent_configuration: AgentConfiguration, fingerprinters: Sequence[PluginConfiguration] agent_configuration: AgentConfiguration, fingerprinters: Sequence[PluginConfiguration]
) -> AgentConfiguration: ) -> AgentConfiguration:
agent_configuration.propagation.network_scan.fingerprinters = fingerprinters agent_configuration_copy = agent_configuration.copy()
agent_configuration_copy.propagation.network_scan.fingerprinters = fingerprinters
return agent_configuration return agent_configuration_copy
def add_tcp_ports( def add_tcp_ports(
agent_configuration: AgentConfiguration, tcp_ports: Sequence[int] agent_configuration: AgentConfiguration, tcp_ports: Sequence[int]
) -> AgentConfiguration: ) -> AgentConfiguration:
agent_configuration.propagation.network_scan.tcp.ports = tuple(tcp_ports) agent_configuration_copy = agent_configuration.copy()
agent_configuration_copy.propagation.network_scan.tcp.ports = tuple(tcp_ports)
return agent_configuration return agent_configuration_copy
def add_subnets( def add_subnets(
agent_configuration: AgentConfiguration, subnets: Sequence[str] agent_configuration: AgentConfiguration, subnets: Sequence[str]
) -> AgentConfiguration: ) -> AgentConfiguration:
agent_configuration.propagation.network_scan.targets.subnets = subnets agent_configuration_copy = agent_configuration.copy()
agent_configuration_copy.propagation.network_scan.targets.subnets = subnets
return agent_configuration return agent_configuration_copy
def add_credential_collectors( def add_credential_collectors(
agent_configuration: AgentConfiguration, credential_collectors: Sequence[PluginConfiguration] agent_configuration: AgentConfiguration, credential_collectors: Sequence[PluginConfiguration]
) -> AgentConfiguration: ) -> AgentConfiguration:
agent_configuration.credential_collectors = tuple(credential_collectors) agent_configuration_copy = agent_configuration.copy()
agent_configuration_copy.credential_collectors = tuple(credential_collectors)
return agent_configuration return agent_configuration_copy
def add_http_ports( def add_http_ports(
agent_configuration: AgentConfiguration, http_ports: Sequence[int] agent_configuration: AgentConfiguration, http_ports: Sequence[int]
) -> AgentConfiguration: ) -> AgentConfiguration:
agent_configuration.propagation.exploitation.options.http_ports = http_ports agent_configuration_copy = agent_configuration.copy()
agent_configuration_copy.propagation.exploitation.options.http_ports = http_ports
return agent_configuration return agent_configuration_copy
def set_keep_tunnel_open_time( def set_keep_tunnel_open_time(
agent_configuration: AgentConfiguration, keep_tunnel_open_time: int agent_configuration: AgentConfiguration, keep_tunnel_open_time: int
) -> AgentConfiguration: ) -> AgentConfiguration:
agent_configuration.keep_tunnel_open_time = keep_tunnel_open_time agent_configuration_copy = agent_configuration.copy()
agent_configuration_copy.keep_tunnel_open_time = keep_tunnel_open_time
return agent_configuration return agent_configuration_copy
def set_maximum_depth( def set_maximum_depth(
agent_configuration: AgentConfiguration, maximum_depth: int agent_configuration: AgentConfiguration, maximum_depth: int
) -> AgentConfiguration: ) -> AgentConfiguration:
agent_configuration.propagation.maximum_depth = maximum_depth agent_configuration_copy = agent_configuration.copy()
agent_configuration_copy.propagation.maximum_depth = maximum_depth
return agent_configuration return agent_configuration_copy