Skip to content

Commit

Permalink
Move security jobs from circleci to github actions (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattops authored and james-jdgtl committed Oct 17, 2024
1 parent 13c6147 commit abcc65f
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rename_template_project_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
slack_releases_channel:
description: 'Slack channel for release notifications.'
required: true
pipeline_security_slack_channel:
security_alerts_slack_channel_id:
description: 'Slack channel for pipeline security notifications.'
required: true
non_prod_alerts_prometheus_severity_label:
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v4

- name: Run rename-project script
run: ./rename-project.bash ${{ github.event.repository.name }} ${{ inputs.slack_releases_channel }} ${{ inputs.pipeline_security_slack_channel }} ${{ inputs.non_prod_alerts_prometheus_severity_label }} ${{ inputs.prod_alerts_prometheus_severity_label }} ${{ inputs.product_id }}
run: ./rename-project.bash ${{ github.event.repository.name }} ${{ inputs.slack_releases_channel }} ${{ inputs.security_alerts_slack_channel_id }} ${{ inputs.non_prod_alerts_prometheus_severity_label }} ${{ inputs.prod_alerts_prometheus_severity_label }} ${{ inputs.product_id }}

- name: Delete this github actions workflow
run: rm .github/workflows/rename_template_project*
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/security_owasp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security OWASP dependency check
on:
workflow_dispatch:
schedule:
- cron: "19 6 * * MON-FRI" # Every weekday
jobs:
security-kotlin-owasp-check:
name: Kotlin security OWASP dependency check
uses: ministryofjustice/hmpps-github-actions/.github/workflows/[email protected] # WORKFLOW_VERSION
with:
channel_id: C05J915DX0Q
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/security_trivy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security trivy dependency check
on:
workflow_dispatch:
schedule:
- cron: "19 6 * * MON-FRI" # Every weekday
jobs:
security-kotlin-trivy-check:
name: Project security trivy dependency check
uses: ministryofjustice/hmpps-github-actions/.github/workflows/[email protected] # WORKFLOW_VERSION
with:
channel_id: C05J915DX0Q
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/security_veracode_pipeline_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security veracode pipeline scan
on:
workflow_dispatch:
schedule:
- cron: "19 6 * * MON-FRI" # Every weekday
jobs:
security-veracode-pipeline-scan:
name: Project security veracode pipeline scan
uses: ministryofjustice/hmpps-github-actions/.github/workflows/[email protected] # WORKFLOW_VERSION
with:
channel_id: C05J915DX0Q
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/security_veracode_policy_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Security veracode policy scan
on:
workflow_dispatch:
schedule:
- cron: "34 6 * * 1" # Every Monday
jobs:
security-veracode-policy-check:
name: Project security veracode policy scan
uses: ministryofjustice/hmpps-github-actions/.github/workflows/[email protected] # WORKFLOW_VERSION
with:
channel_id: C05J915DX0Q
secrets: inherit
13 changes: 8 additions & 5 deletions rename-project.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ fi
if [[ $# -ge 1 ]]; then
PROJECT_INPUT=$1
SLACK_RELEASES_CHANNEL=$2
PIPELINE_SECURITY_SLACK_CHANNEL=$3
SECURITY_ALERTS_SLACK_CHANNEL_ID=$3
NON_PROD_ALERTS_SEVERITY_LABEL=$4
PROD_ALERTS_SEVERITY_LABEL=$5
PRODUCT_ID=$6
else
read -rp "New project name e.g. prison-visits >" PROJECT_INPUT
read -rp "Slack channel for release notifications >" SLACK_RELEASES_CHANNEL
read -rp "Slack channel for pipeline security notifications >" PIPELINE_SECURITY_SLACK_CHANNEL
read -rp "Slack channel for pipeline security notifications >" SECURITY_ALERTS_SLACK_CHANNEL_ID
echo "For configurating alert severity labels, please first see https://user-guide.cloud-platform.service.justice.gov.uk/documentation/monitoring-an-app/how-to-create-alarms.html#creating-your-own-custom-alerts"
read -rp "Non-prod kubernetes alerts. The severity label used by prometheus to route alert notifications to slack >" NON_PROD_ALERTS_SEVERITY_LABEL
read -rp "Production kubernetes alerts. The severity label used by prometheus to route alert notifications to slack >" PROD_ALERTS_SEVERITY_LABEL
Expand Down Expand Up @@ -87,12 +87,15 @@ RANDOM_HOUR=$((RANDOM % (9 - 3 + 1) + 3))
RANDOM_MINUTE=$(($RANDOM%60))
RANDOM_MINUTE2=$(($RANDOM%60))
sed -i -z -E \
-e "s/security:\n triggers:\n - schedule:\n cron: \"15 7/security:\n triggers:\n - schedule:\n cron: \"$RANDOM_MINUTE $RANDOM_HOUR/" \
-e "s/security-weekly:\n triggers:\n - schedule:\n cron: \"0 5/security-weekly:\n triggers:\n - schedule:\n cron: \"$RANDOM_MINUTE2 $RANDOM_HOUR/" \
-e "s/SLACK_RELEASES_CHANNEL/$SLACK_RELEASES_CHANNEL/" \
-e "s/PIPELINE_SECURITY_SLACK_CHANNEL/$PIPELINE_SECURITY_SLACK_CHANNEL/" \
.circleci/config.yml

sed -i -z -E \
-e "s/on:\n workflow_dispatch:\n schedule:\n - cron: \"19 6/on:\n workflow_dispatch:\n schedule:\n - cron: \"$RANDOM_MINUTE $RANDOM_HOUR/" \
-e "s/on:\n workflow_dispatch:\n schedule:\n - cron: \"34 6/on:\n workflow_dispatch:\n schedule:\n - cron: \"$RANDOM_MINUTE2 $RANDOM_HOUR/" \
-e "s/C05J915DX0Q/$SECURITY_ALERTS_SLACK_CHANNEL_ID/" \
.github/workflows/*

# lastly remove ourselves
rm rename-project.bash

Expand Down

0 comments on commit abcc65f

Please sign in to comment.