Skip to content

iterations

iterations ¤

Classes:

Name Description
StraceEnvironment

StraceEnvironment is a class that sets up and manages an execution environment using strace for system call tracing.

panther.plugins.environments.execution_environment.iterations.iterations.StraceEnvironment ¤

StraceEnvironment(env_config_to_test: StraceConfig, output_dir: str, env_type: str, env_sub_type: str, event_manager: EventManager)

Bases: IExecutionEnvironment, ABC

StraceEnvironment is a class that sets up and manages an execution environment using strace for system call tracing.

Attributes:

Name Type Description
global_config GlobalConfig

The global configuration for the environment.

env_config_to_test StraceConfig

The specific configuration for the strace environment to test.

services_managers list[IServiceManager]

List of service managers to handle services within the environment.

test_config TestConfig

Configuration for the test being executed.

plugin_loader PluginLoader

Loader for plugins used in the environment.

Methods:

Name Description
setup_environment

list[IServiceManager], test_config: TestConfig, global_config: GlobalConfig, timestamp: str, plugin_loader: PluginLoader): Sets up the environment with the provided service managers, test configuration, global configuration, and plugin loader.

to_command

int | None = None) -> str: Generates the strace command for execution. Optionally attaches to a specific process ID.

__repr__

Returns a string representation of the StraceEnvironment instance.

Methods:

Name Description
is_network_environment

Returns True if the plugin is an network environment.

teardown_environment

Tears down the environment after experiments are completed.

to_command

Generate the strace command for execution.

Source code in panther/plugins/environments/execution_environment/iterations/iterations.py
43
44
45
46
47
48
49
50
51
52
53
54
55
def __init__(
    self,
    env_config_to_test: StraceConfig,
    output_dir: str,
    env_type: str,
    env_sub_type: str,
    event_manager: EventManager,
):
    super().__init__(
        env_config_to_test, output_dir, env_type, env_sub_type, event_manager
    )
    self.global_config = None
    self.env_config_to_test = env_config_to_test

is_network_environment ¤

is_network_environment()

Returns True if the plugin is an network environment.

Source code in panther/plugins/environments/execution_environment/execution_environment_interface.py
52
53
54
55
56
def is_network_environment(self):
    """
    Returns True if the plugin is an network environment.
    """
    return False

teardown_environment ¤

teardown_environment()

Tears down the environment after experiments are completed.

Source code in panther/plugins/environments/execution_environment/execution_environment_interface.py
72
73
74
75
76
def teardown_environment(self):
    """
    Tears down the environment after experiments are completed.
    """
    pass

to_command ¤

to_command(pid: int | None = None) -> str

Generate the strace command for execution. :param pid: Optional process ID to attach to. :return: Strace command as a string.

Source code in panther/plugins/environments/execution_environment/iterations/iterations.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def to_command(self, pid: int | None = None) -> str:
    """
    Generate the strace command for execution.
    :param pid: Optional process ID to attach to.
    :return: Strace command as a string.
    """
    self.env_config_to_test = StraceConfig()
    excluded = ",".join(
        f"{syscall}" for syscall in self.env_config_to_test.excluded_syscalls
    )
    command = [
        self.env_config_to_test.strace_binary,
        "-k",
    ]  # Include kernel stack if enabled
    command.append(f'-e trace="!{excluded}"')  # Exclude specified syscalls
    if pid:
        command.extend(["-p", str(pid)])
    # if self.env_config_to_test.trace_network_syscalls:
    #     command.append("-e trace=network")  # Include network-related syscalls
    # if self.env_config_to_test.additional_parameters:
    #     command.extend(self.env_config_to_test.additional_parameters)
    # command.append(f"-o {self.env_config_to_test.output_file}")
    return " ".join(command)