Skip to content

Commit dcb9d90

Browse files
authored
Merge pull request #622 from wazuh/438-review-of-pipelines-executed-after-push
Test Wazuh module when pull changes
2 parents a8caba4 + ca3107a commit dcb9d90

File tree

18 files changed

+258
-166
lines changed

18 files changed

+258
-166
lines changed

.github/actions/test_manager_and_agent/Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/actions/test_manager_and_agent/action.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/actions/test_manager_and_agent/entrypoint.sh

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/actions/validate_module/Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/actions/validate_module/action.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/actions/validate_module/entrypoint.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/configure/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
runs:
2+
using: "composite"
3+
steps:
4+
- name: Configure puppet server
5+
shell: bash
6+
run: |
7+
echo "[main]" | sudo tee -a /etc/puppetlabs/puppet/puppet.conf > /dev/null
8+
echo "server = "$HOSTNAME | sudo tee -a /etc/puppetlabs/puppet/puppet.conf > /dev/null
9+
echo "dns_alt_names = "$HOSTNAME | sudo tee -a /etc/puppetlabs/puppet/puppet.conf > /dev/null
10+
sudo echo "127.0.0.1 puppet" | sudo tee -a /etc/hosts > /dev/null
11+
sudo cat /etc/puppetlabs/puppet/puppet.conf
12+
13+
- name: Start Puppet Server
14+
shell: bash
15+
run: |
16+
sudo systemctl start puppetserver
17+
sudo systemctl enable puppetserver
18+
sudo systemctl status puppetserver

.github/debian_install/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
runs:
2+
using: "composite"
3+
steps:
4+
- name: Install dependencies
5+
shell: bash
6+
run: |
7+
sudo apt-get update
8+
sudo apt-get install curl apt-transport-https lsb-release wget
9+
10+
- name: Download and Install Puppet server
11+
shell: bash
12+
run: |
13+
wget https://apt.puppet.com/puppet7-release-focal.deb
14+
sudo dpkg -i puppet7-release-focal.deb
15+
sudo apt-get update
16+
sudo apt-get install -y puppetserver
17+
sudo ln -s /opt/puppetlabs/bin/puppet /bin
18+
sudo ln -s /opt/puppetlabs/server/bin/puppetserver /bin

.github/install_stack/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
runs:
2+
using: "composite"
3+
steps:
4+
- name: Create manifest for install Wazuh stack
5+
shell: bash
6+
run: |
7+
hostname=$(sudo puppetserver ca list --all | awk '{if(NR>1)print $1;}')
8+
sudo echo "127.0.0.1 "$hostname | sudo tee -a /etc/hosts > /dev/null
9+
sudo echo "node "\"$hostname\"" {" | sudo tee -a /etc/puppetlabs/code/environments/production/manifests/stack.pp > /dev/null
10+
sudo echo "class {'wazuh::manager':} -> class {'wazuh::indexer':} -> class {'wazuh::filebeat_oss':} -> class {'wazuh::dashboard':}" | sudo tee -a /etc/puppetlabs/code/environments/production/manifests/stack.pp > /dev/null
11+
sudo echo "}" | sudo tee -a /etc/puppetlabs/code/environments/production/manifests/stack.pp > /dev/null
12+
sudo cat /etc/puppetlabs/code/environments/production/manifests/stack.pp
13+
14+
- name: Install Wazuh Stack
15+
shell: bash
16+
run: sudo bash -c 'puppet agent -tod || test $? -eq 2'

.github/tests/action.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
runs:
2+
using: "composite"
3+
steps:
4+
- name: Wait for start Wazuh Cluster
5+
shell: bash
6+
run: sleep 120
7+
8+
- name: Check Wazuh indexer start
9+
shell: bash
10+
run: |
11+
status_green="`curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:admin -k -s | grep green | wc -l`"
12+
if [[ $status_green -eq 1 ]]; then
13+
curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:admin -k -s
14+
else
15+
curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:admin -k -s
16+
exit 1
17+
fi
18+
status_index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:admin -k -s | wc -l`"
19+
status_index_green="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:admin -k -s | grep "green" | wc -l`"
20+
if [[ $status_index_green -eq $status_index ]]; then
21+
curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:admin -k -s
22+
else
23+
curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:admin -k -s
24+
exit 1
25+
fi
26+
27+
- name: Check Wazuh indexer nodes
28+
shell: bash
29+
run: |
30+
nodes="`curl -XGET "https://0.0.0.0:9200/_cat/nodes" -u admin:admin -k -s | wc -l`"
31+
if [[ $nodes -eq 1 ]]; then
32+
echo "Wazuh indexer nodes: ${nodes}"
33+
else
34+
echo "Wazuh indexer nodes: ${nodes}"
35+
exit 1
36+
fi
37+
38+
- name: Check documents into wazuh-alerts index
39+
shell: bash
40+
run: |
41+
docs="`curl -XGET "https://0.0.0.0:9200/wazuh-alerts*/_doc/_search" -u admin:admin -k -s | jq -r ".hits.total.value"`"
42+
if [[ $docs -gt 100 ]]; then
43+
echo "wazuh-alerts index documents: ${docs}"
44+
else
45+
echo "wazuh-alerts index documents: ${docs}"
46+
exit 1
47+
fi
48+
49+
- name: Check Wazuh templates
50+
shell: bash
51+
run: |
52+
qty_templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:admin -k -s | grep -P "wazuh|wazuh-agent|wazuh-statistics" | wc -l`"
53+
templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:admin -k -s | grep -P "wazuh|wazuh-agent|wazuh-statistics"`"
54+
if [[ $qty_templates -eq 3 ]]; then
55+
echo "wazuh templates:"
56+
echo "${templates}"
57+
else
58+
echo "wazuh templates:"
59+
echo "${templates}"
60+
exit 1
61+
fi
62+
63+
- name: Check Wazuh manager start
64+
shell: bash
65+
run: |
66+
services="`curl -k -s -X GET "https://0.0.0.0:55000/manager/status?pretty=true" -H "Authorization: Bearer ${{env.TOKEN}}" | jq -r .data.affected_items | grep running | wc -l`"
67+
if [[ $services -gt 9 ]]; then
68+
echo "Wazuh Manager Services: ${services}"
69+
echo "OK"
70+
else
71+
echo "Wazuh indexer nodes: ${nodes}"
72+
curl -k -X GET "https://0.0.0.0:55000/manager/status?pretty=true" -H "Authorization: Bearer ${{env.TOKEN}}" | jq -r .data.affected_items
73+
exit 1
74+
fi
75+
env:
76+
TOKEN: $(curl -s -u wazuh-wui:wazuh-wui -k -X GET "https://0.0.0.0:55000/security/user/authenticate?raw=true")
77+
78+
- name: Check Wazuh dashboard service URL
79+
shell: bash
80+
run: |
81+
status=$(curl -XGET --silent https://0.0.0.0:443/app/status -k -u admin:admin -I -s | grep -E "^HTTP" | awk '{print $2}')
82+
if [[ $status -eq 200 ]]; then
83+
echo "Wazuh dashboard status: ${status}"
84+
else
85+
echo "Wazuh dashboard status: ${status}"
86+
exit 1
87+
fi
88+
89+
- name: Check Errors in ossec.log
90+
shell: bash
91+
run: |
92+
log=$(sudo awk 'BEGIN{IGNORECASE=1} /ERROR|CRITICAL/' /var/ossec/logs/ossec.log)
93+
if [[ -z "$log" ]]; then
94+
echo "No errors in ossec.log"
95+
else
96+
echo "Errors in ossec.log:"
97+
echo "${log}"
98+
exit 1
99+
fi
100+
101+
- name: Check Errors from filebeat
102+
shell: bash
103+
run: |
104+
filebeatout=$(sudo filebeat test output)
105+
filebeatstatus=$(echo "${filebeatout}" | grep -c OK)
106+
if [[ filebeatstatus -eq 7 ]]; then
107+
echo "No errors in filebeat"
108+
else
109+
echo "Errors in filebeat"
110+
echo "${filebeatout}"
111+
exit 1
112+
fi

0 commit comments

Comments
 (0)