name: Security
on:
pull_request:
merge_group: {}
schedule:
- cron: "17 6 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: security-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
codeql:
name: CodeQL
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
include:
- language: rust
build-mode: none
- language: actions
build-mode: none
steps:
- uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- uses: github/codeql-action/init@33d7b85da1a04171e211befe2c739303b9a4c066 with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
queries: security-and-quality
- uses: github/codeql-action/analyze@33d7b85da1a04171e211befe2c739303b9a4c066 with:
category: "/language:${{ matrix.language }}"
dependency-review:
name: Dependency review
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
pull-requests: read
steps:
- uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 with:
fail-on-severity: high
report-failure:
name: Report CodeQL failure
needs: codeql
if: always() && (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
issues: write
steps:
- uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 with:
persist-credentials: false
- name: Open or close the failure issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ASSIGNEE: ${{ vars.NIGHTLY_FAILURE_ASSIGNEE || 'SebTardif' }}
RUN_ID: ${{ github.run_id }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
JOB_RESULTS: codeql=${{ needs.codeql.result }}
run: |
python3 scripts/report-scheduled-failure.py \
--prefix "CodeQL red" \
--run-id "$RUN_ID" \
--run-url "$RUN_URL" \
--label nightly-failure \
--label ready