DataHub Security Advisory Alert #26
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
name: DataHub Security Advisory Alert | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs every day at midnight | |
workflow_dispatch: | |
jobs: | |
check-security-advisories: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Fetch security advisories | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api -H "Accept: application/vnd.github+json" /repos/datahub-project/datahub/security-advisories > advisories.json | |
- name: Get last run date for this Action | |
id: get_last_run_date | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
LAST_RUN_DATE=$(gh api \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/repos/ministryofjustice/data-catalogue/actions/runs \ | |
--jq '.workflow_runs[] | |
| select(.conclusion=="success" and .status=="completed" and (.path|endswith("security-alerts.yml"))) | |
| .run_started_at' \ | |
| head -n 1) | |
echo "last_run_date=${LAST_RUN_DATE}" >> "${GITHUB_OUTPUT}" | |
echo "${LAST_RUN_DATE}" | |
- name: Read current version from values.yaml | |
id: read_current_version | |
run: | | |
CURRENT_VERSION=$(python -c "import yaml; print(yaml.safe_load(open('helm_deploy/values-base.yaml'))['global']['datahub']['version'])") | |
echo "current_version=${CURRENT_VERSION}" >> "${GITHUB_OUTPUT}" | |
echo "${CURRENT_VERSION}" | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install Python dependencies | |
run: | | |
pip install --upgrade pip | |
pip install --no-cache-dir -r requirements.txt | |
- name: Filter advisories | |
id: filter_advisories | |
env: | |
REPO: datahub | |
REPO_OWNER: datahub-project | |
run: python scripts/filter_advisories.py \ | |
"${{ steps.read_current_version.outputs.current_version }}" \ | |
"${{ steps.get_last_run_date.outputs.last_run_date }}" | |
- name: Send advisories to Slack | |
id: send_to_slack | |
if: ${{ steps.filter_advisories.outputs.num_filtered_advisories != '0' }} | |
uses: slackapi/[email protected] | |
with: | |
channel-id: 'C071VNHPUHZ' | |
payload-file-path: "./filtered_advisories.json" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.VULN_CHECK_SLACK_BOT_TOKEN }} |