Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate test_registry_report_changes of test_fim/test_registry documentation to qa-docs #2127

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
# Copyright (C) 2015-2021, Wazuh Inc.
# Created by Wazuh, Inc. <info@wazuh.com>.
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2

'''
copyright: Copyright (C) 2015-2021, Wazuh Inc.

Created by Wazuh, Inc. <info@wazuh.com>.

This program is free software; you can redistribute it and/or modify it under the terms of GPLv2

type: integration

brief: File Integrity Monitoring (FIM) system watches selected files and triggering alerts when these files
are modified. Specifically, these tests will verify that FIM does not limit the size of the key
monitored to generate 'diff' information or the 'queue/diff/local' folder where Wazuh stores the
compressed files used to perform the 'diff' operation. Having the 'file_size' and 'disk_quota'
options disabled, and the 'report_changes' option enabled.
The FIM capability is managed by the 'wazuh-syscheckd' daemon, which checks configured
files for changes to the checksums, permissions, and ownership.

tier: 1

modules:
- fim

components:
- agent

daemons:
- wazuh-syscheckd

os_platform:
- windows

os_version:
- Windows 10
- Windows 8
- Windows 7
- Windows Server 2019
- Windows Server 2016
- Windows Server 2012
- Windows Server 2003
- Windows XP

references:
- https://documentation.wazuh.com/current/user-manual/capabilities/file-integrity/index.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/syscheck.html#diff

pytest_args:
- fim_mode:
realtime: Enable real-time monitoring on Linux (using the 'inotify' system calls) and Windows systems.
whodata: Implies real-time monitoring but adding the 'who-data' information.
- tier:
0: Only level 0 tests are performed, they check basic functionalities and are quick to perform.
1: Only level 1 tests are performed, they check functionalities of medium complexity.
2: Only level 2 tests are performed, they check advanced functionalities and are slow to perform.

tags:
- fim_registry_report_changes
'''
import os

import pytest
Expand Down Expand Up @@ -61,22 +114,62 @@ def get_configuration(request):
def test_all_limits_disabled(key, subkey, arch, value_name, tags_to_apply,
get_configuration, configure_environment, restart_syscheckd,
wait_for_fim_start):
"""
Check that no events are sent when the file_size exceeded

Parameters
----------
key : str
Root key (HKEY_*)
subkey : str
path of the registry.
arch : str
Architecture of the registry.
value_name : str
Name of the value that will be created
tags_to_apply : set
Run test if match with a configuration identifier, skip otherwise.
"""
'''
description: Check if the 'wazuh-syscheckd' daemon generates all FIM events when the 'file_size' and
the 'disk_quota' tags have set a small limit but they are disabled. For this purpose,
the test will monitor a key and create multiple values with a content of big size inside it.
That values exceed both, 'file_size' and 'disk_quota' limits. Finally, the test will verify
that all FIM events have been generated, since that those limits are disabled.

wazuh_min_version: 4.2.0

parameters:
- key:
type: str
brief: Path of the registry root key (HKEY_* constants).
- subkey:
type: str
brief: The registry key being monitored by syscheck.
- arch:
type: str
brief: Architecture of the registry.
- value_name:
type: str
brief: Name of the testing value that will be created
- tags_to_apply:
type: set
brief: Run test if matches with a configuration identifier, skip otherwise.
- get_configuration:
type: fixture
brief: Get configurations from the module.
- configure_environment:
type: fixture
brief: Configure a custom environment for testing.
- restart_syscheckd:
type: fixture
brief: Clear the 'ossec.log' file and start a new monitor.
- wait_for_fim_start:
type: fixture
brief: Wait for realtime start, whodata start, or end of initial FIM scan.

assertions:
- Verify that all FIM events are generated for the modifications made on the testing values.
- Verify that a 'diff' file is created for each monitored value.
- Verify that FIM events include the 'content_changes' field.

input_description: A test case (test_limits) is contained in external YAML file
(wazuh_registry_report_changes_limits_quota.yaml) which includes
configuration settings for the 'wazuh-syscheckd' daemon. That is
combined with the testing registry keys to be monitored defined
in this module.

expected_output:
- r'.*Sending FIM event: (.+)$' ('added', 'modified', and 'deleted' events)

tags:
- scheduled
- time_travel
'''
check_apply_test(tags_to_apply, get_configuration['tags'])
value_content = generate_string(4 * 1024 * 1024, '0')
values = {value_name: value_content}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,59 @@
# Copyright (C) 2015-2021, Wazuh Inc.
# Created by Wazuh, Inc. <info@wazuh.com>.
# This program is free software; you can redistribute it and/or modify it under the terms of GPLv2

'''
copyright: Copyright (C) 2015-2021, Wazuh Inc.

Created by Wazuh, Inc. <info@wazuh.com>.

This program is free software; you can redistribute it and/or modify it under the terms of GPLv2

type: integration

brief: File Integrity Monitoring (FIM) system watches selected files and triggering alerts when
these files are modified. Specifically, these tests will check if FIM limits the size of
'diff' information to generate from the monitored value when the 'diff_size_limit' and
the 'report_changes' options are enabled.
The FIM capability is managed by the 'wazuh-syscheckd' daemon, which checks configured
files for changes to the checksums, permissions, and ownership.

tier: 1

modules:
- fim

components:
- agent

daemons:
- wazuh-syscheckd

os_platform:
- windows

os_version:
- Windows 10
- Windows 8
- Windows 7
- Windows Server 2019
- Windows Server 2016
- Windows Server 2012
- Windows Server 2003
- Windows XP

references:
- https://documentation.wazuh.com/current/user-manual/capabilities/file-integrity/index.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/syscheck.html#windows-registry

pytest_args:
- fim_mode:
realtime: Enable real-time monitoring on Linux (using the 'inotify' system calls) and Windows systems.
whodata: Implies real-time monitoring but adding the 'who-data' information.
- tier:
0: Only level 0 tests are performed, they check basic functionalities and are quick to perform.
1: Only level 1 tests are performed, they check functionalities of medium complexity.
2: Only level 2 tests are performed, they check advanced functionalities and are slow to perform.

tags:
- fim_registry_report_changes
'''
import os

import pytest
Expand Down Expand Up @@ -62,24 +114,64 @@ def get_configuration(request):
def test_diff_size_limit_values(key, subkey, arch, value_name, tags_to_apply, size,
get_configuration, configure_environment, restart_syscheckd,
wait_for_fim_start):
"""
Check that no events are sent when the diff_size_limit exceeded

Parameters
----------
key : str
Root key (HKEY_*)
subkey : str
path of the registry.
arch : str
Architecture of the registry.
value_name : str
Name of the value that will be created
tags_to_apply : set
Run test if match with a configuration identifier, skip otherwise.
size : int
Size of the content to write in value
"""
'''
description: Check if the 'wazuh-syscheckd' daemon limits the size of the monitored value to generate
'diff' information from the limit set in the 'diff_size_limit' tag. For this purpose,
the test will monitor a key, create a testing value smaller than the 'diff_size_limit' and
increase its size on each test case. Finally, the test will verify that the compressed file
has been created, and the related FIM event includes the 'content_changes' field if the
value size does not exceed the specified limit and vice versa.

wazuh_min_version: 4.2.0

parameters:
- key:
type: str
brief: Path of the registry root key (HKEY_* constants).
- subkey:
type: str
brief: The registry key being monitored by syscheck.
- arch:
type: str
brief: Architecture of the registry.
- value_name:
type: str
brief: Name of the testing value that will be created
- tags_to_apply:
type: set
brief: Run test if matches with a configuration identifier, skip otherwise.
- get_configuration:
type: fixture
brief: Get configurations from the module.
- configure_environment:
type: fixture
brief: Configure a custom environment for testing.
- restart_syscheckd:
type: fixture
brief: Clear the 'ossec.log' file and start a new monitor.
- wait_for_fim_start:
type: fixture
brief: Wait for realtime start, whodata start, or end of initial FIM scan.

assertions:
- Verify that a 'diff' file is created when a monitored value does not exceed the size limit.
- Verify that no 'diff' file is created when a monitored value exceeds the size limit.
- Verify that FIM events include the 'content_changes' field when the monitored value
does not exceed the size limit.

input_description: A test case (test_diff_size_limit) is contained in external YAML file
(wazuh_registry_report_changes_limits_quota.yaml) which includes
configuration settings for the 'wazuh-syscheckd' daemon. That is
combined with the testing registry keys to be monitored defined
in this module.

expected_output:
- r'.*Sending FIM event: (.+)$' ('added', 'modified', and 'deleted' events)

tags:
- scheduled
- time_travel
'''
check_apply_test(tags_to_apply, get_configuration['tags'])
value_content = generate_string(size, '0')
values = {value_name: value_content}
Expand Down
Loading