test #11
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: 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: Extract dockerfile path info | |
id: dockerfile-info | |
run: | | |
DIRNAME=$(dirname "${{ matrix.dockerfile }}") | |
BASENAME=$(basename "${{ matrix.dockerfile }}") | |
echo "dirname=$DIRNAME" >> $GITHUB_OUTPUT | |
echo "basename=$BASENAME" >> $GITHUB_OUTPUT | |
- 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-${{ matrix.dockerfile }}.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-${{ matrix.dockerfile }}.sarif | |
category: trivy-${{ matrix.dockerfile }} | |
... |