Aucune description

push.yml 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. name: Wazuh Docker pipeline
  2. on: [pull_request]
  3. jobs:
  4. build-docker-images:
  5. runs-on: ubuntu-22.04
  6. steps:
  7. - name: Check out code
  8. uses: actions/checkout@v4
  9. - name: Build Wazuh images
  10. run: ./build-images.sh
  11. working-directory: ./build-docker-images
  12. - name: Create enviroment variables
  13. run: cat .env > $GITHUB_ENV
  14. - name: Create backup Docker images
  15. run: |
  16. mkdir -p /home/runner/work/wazuh-docker/wazuh-docker/docker-images/
  17. docker save wazuh/wazuh-manager:${{env.WAZUH_IMAGE_VERSION}} -o /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-manager.tar
  18. docker save wazuh/wazuh-indexer:${{env.WAZUH_IMAGE_VERSION}} -o /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-indexer.tar
  19. docker save wazuh/wazuh-dashboard:${{env.WAZUH_IMAGE_VERSION}} -o /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-dashboard.tar
  20. docker save wazuh/wazuh-agent:${{env.WAZUH_IMAGE_VERSION}} -o /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-agent.tar
  21. - name: Temporarily save Wazuh manager Docker image
  22. uses: actions/upload-artifact@v4
  23. with:
  24. name: docker-artifact-manager
  25. path: /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-manager.tar
  26. retention-days: 1
  27. - name: Temporarily save Wazuh indexer Docker image
  28. uses: actions/upload-artifact@v4
  29. with:
  30. name: docker-artifact-indexer
  31. path: /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-indexer.tar
  32. retention-days: 1
  33. - name: Temporarily save Wazuh dashboard Docker image
  34. uses: actions/upload-artifact@v4
  35. with:
  36. name: docker-artifact-dashboard
  37. path: /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-dashboard.tar
  38. retention-days: 1
  39. - name: Temporarily save Wazuh agent Docker image
  40. uses: actions/upload-artifact@v4
  41. with:
  42. name: docker-artifact-agent
  43. path: /home/runner/work/wazuh-docker/wazuh-docker/docker-images/wazuh-agent.tar
  44. retention-days: 1
  45. - name: Install Goss
  46. uses: e1himself/goss-installation-action@v1.0.3
  47. with:
  48. version: v0.3.16
  49. - name: Execute Goss tests (wazuh-manager)
  50. run: dgoss run wazuh/wazuh-manager:${{env.WAZUH_IMAGE_VERSION}}
  51. env:
  52. GOSS_SLEEP: 30
  53. GOSS_FILE: .github/.goss.yaml
  54. check-single-node:
  55. runs-on: ubuntu-22.04
  56. needs: build-docker-images
  57. steps:
  58. - name: Check out code
  59. uses: actions/checkout@v4
  60. - name: Create enviroment variables
  61. run: cat .env > $GITHUB_ENV
  62. - name: Retrieve saved Wazuh indexer Docker image
  63. uses: actions/download-artifact@v4
  64. with:
  65. name: docker-artifact-indexer
  66. - name: Retrieve saved Wazuh manager Docker image
  67. uses: actions/download-artifact@v4
  68. with:
  69. name: docker-artifact-manager
  70. - name: Retrieve saved Wazuh dashboard Docker image
  71. uses: actions/download-artifact@v4
  72. with:
  73. name: docker-artifact-dashboard
  74. - name: Retrieve saved Wazuh agent Docker image
  75. uses: actions/download-artifact@v4
  76. with:
  77. name: docker-artifact-agent
  78. - name: Docker load
  79. run: |
  80. docker load --input ./wazuh-indexer.tar
  81. docker load --input ./wazuh-dashboard.tar
  82. docker load --input ./wazuh-manager.tar
  83. docker load --input ./wazuh-agent.tar
  84. - name: Create single node certficates
  85. run: docker compose -f single-node/generate-indexer-certs.yml run --rm generator
  86. - name: Start single node stack
  87. run: docker compose -f single-node/docker-compose.yml up -d
  88. - name: Check Wazuh indexer start
  89. run: |
  90. sleep 60
  91. status_green="`curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s | grep green | wc -l`"
  92. if [[ $status_green -eq 1 ]]; then
  93. curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s
  94. else
  95. curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s
  96. exit 1
  97. fi
  98. status_index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s | wc -l`"
  99. status_index_green="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s | grep "green" | wc -l`"
  100. if [[ $status_index_green -eq $status_index ]]; then
  101. curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s
  102. else
  103. curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s
  104. exit 1
  105. fi
  106. - name: Check Wazuh indexer nodes
  107. run: |
  108. nodes="`curl -XGET "https://0.0.0.0:9200/_cat/nodes" -u admin:SecretPassword -k -s | grep -E "indexer" | wc -l`"
  109. if [[ $nodes -eq 1 ]]; then
  110. echo "Wazuh indexer nodes: ${nodes}"
  111. else
  112. echo "Wazuh indexer nodes: ${nodes}"
  113. exit 1
  114. fi
  115. - name: Check documents into wazuh-alerts index
  116. run: |
  117. sleep 120
  118. docs="`curl -XGET "https://0.0.0.0:9200/wazuh-alerts*/_count" -u admin:SecretPassword -k -s | jq -r ".count"`"
  119. if [[ $docs -gt 0 ]]; then
  120. echo "wazuh-alerts index documents: ${docs}"
  121. else
  122. echo "wazuh-alerts index documents: ${docs}"
  123. exit 1
  124. fi
  125. - name: Check Wazuh templates
  126. run: |
  127. qty_templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:SecretPassword -k -s | grep -P "wazuh|wazuh-agent|wazuh-statistics" | wc -l`"
  128. templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:SecretPassword -k -s | grep -P "wazuh|wazuh-agent|wazuh-statistics"`"
  129. if [[ $qty_templates -gt 3 ]]; then
  130. echo "wazuh templates:"
  131. echo "${templates}"
  132. else
  133. echo "wazuh templates:"
  134. echo "${templates}"
  135. exit 1
  136. fi
  137. - name: Check Wazuh manager start
  138. run: |
  139. 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`"
  140. if [[ $services -gt 9 ]]; then
  141. echo "Wazuh Manager Services: ${services}"
  142. echo "OK"
  143. else
  144. echo "Wazuh indexer nodes: ${nodes}"
  145. curl -k -X GET "https://0.0.0.0:55000/manager/status?pretty=true" -H "Authorization: Bearer ${{env.TOKEN}}" | jq -r .data.affected_items
  146. exit 1
  147. fi
  148. env:
  149. TOKEN: $(curl -s -u wazuh-wui:MyS3cr37P450r.*- -k -X GET "https://0.0.0.0:55000/security/user/authenticate?raw=true")
  150. - name: Check filebeat output
  151. run: ./.github/single-node-filebeat-check.sh
  152. - name: Check Wazuh dashboard service URL
  153. run: |
  154. status=$(curl -XGET --silent https://0.0.0.0:443/app/status -k -u admin:SecretPassword -I -s | grep -E "^HTTP" | awk '{print $2}')
  155. if [[ $status -eq 200 ]]; then
  156. echo "Wazuh dashboard status: ${status}"
  157. else
  158. echo "Wazuh dashboard status: ${status}"
  159. exit 1
  160. fi
  161. - name: Modify Docker endpoint into Wazuh agent docker-compose.yml file
  162. run: sed -i "s/<WAZUH_MANAGER_IP>/$(ip addr show docker0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)/g" wazuh-agent/docker-compose.yml
  163. - name: Start Wazuh agent
  164. run: docker compose -f wazuh-agent/docker-compose.yml up -d
  165. - name: Check Wazuh agent enrollment
  166. run: |
  167. sleep 20
  168. curl -k -s -X GET "https://localhost:55000/agents?pretty=true" -H "Authorization: Bearer ${{env.TOKEN}}"
  169. env:
  170. TOKEN: $(curl -s -u wazuh-wui:MyS3cr37P450r.*- -k -X GET "https://0.0.0.0:55000/security/user/authenticate?raw=true")
  171. - name: Check errors in ossec.log for Wazuh manager
  172. run: ./.github/single-node-log-check.sh
  173. check-multi-node:
  174. runs-on: ubuntu-22.04
  175. needs: build-docker-images
  176. steps:
  177. - name: Check out code
  178. uses: actions/checkout@v4
  179. - name: Create enviroment variables
  180. run: cat .env > $GITHUB_ENV
  181. - name: free disk space
  182. uses: ./.github/free-disk-space
  183. - name: Retrieve saved Wazuh dashboard Docker image
  184. uses: actions/download-artifact@v4
  185. with:
  186. name: docker-artifact-dashboard
  187. - name: Retrieve saved Wazuh manager Docker image
  188. uses: actions/download-artifact@v4
  189. with:
  190. name: docker-artifact-manager
  191. - name: Retrieve saved Wazuh indexer Docker image
  192. uses: actions/download-artifact@v4
  193. with:
  194. name: docker-artifact-indexer
  195. - name: Retrieve saved Wazuh agent Docker image
  196. uses: actions/download-artifact@v4
  197. with:
  198. name: docker-artifact-agent
  199. - name: Docker load
  200. run: |
  201. docker load --input ./wazuh-manager.tar
  202. docker load --input ./wazuh-indexer.tar
  203. docker load --input ./wazuh-dashboard.tar
  204. docker load --input ./wazuh-agent.tar
  205. rm -rf wazuh-manager.tar wazuh-indexer.tar wazuh-dashboard.tar wazuh-agent.tar
  206. - name: Create multi node certficates
  207. run: docker compose -f multi-node/generate-indexer-certs.yml run --rm generator
  208. - name: Start multi node stack
  209. run: docker compose -f multi-node/docker-compose.yml up -d
  210. - name: Check Wazuh indexer start
  211. run: |
  212. until [[ `curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s | grep green | wc -l` -eq 1 ]]
  213. do
  214. echo 'Waiting for Wazuh indexer start'
  215. free -m
  216. df -h
  217. sleep 120
  218. done
  219. status_green="`curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s | grep green | wc -l`"
  220. if [[ $status_green -eq 1 ]]; then
  221. curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s
  222. else
  223. curl -XGET "https://0.0.0.0:9200/_cluster/health" -u admin:SecretPassword -k -s
  224. exit 1
  225. fi
  226. status_index="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s | wc -l`"
  227. status_index_green="`curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s | grep -E "green" | wc -l`"
  228. if [[ $status_index_green -eq $status_index ]]; then
  229. curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s
  230. else
  231. curl -XGET "https://0.0.0.0:9200/_cat/indices" -u admin:SecretPassword -k -s
  232. exit 1
  233. fi
  234. - name: Check Wazuh indexer nodes
  235. run: |
  236. nodes="`curl -XGET "https://0.0.0.0:9200/_cat/nodes" -u admin:SecretPassword -k -s | grep -E "indexer" | wc -l`"
  237. if [[ $nodes -eq 3 ]]; then
  238. echo "Wazuh indexer nodes: ${nodes}"
  239. else
  240. echo "Wazuh indexer nodes: ${nodes}"
  241. exit 1
  242. fi
  243. - name: Check documents into wazuh-alerts index
  244. run: |
  245. until [[ $(``curl -XGET "https://0.0.0.0:9200/wazuh-alerts*/_count" -u admin:SecretPassword -k -s | jq -r ".count"``) -gt 0 ]]
  246. do
  247. echo 'Waiting for Wazuh indexer events'
  248. free -m
  249. df -h
  250. sleep 10
  251. done
  252. docs="`curl -XGET "https://0.0.0.0:9200/wazuh-alerts*/_count" -u admin:SecretPassword -k -s | jq -r ".count"`"
  253. if [[ $docs -gt 0 ]]; then
  254. echo "wazuh-alerts index documents: ${docs}"
  255. else
  256. echo "wazuh-alerts index documents: ${docs}"
  257. exit 1
  258. fi
  259. - name: Check Wazuh templates
  260. run: |
  261. qty_templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:SecretPassword -k -s | grep "wazuh" | wc -l`"
  262. templates="`curl -XGET "https://0.0.0.0:9200/_cat/templates" -u admin:SecretPassword -k -s | grep "wazuh"`"
  263. if [[ $qty_templates -gt 3 ]]; then
  264. echo "wazuh templates:"
  265. echo "${templates}"
  266. else
  267. echo "wazuh templates:"
  268. echo "${templates}"
  269. exit 1
  270. fi
  271. - name: Check Wazuh manager start
  272. run: |
  273. 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`"
  274. if [[ $services -gt 10 ]]; then
  275. echo "Wazuh Manager Services: ${services}"
  276. echo "OK"
  277. else
  278. echo "Wazuh indexer nodes: ${nodes}"
  279. 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
  280. exit 1
  281. fi
  282. nodes=$(curl -k -s -X GET "https://0.0.0.0:55000/cluster/nodes" -H "Authorization: Bearer ${{env.TOKEN}}" | jq -r ".data.affected_items[].name" | wc -l)
  283. if [[ $nodes -eq 2 ]]; then
  284. echo "Wazuh manager nodes: ${nodes}"
  285. else
  286. echo "Wazuh manager nodes: ${nodes}"
  287. exit 1
  288. fi
  289. env:
  290. TOKEN: $(curl -s -u wazuh-wui:MyS3cr37P450r.*- -k -X GET "https://0.0.0.0:55000/security/user/authenticate?raw=true")
  291. - name: Check filebeat output
  292. run: ./.github/multi-node-filebeat-check.sh
  293. - name: Check Wazuh dashboard service URL
  294. run: |
  295. status=$(curl -XGET --silent https://0.0.0.0:443/app/status -k -u admin:SecretPassword -I | grep -E "^HTTP" | awk '{print $2}')
  296. if [[ $status -eq 200 ]]; then
  297. echo "Wazuh dashboard status: ${status}"
  298. else
  299. echo "Wazuh dashboard status: ${status}"
  300. exit 1
  301. fi
  302. - name: Modify Docker endpoint into Wazuh agent docker-compose.yml file
  303. run: sed -i "s/<WAZUH_MANAGER_IP>/$(ip addr show docker0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)/g" wazuh-agent/docker-compose.yml
  304. - name: Start Wazuh agent
  305. run: docker compose -f wazuh-agent/docker-compose.yml up -d
  306. - name: Check Wazuh agent enrollment
  307. run: |
  308. sleep 20
  309. curl -k -s -X GET "https://localhost:55000/agents?pretty=true" -H "Authorization: Bearer ${{env.TOKEN}}"
  310. env:
  311. TOKEN: $(curl -s -u wazuh-wui:MyS3cr37P450r.*- -k -X GET "https://0.0.0.0:55000/security/user/authenticate?raw=true")
  312. - name: Check errors in ossec.log for Wazuh manager
  313. run: ./.github/multi-node-log-check.sh