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

System Tests: FIM - Synchronization process #2443

Merged
merged 28 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2fdf85d
Added new provisioning test
CamiRomero Jan 3, 2022
77fa96c
Update function to return log
CamiRomero Jan 6, 2022
9f431e1
Update ossec.conf on manager and agent
CamiRomero Jan 6, 2022
bf49a66
Update local internal options on manager and agent
CamiRomero Jan 6, 2022
41b8485
add new system test to check fim synchronization
CamiRomero Jan 6, 2022
924b4c4
Add new file to check manager messages
CamiRomero Jan 10, 2022
a5a6dea
add test to README
CamiRomero Jan 13, 2022
6f638b3
Change frecuency that syscheck is executed
CamiRomero Jan 13, 2022
be81095
Add test to chec FIM synchronization
CamiRomero Jan 13, 2022
2413d0b
Add: Add PR https:/wazuh/wazuh-qa/pull/2443 to changelog
CamiRomero Jan 24, 2022
2c97b0a
Add: add documentation
CamiRomero Jan 24, 2022
5972a00
Add new file to define the common functions on fim test
CamiRomero Jan 24, 2022
79d0517
Remove unnecessary try-finally
CamiRomero Jan 24, 2022
d75a7f8
Modify message to search
CamiRomero Jan 24, 2022
4551cb7
Rename test folder
CamiRomero Jan 25, 2022
ef1fa74
Parametrize test with case: add, modify, delete
CamiRomero Jan 25, 2022
3e8010c
Rename name of test
CamiRomero Jan 25, 2022
8f919fe
remove unnecesary yml
CamiRomero Jan 25, 2022
c136ea8
Remove old files
CamiRomero Jan 25, 2022
15064ae
Remove assets files
CamiRomero Jan 25, 2022
7f24edb
Replace common.py to __init_
CamiRomero Jan 26, 2022
91ef441
Replace clean log for clean environment
CamiRomero Jan 27, 2022
0f4c912
Merge branch 'master' into 2389-System-test-for-fim-synchronization-p…
CamiRomero Jan 28, 2022
5de9366
Update CHANGELOG.md
CamiRomero Jan 28, 2022
2622cb3
Add documentation in order to respect Schema 2.0
CamiRomero Feb 2, 2022
bb6ab84
Merge branch '2389-System-test-for-fim-synchronization-process' of gi…
CamiRomero Feb 2, 2022
7472d51
Changed tier 1 to tier 0
CamiRomero Feb 3, 2022
6e63fb5
remove unnecessary lines
CamiRomero Feb 3, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Release report: https:/wazuh/wazuh-qa/issues/2500
### Added

- Added specific version of libcst to install in python lower than 3.7. ([#2459](https:/wazuh/wazuh-qa/pull/2459))
- Add system test to check synchronization between agent and manager. ([#2443](https:/wazuh/wazuh-qa/pull/2443))
- Make `simulate-api-load` CLI run tasks simultaneously. ([#2392](https:/wazuh/wazuh-qa/pull/2392))
- Add `qa-ctl` `v0.3`. ([#2307](https:/wazuh/wazuh-qa/pull/2307))
- Add `qa-ctl` `v0.2`. ([#2299](https:/wazuh/wazuh-qa/pull/2299))
Expand Down
1 change: 1 addition & 0 deletions deps/wazuh_testing/wazuh_testing/tools/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ def run(self):
break
time.sleep(self._time_step)
self.check_result()
return self.result()

@new_process
def file_composer(self, host, path, output_path):
Expand Down
1 change: 0 additions & 1 deletion deps/wazuh_testing/wazuh_testing/tools/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,3 @@ def clean_environment(host_manager, target_files):
"""
for target in target_files:
host_manager.clear_file(host=target[0], file_path=target[1])

1 change: 1 addition & 0 deletions tests/system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ required an specific testing environment located in `wazuh-qa/tests/system/provi
| test_cluster/test_integrity_sync | agentless_cluster |
| test_jwt_invalidation | agentless_cluster |
| test_active_response_log_format | manager_agent |
| test_fim/test_synchronization | one_manager_agent |

### Test structure

Expand Down
12 changes: 12 additions & 0 deletions tests/system/provisioning/one_manager_agent/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[defaults]
hash_behaviour = replace
gather_timeout = 300
stdout_callback = yaml
callback_whitelist = profile_tasks, timer
timeout = 60
log_path = ./ansible.log

[ssh_connection]
ssh_args = -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
pipelining = True
retries = 10
10 changes: 10 additions & 0 deletions tests/system/provisioning/one_manager_agent/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- hosts: localhost
tasks:
- docker_container:
name: wazuh-manager
state: absent
force_kill: yes
- docker_container:
name: wazuh-agent1
state: absent
force_kill: yes
8 changes: 8 additions & 0 deletions tests/system/provisioning/one_manager_agent/inventory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
all:
hosts:
wazuh-manager:
ansible_connection: docker
ansible_python_interpreter: python
wazuh-agent1:
ansible_connection: docker
ansible_python_interpreter: python
48 changes: 48 additions & 0 deletions tests/system/provisioning/one_manager_agent/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
- name: Create our container (Manager)
hosts: localhost
vars_files:
- ./vars/configurations.yml
tasks:
- name: Create a network
docker_network:
name: "{{ docker_network }}"
- docker_container:
name: "{{ manager_hostname }}"
image: "{{ image }}"
hostname: "{{ manager_hostname }}"
networks:
- name: "{{ docker_network }}"

- name: Create our container (Agent1)
hosts: localhost
vars_files:
- ./vars/configurations.yml
tasks:
- docker_container:
name: "{{ agent1_hostname }}"
image: "{{ image }}"
hostname: "{{ agent1_hostname }}"
networks:
- name: "{{ docker_network }}"

- name: Wazuh Manager
hosts: wazuh-manager
vars:
master_hostname: "wazuh-manager"
vars_files:
- ./vars/configurations.yml
roles:
- name: "roles/manager-role"

- name: Wazuh Agent1
hosts: wazuh-agent1
vars:
manager_hostname: wazuh-manager
agent_id: "{{ agent1_id }}"
agent_hostname: "{{ agent1_hostname }}"
agent_key: "{{ agent1_key }}"
vars_files:
- ./vars/configurations.yml
roles:
- name: "roles/agent-role"
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<!--
Wazuh - Agent - Default configuration for debian 10
More info at: https://documentation.wazuh.com
Mailing list: https://groups.google.com/forum/#!forum/wazuh
-->

<ossec_config>
<client>
<server>
<address>MANAGER_IP</address>
<port>1514</port>
<protocol>tcp</protocol>
</server>
<config-profile>debian, debian10</config-profile>
<notify_time>10</notify_time>
<time-reconnect>60</time-reconnect>
<auto_restart>yes</auto_restart>
<crypto_method>aes</crypto_method>
</client>

<client_buffer>
<!-- Agent buffer options -->
<disabled>no</disabled>
<queue_size>5000</queue_size>
<events_per_second>500</events_per_second>
</client_buffer>


<!-- File integrity monitoring -->
<syscheck>
<disabled>no</disabled>

<!-- Frequency that syscheck is executed default every 12 hours -->
<frequency>60</frequency>

<scan_on_start>yes</scan_on_start>

<!-- Directories to check (perform all possible verifications) -->
<directories check_all="yes">/etc,/usr/bin,/usr/sbin</directories>
<directories check_all="yes">/bin,/sbin,/boot</directories>
<directories check_all="yes">/testdir1</directories>
<directories check_all="yes" realtime="yes">/testdir2</directories>
<directories check_all="yes" whodata="yes">/testdir3</directories>

<!-- Files/directories to ignore -->
<ignore>/etc/mtab</ignore>
<ignore>/etc/hosts.deny</ignore>
<ignore>/etc/mail/statistics</ignore>
<ignore>/etc/random-seed</ignore>
<ignore>/etc/random.seed</ignore>
<ignore>/etc/adjtime</ignore>
<ignore>/etc/httpd/logs</ignore>
<ignore>/etc/utmpx</ignore>
<ignore>/etc/wtmpx</ignore>
<ignore>/etc/cups/certs</ignore>
<ignore>/etc/dumpdates</ignore>
<ignore>/etc/svc/volatile</ignore>
<ignore>/sys/kernel/security</ignore>
<ignore>/sys/kernel/debug</ignore>
<ignore>/dev/core</ignore>

<!-- File types to ignore -->
<ignore type="sregex">^/proc</ignore>
<ignore type="sregex">.log$|.swp$</ignore>

<!-- Check the file, but never compute the diff -->
<nodiff>/etc/ssl/private.key</nodiff>

<skip_nfs>yes</skip_nfs>
</syscheck>

<!-- Log analysis -->
<localfile>
<log_format>syslog</log_format>
<location>/var/ossec/logs/active-responses.log</location>
</localfile>

<localfile>
<log_format>syslog</log_format>
<location>/var/log/secure</location>
</localfile>

<!-- Choose between "plain", "json", or "plain,json" for the format of internal logs -->
<logging>
<log_format>plain</log_format>
</logging>

</ossec_config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
- name: "Check and update debian repositories"
shell:
cmd: apt-get update --allow-releaseinfo-change

- name: "Installing dependencies using apt"
apt:
pkg:
- git
- gcc
- make
- cmake
- libc6-dev
- curl
- policycoreutils
- automake
- autoconf
- libtool
- python3-pytest
force_apt_get: yes
state: present
update_cache: yes
cache_valid_time: 3600

- name: "Clone wazuh repository"
git:
repo: "https:/wazuh/wazuh"
dest: /wazuh
version: "{{ wazuh_branch }}"

- name: Install agent
args:
chdir: /wazuh
creates: /var/ossec
environment:
USER_LANGUAGE: "en"
USER_NO_STOP: "y"
USER_INSTALL_TYPE: "agent"
USER_DIR: "/var/ossec"
USER_ENABLE_EMAIL: "n"
USER_ENABLE_SYSCHECK: "y"
USER_ENABLE_ROOTCHECK: "y"
USER_ENABLE_OPENSCAP: "y"
USER_WHITE_LIST: "n"
USER_ENABLE_SYSLOG: "y"
USER_ENABLE_AUTHD: "y"
USER_AUTO_START: "y"
shell: "./install.sh"

- name: Copy ossec.conf file
copy:
src: ../files/ossec.conf
dest: /var/ossec/etc/ossec.conf
owner: ossec
mode: '0644'

- name: Remove client.keys
file:
path: /var/ossec/etc/client.keys
state: absent

- name: Register agents
lineinfile:
path: /var/ossec/etc/client.keys
line: "{{ agent_id }} {{agent_hostname}} any {{ agent_key }}"
owner: ossec
mode: "0644"
create: yes

- name: Set Wazuh Manager IP
lineinfile:
path: /var/ossec/etc/ossec.conf
regexp: '<address>(.*)</address>'
line: "<address>{{ manager_hostname }}</address>"
backrefs: yes

- name: enable debug mode
blockinfile:
path: /var/ossec/etc/local_internal_options.conf
block: |
syscheck.debug=2

- name: Restart Wazuh
command: /var/ossec/bin/wazuh-control restart
Loading