Skip to content

test

test #16

---
name: Vulnerability test
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 12 * * 1' # Runs every Monday at 12:00 PM UTC
jobs:
# code-vulnerabilities:
# name: Code
# runs-on: ubuntu-latest
# steps:
# - name: Check out repository
# uses: actions/checkout@v4
# - name: Harden-Runner
# uses: step-security/[email protected]
# - name: Set up environment
# uses: ./.github/actions/setup/poetry
# with:
# os: ${{ job.os }}
# python-version: '3.13.0'
# poetry-install-options: "--only=vulnerability --no-root"
# poetry-export-options: "--only=vulnerability"
# - name: Check code vulnerabilities with bandit
# run: poetry run bandit -c pyproject.toml -r jupyterhub/
# dependency-vulnerabilities:
# name: Dependencies
# runs-on: ubuntu-latest
# steps:
# - name: Check out repository
# uses: actions/checkout@v4
# - name: Harden-Runner
# uses: step-security/[email protected]
# - name: Set up environment
# uses: ./.github/actions/setup/poetry
# with:
# os: ${{ job.os }}
# python-version: '3.13.0'
# poetry-install-options: "--only=vulnerability --no-root"
# poetry-export-options: "--only=vulnerability"
# - name: Check dependency vulnerabilities with safety
# run: poetry run safety check --full-report
trivy:
name: Container Scan
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
matrix:
dockerfile:
- jupyterhub/hub/hub.Dockerfile
- jupyterhub/notebook/notebook.Dockerfile
steps:
- name: Checkout code
uses: actions/checkout@v4
# - name: Harden-Runner
# uses: step-security/[email protected]
- name: Build Docker image
# yamllint disable rule:line-length
run: |
IMAGE_NAME="$(basename '${{ matrix.dockerfile }}' | sed 's/.Dockerfile//'):${{github.sha}}"
docker build -t $IMAGE_NAME -f ${{ matrix.dockerfile }} .
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
# yamllint enable rule:line-length
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: ${{ env.IMAGE_NAME }}
format: 'sarif'
output: 'trivy-results-${{ env.IMAGE_NAME }}.sarif'
severity: 'CRITICAL,HIGH'
timeout: '10m'
ignore-unfixed: true
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: 'trivy-results-${{ env.IMAGE_NAME }}.sarif'
category: 'trivy-${{ env.IMAGE_NAME }}'
...