Files
splunk-security_content/.github/workflows/docker-detection-testing.yml
T
2021-11-05 14:57:46 -07:00

246 lines
11 KiB
YAML

name: docker-detection-testing
on:
push:
jobs:
validate-tag-if-present:
runs-on: ubuntu-latest
steps:
- name: TAGGED, Validate that the tag is in the correct format
run: |
echo "The GITHUB_REF: $GITHUB_REF"
#First check to see if the release is a tag
if [[ $GITHUB_REF =~ refs/tags/* ]]; then
#Yes, this is a tag, so we need to test to make sure that the tag
#is in the correct format (like v1.10.20)
if [[ $GITHUB_REF =~ refs/tags/v[0-9]+.[0-9]+.[0-9]+ ]]; then
echo "PASS: Tagged release with good format"
exit 0
else
echo "FAIL: Tagged release with bad format"
exit 1
fi
else
echo "PASS: Not a tagged release"
exit 0
fi
quit-for-dependabot:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
steps:
- name: "Placeholder"
run: |
echo "No, this is not a dependabot run!"
docker-detection-testing-setup:
runs-on: ubuntu-latest
needs: [validate-tag-if-present, quit-for-dependabot]
steps:
- name: Get branch and PR required for detection testing main.py
id: vars
run: |
echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
- name: Checkout Repo
uses: actions/checkout@v2
- name: Install Docker
run: |
sudo apt update -qq
#python2.7 needed for slim, for now
sudo apt install python2
sudo apt install virtualenv
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
sudo python2.7 get-pip.py
- uses: actions/setup-python@v2
with:
python-version: '3.9' #Available versions here - https://github.com/actions/python-versions/releases easy to change/make a matrix/use pypy
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install Python Dependencies
run: |
cd automated_detection_testing/ci/detection_testing_batch
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install wheel
python3 -m pip install -r requirements.txt
- name: Run the CI
run: |
cd automated_detection_testing/ci/detection_testing_batch
source .venv/bin/activate
#python3 detection_testing_execution.py -b ${{ steps.vars.outputs.branch }} -u 123456789 --splunkbase_username ${{ secrets.SPLUNKBASE_TESTING_USERNAME }} --splunkbase_password ${{ secrets.SPLUNKBASE_TESTING_KEY }} -m new -n2
python3 detection_testing_execution.py -b RegistryDetectionFixes -u 123456789 --splunkbase_username ${{ secrets.SPLUNKBASE_TESTING_USERNAME }} --splunkbase_password ${{ secrets.SPLUNKBASE_TESTING_KEY }} -m new -n10 -split
echo "DONE!"
- name: Upload Test Results Files
uses: actions/upload-artifact@v2
with:
name: testing-results-config
path: |
automated_detection_testing/ci/detection_testing_batch/apps/DA-ESS-ContentUpdate-latest.tar.gz
automated_detection_testing/ci/detection_testing_batch/container_0_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_1_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_2_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_3_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_4_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_5_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_6_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_7_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_8_tests.txt
automated_detection_testing/ci/detection_testing_batch/container_9_tests.txt
docker-detection-testing-execution:
runs-on: ubuntu-latest
needs: [validate-tag-if-present, quit-for-dependabot, docker-detection-testing-setup]
strategy:
matrix:
test_filename: ["container_0_tests.txt",
"container_1_tests.txt",
"container_2_tests.txt",
"container_3_tests.txt",
"container_4_tests.txt",
"container_5_tests.txt",
"container_6_tests.txt",
"container_7_tests.txt",
"container_8_tests.txt",
"container_9_tests.txt"]
steps:
- name: Get branch and PR required for detection testing main.py
id: vars
run: |
echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
- name: Checkout Repo
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: testing-results-config
path: automated_detection_testing/ci/detection_testing_batch/prior_config
- name: Install Docker
run: |
sudo apt update -qq
#python2.7 needed for slim, for now
sudo apt install python2
sudo apt install virtualenv
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
sudo python2.7 get-pip.py
- uses: actions/setup-python@v2
with:
python-version: '3.9' #Available versions here - https://github.com/actions/python-versions/releases easy to change/make a matrix/use pypy
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install Python Dependencies
run: |
cd automated_detection_testing/ci/detection_testing_batch
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install wheel
python3 -m pip install -r requirements.txt
- name: Run the CI
run: |
cd automated_detection_testing/ci/detection_testing_batch
source .venv/bin/activate
#python3 detection_testing_execution.py -b ${{ steps.vars.outputs.branch }} -u 123456789 --splunkbase_username ${{ secrets.SPLUNKBASE_TESTING_USERNAME }} --splunkbase_password ${{ secrets.SPLUNKBASE_TESTING_KEY }} -m new -n2
python3 detection_testing_execution.py -b RegistryDetectionFixes -u 123456789 --splunkbase_username ${{ secrets.SPLUNKBASE_TESTING_USERNAME }} --splunkbase_password ${{ secrets.SPLUNKBASE_TESTING_KEY }} -m selected -tff prior_config/${{ matrix.test_filename}} -n1 -e prior_config/apps/DA-ESS-ContentUpdate-latest.tar.gz
- name: Upload Test Results Files
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.test_filename}}.results
path: |
automated_detection_testing/ci/detection_testing_batch/success.csv
automated_detection_testing/ci/detection_testing_batch/error.csv
automated_detection_testing/ci/detection_testing_batch/failure.csv
automated_detection_testing/ci/detection_testing_batch/combined.csv
automated_detection_testing/ci/detection_testing_batch/success.json
automated_detection_testing/ci/detection_testing_batch/error.json
automated_detection_testing/ci/detection_testing_batch/failure.json
automated_detection_testing/ci/detection_testing_batch/combined.json
docker-detection-testing-execution-merge-results:
runs-on: ubuntu-latest
needs: [validate-tag-if-present, quit-for-dependabot, docker-detection-testing-setup, docker-detection-testing-execution]
steps:
- name: Get branch and PR required for detection testing main.py
id: vars
run: |
echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
- name: Checkout Repo
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_0_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_1_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_2_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_3_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_4_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_5_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_6_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_7_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_8_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: container_9_tests.txt.results
path: automated_detection_testing/ci/detection_testing_batch/results
- name: Merge Detections into single File
run: |
cd automated_detection_testing/ci/detection_testing_batch/results
ls -lah
echo "DONE!"