Skip to content

Commit

Permalink
refact: Refactor variable names #2947
Browse files Browse the repository at this point in the history
  • Loading branch information
fedepacher committed Aug 17, 2022
1 parent 9490d8b commit a810b0c
Show file tree
Hide file tree
Showing 34 changed files with 94 additions and 93 deletions.
4 changes: 2 additions & 2 deletions deps/wazuh_testing/wazuh_testing/modules/eps/event_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def check_eps_disabled():
check_analysisd_event(callback=fr'.*INFO: EPS limit disabled.*', timeout=eps.T_10)


def check_eps_enabled(maximun, timeframe):
def check_eps_enabled(maximum, timeframe):
"""Check if the eps module is enable"""
check_analysisd_event(callback=fr".*INFO: EPS limit enabled, EPS: '{maximun}', timeframe: '{timeframe}'",
check_analysisd_event(callback=fr".*INFO: EPS limit enabled, EPS: '{maximum}', timeframe: '{timeframe}'",
timeout=eps.T_10)


Expand Down
12 changes: 6 additions & 6 deletions deps/wazuh_testing/wazuh_testing/scripts/simulate_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def process_script_parameters(args):
args (argparse.Namespace): Script args.
"""
# Add keepalive and receive_message modules if they are not specified in script parameters
if None == args.disable_keepalive:
if args.disable_keepalive is None:
if 'keepalive' not in args.modules:
args.modules.append('keepalive')
args.modules_eps.append('0')


if None == args.disable_receive:
if args.disable_receive is None:
if 'receive_messages' not in args.modules:
args.modules.append('receive_messages')
args.modules_eps.append('0')
Expand Down Expand Up @@ -139,7 +139,7 @@ def create_injectors(agents, manager_address, protocol, limit_msg):
agents (list): List of agents to create the injectors (1 injector/agent).
manager_address (str): Manager IP address to connect the agents.
protocol (str): TCP or UDP protocol to connect the agents to the manager.
limit_msg (int): Maximun amount of message to be sent.
limit_msg (int): Maximum amount of message to be sent.
Returns:
list: List of injector objects.
Expand All @@ -164,10 +164,10 @@ def start(injector, time_alive, flag_disable_keepalive):
"""
try:
injector.run()
if not flag_disable_keepalive:
sleep(time_alive)
else:
if flag_disable_keepalive:
injector.wait()
else:
sleep(time_alive)
finally:
stop(injector)

Expand Down
4 changes: 2 additions & 2 deletions deps/wazuh_testing/wazuh_testing/tools/agent_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ class Injector:
thread_number (int): total number of threads created. This may change depending on the modules used in the
agent.
threads (list): list containing all the threads created.
limit_msg (int): Maximun amount of message to be sent.
limit_msg (int): Maximum amount of message to be sent.
Examples:
To create an Injector, you need to create an agent, a sender and then, create the injector using both of them.
Expand Down Expand Up @@ -1601,7 +1601,7 @@ class InjectorThread(threading.Thread):
agent (Agent): agent owner of the injector and the sender.
module (str): module used to send events (fim, syscollector, etc).
stop_thread (int): 0 if the thread is running, 1 if it is stopped.
limit_msg (int): Maximun amount of message to be sent.
limit_msg (int): Maximum amount of message to be sent.
"""
def __init__(self, thread_id, name, sender, agent, module, limit_msg):
super(InjectorThread, self).__init__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- eps:
elements:
- maximum:
value: MAXIMUN
value: MAXIMUM
- timeframe:
value: TIMEFRAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- eps:
elements:
- maximum:
value: MAXIMUN
value: MAXIMUM
- timeframe:
value: TIMEFRAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- eps:
elements:
- maximum:
value: MAXIMUN
value: MAXIMUM
- timeframe:
value: TIMEFRAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- eps:
elements:
- maximum:
value: MAXIMUN
value: MAXIMUM
- timeframe:
value: TIMEFRAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- eps:
elements:
- maximum:
value: MAXIMUN
value: MAXIMUM
- timeframe:
value: TIMEFRAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- eps:
elements:
- maximum:
value: MAXIMUN
value: MAXIMUM
- timeframe:
value: TIMEFRAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- eps:
elements:
- maximum:
value: MAXIMUN
value: MAXIMUM
- timeframe:
value: TIMEFRAME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- eps:
elements:
- maximum:
value: MAXIMUN
value: MAXIMUM

- section: remote
elements:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: 'EPS Limits disabled'
description: 'EPS Limits disabled'
configuration_parameters:
MAXIMUN: '0'
MAXIMUM: '0'
TIMEFRAME: '5'
metadata:
maximun: 0
maximum: 0
timeframe: 5
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: 'EPS Limits enabled'
description: 'EPS Limits enabled'
configuration_parameters:
MAXIMUN: '10'
MAXIMUM: '10'
TIMEFRAME: '5'
metadata:
maximun: 10
maximum: 10
timeframe: 5
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
- name: 'EPS Limits with maximun values over the maximun allowed'
description: 'EPS Limits with maximun values over the maximun allowed'
- name: 'EPS Limits with maximum values over the maximum allowed'
description: 'EPS Limits with maximum values over the maximum allowed'
configuration_parameters:
MAXIMUN: '100001'
MAXIMUM: '100001'
TIMEFRAME: '5'
metadata:
maximun: 100001
maximum: 100001
timeframe: 5

- name: 'EPS Limits with timeframe values over the timeframe allowed'
description: 'EPS Limits with timeframe values over the timeframe allowed'
configuration_parameters:
MAXIMUN: '10'
MAXIMUM: '10'
TIMEFRAME: '3601'
metadata:
maximun: 10
maximum: 10
timeframe: 3601

- name: 'EPS Limits with timeframe value 0'
description: 'EPS Limits with timeframe value 0'
configuration_parameters:
MAXIMUN: '10'
MAXIMUM: '10'
TIMEFRAME: '0'
metadata:
maximun: 10
maximum: 10
timeframe: 0

- name: 'EPS Limits with maximun and timeframe values 0'
description: 'EPS Limits with maximun and timeframe values 0'
- name: 'EPS Limits with maximum and timeframe values 0'
description: 'EPS Limits with maximum and timeframe values 0'
configuration_parameters:
MAXIMUN: '0'
MAXIMUM: '0'
TIMEFRAME: '0'
metadata:
maximun: 0
maximum: 0
timeframe: 0
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: 'EPS Limits disables'
description: 'EPS Limits disables'
configuration_parameters:
MAXIMUN: '0'
MAXIMUM: '0'
TIMEFRAME: '5'
metadata:
maximun: 0
maximum: 0
timeframe: 5
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: 'EPS Limits process old events instead of new ones - Multithread'
description: 'EPS Limits process old events instead of new ones - Multithread'
configuration_parameters:
MAXIMUN: '10'
MAXIMUM: '10'
TIMEFRAME: '5'
metadata:
maximun: 10
maximum: 10
timeframe: 5
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: 'EPS Limits process old events instead of new ones - One thread'
description: 'EPS Limits process old events instead of new ones - One thread'
configuration_parameters:
MAXIMUN: '100'
MAXIMUM: '100'
TIMEFRAME: '5'
metadata:
maximun: 100
maximum: 100
timeframe: 5
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: 'EPS Limits start dropping events'
description: 'EPS Limits start dropping events'
configuration_parameters:
MAXIMUN: '1'
MAXIMUM: '1'
TIMEFRAME: '5'
metadata:
maximun: 1
maximum: 1
timeframe: 5
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: 'EPS Limits start queueing events'
description: 'EPS Limits start queueing events'
configuration_parameters:
MAXIMUN: '100'
MAXIMUM: '100'
TIMEFRAME: '5'
metadata:
maximun: 100
maximum: 100
timeframe: 5
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- name: 'EPS Limits stop processing events'
description: 'EPS Limits stop processing events'
configuration_parameters:
MAXIMUN: '100'
MAXIMUM: '100'
TIMEFRAME: '5'
metadata:
maximun: 100
maximum: 100
timeframe: 5
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: 'EPS Limits without maximun value'
description: 'EPS Limits without maximun value'
- name: 'EPS Limits without maximum value'
description: 'EPS Limits without maximum value'
configuration_parameters:
TIMEFRAME: '5'
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: 'EPS Limits without timeframe value'
description: 'EPS Limits without timeframe value'
configuration_parameters:
MAXIMUN: '500'
MAXIMUM: '500'
metadata:
maximun: 500
maximum: 500
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: 'EPS Limits without timeframe value'
description: 'EPS Limits without timeframe value'
configuration_parameters:
MAXIMUN: '500'
MAXIMUM: '500'
metadata:
maximun: 500
maximum: 500
4 changes: 2 additions & 2 deletions tests/integration/test_analysisd/test_eps/test_enabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ def test_enabled(configuration, metadata, set_wazuh_configuration_eps,
- Verify that when the `maximum` value is set to a values greater than 0 and lower than 100000 and, `timeframe`
value is set to a value greater than 0 and lower than 3600, the module EPS limits is running.
- Verify that the wazuh-analysisd daemon is running.
input_description:
- The `cases_enabled.yaml` file provides the module configuration for this test.
expected_output:
- r'(.*)wazuh-analysisd: INFO: EPS limit enabled, EPS: (.*), timeframe: (.*)'
'''
evm.check_eps_enabled(metadata['maximun'], metadata['timeframe'])
evm.check_eps_enabled(metadata['maximum'], metadata['timeframe'])
# Check that wazuh-analysisd is running
check_if_deamon_is_running('wazuh-analysisd')
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
TEST_CASES_PATH = os.path.join(TEST_DATA_PATH, 'test_cases')

# Configuration and cases data
t1_configurations_path = os.path.join(CONFIGURATIONS_PATH, 'configuration_without_maximun.yaml')
t1_cases_path = os.path.join(TEST_CASES_PATH, 'cases_without_maximun.yaml')
t1_configurations_path = os.path.join(CONFIGURATIONS_PATH, 'configuration_without_maximum.yaml')
t1_cases_path = os.path.join(TEST_CASES_PATH, 'cases_without_maximum.yaml')

t2_configurations_path = os.path.join(CONFIGURATIONS_PATH, 'configuration_without_timeframe.yaml')
t2_cases_path = os.path.join(TEST_CASES_PATH, 'cases_without_timeframe.yaml')

t3_configurations_path = os.path.join(CONFIGURATIONS_PATH, 'configuration_without_timeframe_maximun.yaml')
t3_cases_path = os.path.join(TEST_CASES_PATH, 'cases_without_timeframe_maximun.yaml')
t3_configurations_path = os.path.join(CONFIGURATIONS_PATH, 'configuration_without_timeframe_maximum.yaml')
t3_cases_path = os.path.join(TEST_CASES_PATH, 'cases_without_timeframe_maximum.yaml')

# Test configurations without maximun value (t1)
# Test configurations without maximum value (t1)
t1_configuration_parameters, t1_configuration_metadata, t1_case_ids = get_test_cases_data(t1_cases_path)
t1_configurations = load_configuration_template(t1_configurations_path, t1_configuration_parameters,
t1_configuration_metadata)
Expand All @@ -35,15 +35,15 @@
t2_configurations = load_configuration_template(t2_configurations_path, t2_configuration_parameters,
t2_configuration_metadata)

# Test configurations without timeframe and maximun values (t3)
# Test configurations without timeframe and maximum values (t3)
t3_configuration_parameters, t3_configuration_metadata, t3_case_ids = get_test_cases_data(t3_cases_path)
t3_configurations = load_configuration_template(t3_configurations_path, t3_configuration_parameters,
t3_configuration_metadata)


@pytest.mark.parametrize('configuration, metadata', zip(t1_configurations, t1_configuration_metadata), ids=t1_case_ids)
@pytest.mark.parametrize('configure_local_internal_options_eps', [ANALYSISD_STATE_INTERNAL_DEFAULT], indirect=True)
def test_without_maximun(configuration, metadata, set_wazuh_configuration_eps,
def test_without_maximum(configuration, metadata, set_wazuh_configuration_eps,
truncate_monitored_files, restart_wazuh_daemon_after_finishing):
'''
description: Check that wazuh manager is not started when `maximum` value is not present in the
Expand Down Expand Up @@ -149,7 +149,7 @@ def test_without_timeframe(configuration, metadata, set_wazuh_configuration_eps,

@pytest.mark.parametrize('configuration, metadata', zip(t3_configurations, t3_configuration_metadata), ids=t3_case_ids)
@pytest.mark.parametrize('configure_local_internal_options_eps', [ANALYSISD_STATE_INTERNAL_DEFAULT], indirect=True)
def test_without_timeframe_maximun(configuration, metadata, set_wazuh_configuration_eps,
def test_without_timeframe_maximum(configuration, metadata, set_wazuh_configuration_eps,
truncate_monitored_files, restart_wazuh_daemon_after_finishing):
'''
description: Check that wazuh manager is not started when `maximum` and/or `timeframe` are not present in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@pytest.mark.parametrize('configuration, metadata', zip(t1_configurations, t1_configuration_metadata), ids=t1_case_ids)
@pytest.mark.parametrize('configure_local_internal_options_eps', [ANALYSISD_STATE_INTERNAL_DEFAULT], indirect=True)
def test_invalid_values(configuration, metadata, set_wazuh_configuration_eps,
truncate_monitored_files, restart_wazuh_daemon_after_finishing):
truncate_monitored_files, restart_wazuh_daemon_after_finishing):
'''
description: Check that wazuh manager is not started when an invalid value is set to `maximum` and/or `timeframe`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@pytest.mark.parametrize('configuration, metadata', zip(t1_configurations, t1_configuration_metadata), ids=t1_case_ids)
@pytest.mark.parametrize('configure_local_internal_options_eps', [ANALYSISD_STATE_INTERNAL_DEFAULT], indirect=True)
def test_disabled(configuration, metadata, set_wazuh_configuration_eps,
truncate_monitored_files, restart_wazuh_daemon_function):
truncate_monitored_files, restart_wazuh_daemon_function):
'''
description: Check that limits EPS is disabled when it is not configured.
Expand Down
Loading

0 comments on commit a810b0c

Please sign in to comment.