wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
64 stars 30 forks source link

Add integration tests to the developed Security Lake implementation #4055

Closed mateojames closed 1 month ago

mateojames commented 1 year ago
Development branch
4055-aws-asl-integration-tests

Following the https://github.com/wazuh/wazuh/issues/16326 epic, this task aims to develop integrations tests to the https://github.com/wazuh/wazuh/issues/16407.

For the completion of this issue we must ensure to:

mateojames commented 1 year ago

Issue Update

To do the testing I have a manager running Ubuntu in a Docker container, where the branch feature/16407-amazon-sec-lake-dev was cloned from the wazuh repository and installed. In the container I have also cloned the 3333-aws-integration-tests branch from wazuh-qa repository and have installed Vagrant for the management of VMs. Some errors were found.

🔴 Installation of the requirements error ``` root@wazuh-master:/home/wazuh-qa# python3 -m pip install -r requirements.txt Ignoring pytest: markers 'python_version >= "3.10"' don't match your environment Ignoring jq: markers '(platform_system == "Linux" or platform_system == "Darwin") and python_version >= "3.10"' don't match your environment Ignoring wmi: markers 'platform_system == "Windows"' don't match your environment Ignoring libcst: markers 'python_version <= "3.6"' don't match your environment ... Successfully built configobj grpcio netifaces psutil pyyaml jq treelib pybitbucket-fork progress docopt ordered-set future ERROR: grpcio-status 1.53.0 has requirement protobuf>=4.21.6, but you'll have protobuf 3.20.3 which is incompatible. ERROR: python-daemon 3.0.1 has requirement setuptools>=62.4.0, but you'll have setuptools 56.0.0 which is incompatible. Installing collected packages: six, configobj, certifi, pycparser, cffi, cycler, bcrypt, distro, filetype, python-dateutil, freezegun, grpcio, cachetools, pyasn1, rsa, pyasn1-modules, google-auth, urllib3, charset-normalizer, idna, requests, protobuf, googleapis-common-protos, grpcio-status, google-api-core, typing-extensions, pyyaml, mypy-extensions, typing-inspect, libcst, proto-plus, grpc-google-iam-v1, google-cloud-pubsub, setuptools, pyrsistent, attrs, jsonschema, kiwisolver, lockfile, pillow, numpy, contourpy, pyparsing, fonttools, zipp, importlib-resources, packaging, matplotlib, netifaces, pytz, tzdata, pandas, psutil, py, pycryptodome, cryptography, pyOpenSSL, iniconfig, pluggy, toml, pytest, pytest-metadata, pytest-html, scipy, seaborn, testinfra, jq, MarkupSafe, Jinja2, sphinxcontrib-devhelp, docutils, imagesize, sphinxcontrib-applehelp, importlib-metadata, babel, sphinxcontrib-htmlhelp, sphinxcontrib-qthelp, Pygments, snowballstemmer, sphinxcontrib-jsmath, sphinxcontrib-serializinghtml, alabaster, sphinx, numpydoc, python-daemon, ptyprocess, pexpect, ansible-runner, websocket-client, docker, python-vagrant, resolvelib, ansible-core, ansible, elastic-transport, elasticsearch, Click, dparse, safety, pbr, stevedore, smmap, gitdb, GitPython, bandit, future, oauthlib, requests-oauthlib, simplejson, uritemplate, voluptuous, pybitbucket-fork, uritemplate.py, github3.py, requests-toolbelt, python-gitlab, progress, docopt, gogs-client, lxml, git-repo, xmltodict, pyspnego, requests-ntlm, pywinrm, ordered-set, deepdiff, treelib, wcwidth, prettytable, mysql-connector-python Attempting uninstall: setuptools Found existing installation: setuptools 45.2.0 Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr Can't uninstall 'setuptools'. No files were found to uninstall. ```
🔴 Running a test to confirm a successful environment was deployed ``` ------------------------------------------------------------------------------------------------- Captured log setup ------------------------------------------------------------------------------------------------- DEBUG wazuh_testing:conftest.py:629 Set local_internal_option to {'wazuh_modules.debug': '2', 'monitord.rotate_log': '0'} ------------------------------------------------------------------------------------------------ Captured stderr call ------------------------------------------------------------------------------------------------ 2023-04-17 19:12:36,016 - wazuh_testing - ERROR - ('The AWS module did not show the correct message about discard regex or ', 'did not process the expected amount of logs') 2023-04-17 19:12:36,018 - wazuh_testing - ERROR - Results accumulated: 0 2023-04-17 19:12:36,018 - wazuh_testing - ERROR - Results expected: 6 ------------------------------------------------------------------------------------------------- Captured log call -------------------------------------------------------------------------------------------------- ERROR wazuh_testing:monitoring.py:465 ('The AWS module did not show the correct message about discard regex or ', 'did not process the expected amount of logs') ERROR wazuh_testing:monitoring.py:466 Results accumulated: 0 ERROR wazuh_testing:monitoring.py:468 Results expected: 6 ---------------------------------------------------------------------------------------------- Captured stdout teardown ---------------------------------------------------------------------------------------------- wazuh-clusterd not running... Killing wazuh-modulesd... Killing wazuh-monitord... Killing wazuh-logcollector... Killing wazuh-remoted... Killing wazuh-syscheckd... Killing wazuh-analysisd... wazuh-maild not running... Killing wazuh-execd... Killing wazuh-db... Killing wazuh-authd... wazuh-agentlessd not running... wazuh-integratord not running... wazuh-dbd not running... wazuh-csyslogd not running... Killing wazuh-apid... Wazuh v4.4.1 Stopped ---------------------------------------------------------------------------------------------- Captured stderr teardown ---------------------------------------------------------------------------------------------- 2023-04-17 19:12:38,903 - wazuh_testing - DEBUG - Restore local_internal_option to {} ----------------------------------------------------------------------------------------------- Captured log teardown ------------------------------------------------------------------------------------------------ DEBUG wazuh_testing:conftest.py:634 Restore local_internal_option to {} ============================================================================================== short test summary info =============================================================================================== FAILED test_aws/test_discard_regex.py::test_discard_regex[cloudtrail_discard_regex] - TimeoutError: ('The AWS module did not show the correct message about discard regex or ', 'did not process the expected amoun... !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! =============================================================================== 1 failed, 1 passed, 180 deselected in 63.32s (0:01:03) =============================================================================== root@wazuh-master:/home/wazuh-qa/tests/integration# ```

Further investigation is required.

mateojames commented 1 year ago

Amazon Security Lake Test Cases

Tier 0

mateojames commented 1 year ago

Issue Update

Some integration tests still need to be defined, such as:

mateojames commented 1 year ago

Issue Update

The subscriber section for Tier 0 testing was added to the test_basic, still in development process

fdalmaup commented 1 year ago

Issue Update

To maintain consistency between the different already developed integration tests of the module, and because the iam_role_duration, sts_endpoint, and service_endpoint parameters do not generate a fundamental modification of the behavior of the module, no tests will be developed that make use of the same.

Also, the parser integration tests added in https://github.com/wazuh/wazuh-qa/pull/3882 will be expanded in order to contemplate the new <subscriber> section and its inner fields.

fdalmaup commented 1 year ago

Issue Update

The current Integration Tests structure has been reviewed to understand better how the Security Lake tests should be developed.

Since the objective of these tests is not the generation of the Security Lake itself but the interaction with the principal components available when setting up a Data Access Subscription, we should have an environment with the following services available for the test account:

While the needed permissions to handle these services are being required, the Subscriber Parser Integration tests are being developed.

fdalmaup commented 1 year ago

Issue Update

The base test which needs the previously mentioned AWS services, will be added to test_basic.py.

In the meantime, the test_parser.py is being updated with ASL integration cases, which are:

fdalmaup commented 1 year ago

Issue Update

New test cases have been checked for the Parser tests:

Developed with the current implementation:

May require modifications of the module at a C and/or script level

Selutario commented 4 months ago

Moving to on hold as the tests migration is almost ready.

fdalmaup commented 2 months ago

The issue will be resumed once higher-priority issues are done.

fdalmaup commented 1 month ago

Due to the changes planned for version 5.0, the analysis that is being carried out regarding the External integrations modules, the team's efforts for improvements will be directed to the mentioned version.