Refactor Snort test for macOS #60
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Snort tests | |
on: [push, pull_request] | |
jobs: | |
run-tests: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] # Operating systems | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
# Linux-specific steps | |
- name: Set up Python (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y curl gnupg2 iproute2 | |
pip install pytest pytest-testinfra | |
- name: Install wazuh-agent (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | sudo apt-key add - | |
echo "deb https://packages.wazuh.com/4.x/apt/ stable main" | sudo tee /etc/apt/sources.list.d/wazuh.list | |
sudo apt-get update | |
sudo apt-get install -y wazuh-agent | |
- name: Run Snort install script (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo bash scripts/install.sh | |
# Windows-specific steps | |
- name: Install Wazuh agent (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
Invoke-WebRequest -Uri https://packages.wazuh.com/4.x/windows/wazuh-agent-4.9.0-1.msi -OutFile $env:TEMP\wazuh-agent.msi | |
msiexec.exe /i $env:TEMP\wazuh-agent.msi /qn WAZUH_MANAGER='10.0.0.1' WAZUH_AGENT_NAME='test' | |
- name: Install Snort (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
Start-Process -FilePath "powershell.exe" -ArgumentList "-File $env:GITHUB_WORKSPACE/scripts/snort.ps1" -Verb RunAs -Wait | |
# macOS-specific steps | |
- name: Set up Python (macOS) | |
if: matrix.os == 'macos-latest' | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew update | |
brew install curl iproute2mac | |
pip install pytest pytest-testinfra | |
- name: Install Wazuh agent (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
curl -so wazuh-agent.pkg https://packages.wazuh.com/4.x/macos/wazuh-agent-4.9.0-1.intel64.pkg && echo "WAZUH_MANAGER='10.0.0.1' && WAZUH_AGENT_NAME='test'" > /tmp/wazuh_envs && sudo installer -pkg ./wazuh-agent.pkg -target / | |
sudo /Library/Ossec/bin/wazuh-control start | |
- name: Run Snort install script (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
bash scripts/install.sh | |
# Running tests | |
- name: Run tests (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo $(which pytest) -vv scripts/tests/test.py | |
- name: List files (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
dir $env:GITHUB_WORKSPACE\scripts | |
- name: Run tests (Windows) | |
if: matrix.os == 'windows-latest' | |
run: | | |
pwsh -ExecutionPolicy Bypass -File $env:GITHUB_WORKSPACE/scripts/tests/test.ps1 | |