Files
splunk-security_content/.github/workflows/detection-testing.yml
T
2021-08-06 15:22:43 -07:00

105 lines
4.9 KiB
YAML

name: detection-testing
on: [push, pull_request]
jobs:
detection-testing:
runs-on: ubuntu-latest
environment: Detection-Testing-Approval
#Doesn't seem like it actually has any dependencies...
#needs: [validate-content, build-sources, build-package, run-appinspect, create-report, update-sources-github, publish-github-release, attack-range-update, master-api-update]
#Only run when tagged
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: '0'
- name: Install System Packages
run: |
sudo apt update -qq
sudo apt install jq -qq
- uses: actions/setup-python@v2
with:
python-version: '3.9.5' #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: |
#Get the virtualenv set up
rm -rf venv
python3 -m venv --clear venv
source venv/bin/activate
python3 -m pip install -q -r requirements.txt
- name: Get branch and PR required for detection testing main.py
id: vars
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
#Set up credentials in the environment so that boto will be able to find them
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
#Right now the script is hard coded to EU because of the dev who originally wrote it...
#probably change that arg to None and set here?
aws-region: us-west-1 #assume we will always use this, could make this an environment variable...
- name: Run Detection testing
timeout-minutes: 120
run: |
echo "Just print the result of git branch -a --contains $GITHUB_SHA"
REAL_BRANCH=$(git branch -a --contains $GITHUB_SHA | tail -n1 | cut -d'/' -f3')
mkdir tempFolder
cd tempFolder
git clone --branch $REAL_BRANCH ${{ secrets.GITHUB_TOKEN }}@$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/
ls -lah
git config user.email "research@splunk.com"
git config user.name "research bot"
touch test.file
git add test.file
git commit --allow-empty -m "Doing a test commit"
git push
#echo "Show a big log of the past 10 commits"
#git log --pretty=oneline | head -n 2
#echo "Attempt 1"
#THE_BRANCH=`git branch -a --contains ${{ steps.vars.outputs.tag }} | tail -n 1 | sed 's/^[[:space:]]*//g'`
#echo "Parsed branch name <$THE_BRANCH>"
#git checkout $THE_BRANCH
#git pull
#git config user.email "research@splunk.com"
#git config user.name "research bot"
#touch test.file
#git add test.file
#git commit --allow-empty -m "Doing a test commit"
#BRANCH_NAME=`git branch -a --contains ${{ steps.vars.outputs.branch }} | head -n1 | cut -d' ' -f2`
#git log --pretty=oneline | head -n 1 | tail -n 1 | cut -d' ' -f 1 | tr "*" " " | sed 's/^[[:space:]]*//g'
#git log --pretty=oneline | head -n 2 | tail -n 1 | cut -d' ' -f 1 | tr "*" " " | sed 's/^[[:space:]]*//g'
#BRANCH_NAME=$(git branch -a --contains $(git log --pretty=oneline | head -n 1 | tail -n 1 | cut -d' ' -f 1 | tr "*" " " | sed 's/^[[:space:]]*//g'))
#echo "The branch name 1 is....$BRANCH_NAME"
#BRANCH_NAME=$(git branch -a --contains $(git log --pretty=oneline | head -n 2 | tail -n 1 | cut -d' ' -f 1 | tr "*" " " | sed 's/^[[:space:]]*//g'))
#echo "The branch name 2 is....$BRANCH_NAME"
# cd automated_detection_testing/ci/python_ci_code
# python3 -m venv --clear venv
# source venv/bin/activate
# pip install -q -r requirements.txt
# if [[ ! -z "${{ github.event.issue.pull_request }}" && ! -z "${{ github.event.issue.number }}" ]]; then
# python3 main.py -b $SIMPLE_BRANCH -pr ${{ github.event.issue.number }}
# else
# python3 main.py -b $SIMPLE_BRANCH
# fi
- name: Puish Changes
uses: ad-m/github-push-action@master
#with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: ${{ github.ref }}