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

Fix manager configuration validation #16357

Open
wants to merge 5 commits into
base: 4.4
Choose a base branch
from

Conversation

GGP1
Copy link
Member

@GGP1 GGP1 commented Mar 9, 2023

Related issue
Closes #16341

Description

During the validation of configuration files (ossec.conf), non-xml formatted data was accepted.

Expected behavior

Return an error and not allow the users to save invalid content to the configuration file.

Steps to reproduce

UI steps:

  • Log in to the dashboard
  • Switch to Management → Configuration
  • Edit configuration: put some malformed data inside the form (non-xml, see examples).
  • Save the configuration - no error.

Similarly, we could reproduce the issue using the API by submitting the same payload inside the body of a PUT request to the endpoint /manager/configuration.

Logs/Alerts example

The following content was considered valid:

{"body": {"<ossec_config></ossec_config>"}}

Tests

====================================== test session starts ======================================
platform linux -- Python 3.9.16, pytest-7.0.1, pluggy-1.0.0
rootdir: /home/gasti/work/wazuh/framework
plugins: anyio-3.6.2, asyncio-0.18.1
asyncio: mode=legacy
collected 2045 items                                                                            

framework/scripts/tests/test_agent_groups.py ..............                               [  0%]
framework/scripts/tests/test_agent_upgrade.py ...............                             [  1%]
framework/scripts/tests/test_cluster_control.py ......                                    [  1%]
framework/scripts/tests/test_wazuh_clusterd.py .......                                    [  2%]
framework/scripts/tests/test_wazuh_logtest.py ......................                      [  3%]
framework/wazuh/core/cluster/dapi/tests/test_dapi.py ..............................ss     [  4%]
framework/wazuh/core/cluster/tests/test_client.py ................                        [  5%]
framework/wazuh/core/cluster/tests/test_cluster.py ..........................ss.......    [  7%]
framework/wazuh/core/cluster/tests/test_common.py ....................................... [  9%]
....................................                                                      [ 10%]
framework/wazuh/core/cluster/tests/test_control.py ......                                 [ 11%]
framework/wazuh/core/cluster/tests/test_local_client.py .......ss....                     [ 11%]
framework/wazuh/core/cluster/tests/test_local_server.py ........................          [ 12%]
framework/wazuh/core/cluster/tests/test_master.py ....................................... [ 14%]
......                                                                                    [ 15%]
framework/wazuh/core/cluster/tests/test_server.py ...................                     [ 16%]
framework/wazuh/core/cluster/tests/test_utils.py ...........                              [ 16%]
framework/wazuh/core/cluster/tests/test_worker.py ....................................    [ 18%]
framework/wazuh/core/tests/test_active_response.py ..............                         [ 19%]
framework/wazuh/core/tests/test_agent.py ................................................ [ 21%]
......................................................................................... [ 25%]
.......                                                                                   [ 26%]
framework/wazuh/core/tests/test_cdb_list.py ......................................        [ 27%]
framework/wazuh/core/tests/test_common.py .......                                         [ 28%]
framework/wazuh/core/tests/test_configuration.py ........................................ [ 30%]
..............................                                                            [ 31%]
framework/wazuh/core/tests/test_database.py .............                                 [ 32%]
framework/wazuh/core/tests/test_decoder.py ................                               [ 33%]
framework/wazuh/core/tests/test_exception.py ...                                          [ 33%]
framework/wazuh/core/tests/test_input_validator.py ...                                    [ 33%]
framework/wazuh/core/tests/test_logtest.py ..                                             [ 33%]
framework/wazuh/core/tests/test_manager.py ...............                                [ 34%]
framework/wazuh/core/tests/test_mitre.py .............                                    [ 34%]
framework/wazuh/core/tests/test_pyDaemonModule.py .....                                   [ 35%]
framework/wazuh/core/tests/test_results.py ........................................       [ 37%]
framework/wazuh/core/tests/test_rootcheck.py .............                                [ 37%]
framework/wazuh/core/tests/test_rule.py ......................                            [ 38%]
framework/wazuh/core/tests/test_sca.py ........................                           [ 40%]
framework/wazuh/core/tests/test_security.py ............                                  [ 40%]
framework/wazuh/core/tests/test_stats.py .................                                [ 41%]
framework/wazuh/core/tests/test_syscheck.py .......                                       [ 41%]
framework/wazuh/core/tests/test_syscollector.py ...                                       [ 41%]
framework/wazuh/core/tests/test_task.py ........                                          [ 42%]
framework/wazuh/core/tests/test_utils.py ................................................ [ 44%]
......................................................................................... [ 48%]
......................................................................................... [ 53%]
.............                                                                             [ 53%]
framework/wazuh/core/tests/test_vulnerability.py ..                                       [ 54%]
framework/wazuh/core/tests/test_wazuh_queue.py ....................                       [ 55%]
framework/wazuh/core/tests/test_wazuh_socket.py ....................                      [ 56%]
framework/wazuh/core/tests/test_wdb.py .s.ssssss......................                    [ 57%]
framework/wazuh/core/tests/test_wlogging.py .........                                     [ 57%]
framework/wazuh/rbac/tests/test_auth_context.py ..                                        [ 58%]
framework/wazuh/rbac/tests/test_decorators.py ........................................... [ 60%]
..................................................................                        [ 63%]
framework/wazuh/rbac/tests/test_default_configuration.py ................................ [ 64%]
........................                                                                  [ 66%]
framework/wazuh/rbac/tests/test_orm.py .................................................. [ 68%]
....                                                                                      [ 68%]
framework/wazuh/rbac/tests/test_preprocessor.py ...........                               [ 69%]
framework/wazuh/tests/test_active_response.py ............                                [ 69%]
framework/wazuh/tests/test_agent.py ..................................................... [ 72%]
.................................................................                         [ 75%]
framework/wazuh/tests/test_cdb_list.py .................................................. [ 78%]
...                                                                                       [ 78%]
framework/wazuh/tests/test_ciscat.py .................................                    [ 79%]
framework/wazuh/tests/test_cluster.py ..........                                          [ 80%]
framework/wazuh/tests/test_decoder.py ...................................                 [ 82%]
framework/wazuh/tests/test_group.py .......                                               [ 82%]
framework/wazuh/tests/test_logtest.py ......                                              [ 82%]
framework/wazuh/tests/test_manager.py ....................................                [ 84%]
framework/wazuh/tests/test_mitre.py .......                                               [ 84%]
framework/wazuh/tests/test_rootcheck.py ................................................. [ 87%]
.                                                                                         [ 87%]
framework/wazuh/tests/test_rule.py ...................................................... [ 89%]
..                                                                                        [ 90%]
framework/wazuh/tests/test_sca.py ...........                                             [ 90%]
framework/wazuh/tests/test_security.py .................................................. [ 93%]
.......................                                                                   [ 94%]
framework/wazuh/tests/test_stats.py ...............                                       [ 94%]
framework/wazuh/tests/test_syscheck.py .........................                          [ 96%]
framework/wazuh/tests/test_syscollector.py ............                                   [ 96%]
framework/wazuh/tests/test_task.py ............................                           [ 98%]
framework/wazuh/tests/test_vulnerability.py ........................................      [100%]

=================== 2032 passed, 13 skipped, 79 warnings in 213.41s (0:03:33) ===================

I ran the tests in api/api just in case and they all pass as well.

  • Compilation without warnings in every supported platform
    • Linux
    • Windows
    • MAC OS X
  • Source installation
  • Package installation
  • Source upgrade
  • Package upgrade
  • Review logs syntax and correct language
  • QA templates contemplate the added capabilities
  • Memory tests for Linux
    • Scan-build report
    • Coverity
    • Valgrind (memcheck and descriptor leaks check)
    • Dr. Memory
    • AddressSanitizer
  • Memory tests for Windows
    • Scan-build report
    • Coverity
    • Dr. Memory
  • Memory tests for macOS
    • Scan-build report
    • Leaks
    • AddressSanitizer
  • Retrocompatibility with older Wazuh versions
  • Working on cluster environments
  • Configuration on demand reports new parameters
  • The data flow works as expected (agent-manager-api-app)
  • Added unit tests (for new features)
  • Stress test for affected components
  • Decoder/Rule tests
    • Added unit testing files ".ini"
    • runtests.py executed without errors

@GGP1 GGP1 self-assigned this Mar 9, 2023
@GGP1 GGP1 added type/bug Something isn't working module/framework labels Mar 9, 2023
@GGP1 GGP1 changed the title Fix XML tree validation Fix manager configuration validation Mar 9, 2023
@GGP1 GGP1 force-pushed the fix/16341-api-config-validation branch from b658f78 to d540a8f Compare March 13, 2023 11:25
@GGP1 GGP1 changed the base branch from master to 4.4.1 March 13, 2023 11:30
@Selutario Selutario self-requested a review March 13, 2023 12:16
framework/wazuh/core/tests/test_utils.py Outdated Show resolved Hide resolved
framework/wazuh/core/tests/test_utils.py Outdated Show resolved Hide resolved
@GGP1 GGP1 changed the base branch from 4.4.1 to 4.4 March 31, 2023 14:55
@GGP1 GGP1 force-pushed the fix/16341-api-config-validation branch from 9c5f5d5 to 18c8870 Compare March 31, 2023 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/api type/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration update accepting invalid format
3 participants