diff --git a/.github/workflows/test-script.yml b/.github/workflows/test-script.yml index d04fd17..bf3168c 100644 --- a/.github/workflows/test-script.yml +++ b/.github/workflows/test-script.yml @@ -3,8 +3,51 @@ name: Test install script on: [ push, pull_request ] jobs: - test_script: + test_script_linux: + name: Test install script on Linux ${{ matrix.os }}, ${{ matrix.version }} runs-on: ubuntu-latest + strategy: + matrix: + include: + - os: centos + version: latest + - os: centos + version: 8 + - os: centos + version: 7 + + - os: opensuse + version: latest + - os: opensuse + version: 15 + + - os: ubuntu + version: latest + - os: ubuntu + version: jammy + - os: ubuntu + version: focal + - os: ubuntu + version: noble + + - os: debian + version: latest + - os: debian + version: buster + + - os: alpine + version: latest + - os: alpine + version: edge + - os: alpine + version: 3 + + - os: fedora + version: latest + - os: fedora + version: 41 + - os: fedora + version: 40 steps: - name: Checkout code uses: actions/checkout@v4 @@ -19,6 +62,9 @@ jobs: with: platforms: ${{ steps.qemu.outputs.platforms }} + - name: Pull without cache + run: docker pull ghcr.io/stephane-segning/bats-docker:${{ matrix.os }}-${{ matrix.version }} + - name: Test script run: | - docker run --rm -v "$PWD:/app" bats/bats:latest /app/scripts/tests/test-script.bats + docker run --rm -v "$PWD:/app" ghcr.io/stephane-segning/bats-docker:${{ matrix.os }}-${{ matrix.version }} bats /app/scripts/tests/test-script.bats diff --git a/scripts/tests/README.md b/scripts/tests/README.md index e70afea..53151e5 100644 --- a/scripts/tests/README.md +++ b/scripts/tests/README.md @@ -6,5 +6,5 @@ The BATS framework is used to test the scripts in this project. The tests are wr located in the `scripts/tests` directory. ```bash -docker run --rm -it -v "$PWD:/app" bats/bats:latest /app/scripts/tests/test-script.bats +docker run --rm -it -v "$PWD:/app" ghcr.io/stephane-segning/bats-docker:alpine-latest bats /app/scripts/tests/test-script.bats ``` \ No newline at end of file diff --git a/scripts/tests/setup.sh b/scripts/tests/setup.sh new file mode 100644 index 0000000..5801eb9 --- /dev/null +++ b/scripts/tests/setup.sh @@ -0,0 +1,263 @@ +#!/usr/bin/env sh + +mkdir -p /var/ossec/etc +cat <> /var/ossec/etc/ossec.conf + + + + + yes + yes + no + no + no + smtp.example.wazuh.com + wazuh@example.wazuh.com + recipient@example.wazuh.com + 12 + alerts.log + 10m + 0 + + + + + plain + + + + 3 + 12 + + + + secure + 1514 + tcp + + + + + no + + + 43200 + + /var/ossec/etc/shared/rootkit_files.txt + /var/ossec/etc/shared/rootkit_trojans.txt + + /var/ossec/etc/shared/system_audit_rcl.txt + /var/ossec/etc/shared/system_audit_ssh.txt + /var/ossec/etc/shared/cis_debian_linux_rcl.txt + + yes + + + + yes + 1800 + 1d + yes + + + xccdf_org.ssgproject.content_profile_common + + + + + + no + 1h + yes + yes + yes + yes + + + + 10 + + + + + + no + + + 43200 + + yes + + + yes + + + no + + + /etc,/usr/bin,/usr/sbin + /bin,/sbin,/boot + + + /etc/mtab + /etc/hosts.deny + /etc/mail/statistics + /etc/random-seed + /etc/random.seed + /etc/adjtime + /etc/httpd/logs + /etc/utmpx + /etc/wtmpx + /etc/cups/certs + /etc/dumpdates + /etc/svc/volatile + /sys/kernel/security + /sys/kernel/debug + + + .log$|.swp$ + + + /etc/ssl/private.key + + yes + yes + yes + yes + + + 10 + + + 50 + + + + yes + 5m + 10 + + + + + + 127.0.0.1 + ^localhost.localdomain$ + 10.0.0.2 + + + + disable-account + disable-account + yes + + + + restart-wazuh + restart-wazuh + + + + firewall-drop + firewall-drop + yes + + + + host-deny + host-deny + yes + + + + route-null + route-null + yes + + + + win_route-null + route-null.exe + yes + + + + + + + syslog + /var/ossec/logs/active-responses.log + + + + syslog + /var/log/messages + + + + syslog + /var/log/auth.log + + + + syslog + /var/log/syslog + + + + command + df -P + 360 + + + + full_command + netstat -tan |grep LISTEN |grep -v 127.0.0.1 | sort + 360 + + + + full_command + last -n 5 + 360 + + + + + ruleset/decoders + ruleset/rules + 0215-policy_rules.xml + etc/lists/audit-keys + + + etc/decoders + etc/rules + + + + + no + 1515 + no + yes + no + + no + /var/ossec/etc/sslmanager.cert + /var/ossec/etc/sslmanager.key + no + + + +EOF \ No newline at end of file diff --git a/scripts/tests/test-script.bats b/scripts/tests/test-script.bats index cdfab24..ea773e8 100644 --- a/scripts/tests/test-script.bats +++ b/scripts/tests/test-script.bats @@ -1,27 +1,6 @@ #!/usr/bin/env bats -WAZUH_MANAGER="10.0.0.2" - -if [ "$(uname -o)" = "GNU/Linux" ] && command -v groupadd >/dev/null 2>&1; then - OSSEC_CONF_PATH="/var/ossec/etc/ossec.conf" - apt-get update && apt-get install -y curl gnupg2 - curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import - chmod 644 /usr/share/keyrings/wazuh.gpg - echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list - apt-get update - apt-get install wazuh-agent -y - sed -i "s|MANAGER_IP|$WAZUH_MANAGER|g" /var/ossec/etc/ossec.conf -elif [ "$(which apk)" = "/sbin/apk" ]; then - OSSEC_CONF_PATH="/Library/Ossec/etc/ossec.conf" - wget -O /etc/apk/keys/alpine-devel@wazuh.com-633d7457.rsa.pub https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub - echo "https://packages.wazuh.com/4.x/alpine/v3.12/main" >> /etc/apk/repositories - apk update - apk add wazuh-agent - sed -i "s|MANAGER_IP|$WAZUH_MANAGER|g" /var/ossec/etc/ossec.conf -else - log ERROR "Unsupported OS for creating user." - exit 1 -fi +sh /app/scripts/tests/setup.sh chmod +x /app/scripts/install.sh