-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update and rename test_docker.yml to test_apache_docker.yml
- Loading branch information
1 parent
0d92cd3
commit 1463357
Showing
2 changed files
with
85 additions
and
164 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Validate WAF Patterns for Apache with Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Trigger on push to main branch | ||
pull_request: | ||
branches: | ||
- main # Trigger on pull request to main branch | ||
|
||
jobs: | ||
validate-waf-patterns: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Cache Docker setup | ||
id: cache-docker | ||
uses: actions/cache@v3 | ||
with: | ||
path: /var/lib/docker | ||
key: docker-setup-${{ runner.os }} | ||
|
||
- name: Set up Docker | ||
run: | | ||
sudo apt-get update | ||
# Remove conflicting containerd package | ||
sudo apt-get remove -y containerd | ||
# Install Docker dependencies | ||
sudo apt-get install -y ca-certificates curl | ||
# Add Docker's official GPG key | ||
sudo install -m 0755 -d /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | ||
sudo chmod a+r /etc/apt/keyrings/docker.gpg | ||
# Add Docker's repository | ||
echo \ | ||
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | ||
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | ||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
# Install Docker | ||
sudo apt-get update | ||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
sudo docker --version | ||
- name: Pull Docker images | ||
run: | | ||
echo "Pulling ApacheDocker image..." | ||
sudo docker pull httpd:latest | ||
- name: Validate Apache configuration | ||
run: | | ||
echo "Validating Apache configuration..." | ||
for file in waf_patterns/apache/*.conf; do | ||
echo "Validating $file..." | ||
sudo docker run --rm -v $(pwd)/waf_patterns/apache:/usr/local/apache2/conf/extra:ro httpd httpd -t | ||
if [ $? -ne 0 ]; then | ||
echo "Error: Validation failed for $file" | ||
exit 1 | ||
fi | ||
done | ||
- name: Start Apache container with WAF rules | ||
run: | | ||
echo "Starting Apache container..." | ||
sudo docker run -d \ | ||
--name apache-waf \ | ||
-p ${{ env.APACHE_PORT }}:80 \ | ||
-v $(pwd)/waf_patterns/apache:/usr/local/apache2/conf/extra \ | ||
httpd:latest | ||
echo "Apache is running on port ${{ env.APACHE_PORT }}." | ||
- name: Check Apache container logs | ||
run: | | ||
echo "Checking Apache container logs..." | ||
sudo docker logs apache-waf | ||
- name: Clean up containers | ||
if: always() | ||
run: | | ||
echo "Stopping and removing containers..." | ||
sudo docker stop apache-waf || true | ||
sudo docker rm apache-waf || true | ||
echo "Containers stopped and removed." |
This file was deleted.
Oops, something went wrong.