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

Add Continuous Testing with Pytest and GitHub Actions #4

Merged
merged 74 commits into from
Sep 4, 2024
Merged

Conversation

bengo237
Copy link
Contributor

@bengo237 bengo237 commented Sep 4, 2024

This PR introduces continuous testing for the Snort and Wazuh integration using Pytest and GitHub Actions. Key changes include:

  • Pytest Configuration: Added Pytest tests to validate the Snort installation and configuration. Tests ensure that Snort is correctly installed, the configuration files exist, and the system is properly configured.

  • GitHub Actions Workflow: Created a GitHub Actions workflow that automatically runs Pytest tests on each push and pull request. The workflow sets up the environment, installs necessary dependencies, and executes the tests to ensure the integrity of the Snort and Wazuh setup.

  • Testing Documentation: Added detailed documentation in scripts/tests/README.md to guide users on how to run tests locally and understand the testing process.

These additions will help maintain high code quality and ensure that changes to the repository do not break existing functionality.

- Checkout code
- Set up Python 3.9
- Install dependencies including pytest and pytest-testinfra
- Run Snort installation script
- Execute tests with pytest
The code changes in `test_install.py` ensure that the `HOME_NET` variable in `snort.conf` is correctly configured. The previous implementation used the `ip` command with the `-o` and `-f inet` options to retrieve the IP address, but it didn't work as expected. The updated code now uses the `ip` command with the `-4` option and `grep` to extract the IP address. The `HOME_NET` variable is then updated in `snort.conf` to include the IP address with a `/24` subnet mask.

This commit message follows the established conventions in the repository.
- Introduced fixture `host_interface_and_homenet` to dynamically retrieve
  the default network interface and corresponding IP address for HOME_NET.
- Added `test_home_net_defined` to verify that HOME_NET is correctly defined
  in `snort.conf` using the retrieved IP address.
- Added `test_interface_defined` to ensure the default network interface is
  properly specified in `snort.conf`.
- Integrated these tests into the existing test suite alongside dependency
  installation and OSSEC configuration validation.
@bengo237 bengo237 self-assigned this Sep 4, 2024
@bengo237 bengo237 linked an issue Sep 4, 2024 that may be closed by this pull request
@bengo237 bengo237 requested a review from ArmandMeppa September 4, 2024 14:21
@bengo237 bengo237 merged commit a665f66 into main Sep 4, 2024
3 checks passed
@bengo237 bengo237 deleted the develop branch September 4, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write Tests for Snort Script and Add Uninstallation Feature
1 participant