mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-07 08:26:11 +00:00
* Initial plan * chore(security): harden workflow permissions and pin Docker base image digests Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/2ddc8f2b-7355-48cf-9a0b-c06df66c3f47 * fix(security): restore permissions: {} on publish + release-candidate workflows These two release-publishing workflows had permissions: {} (the strictest valid form) before PR #1454, which replaced it with permissions: read-all. Every job in both files already declares its own permissions block, so the workflow-level default is only the safety net for future jobs added without one — read-all weakens that net for no benefit. Restore {} and the explanatory comment. Scorecard's TokenPermissions check accepts both forms, so this preserves U9 compliance. * fix(security): narrow permissions: read-all to contents: read on 13 workflows PR #1454 added permissions: read-all to 13 workflows that previously had no top-level permissions block. read-all is Scorecard-compliant but unnecessarily broad — every job in scope only needs contents:read at the workflow level (job-level blocks already grant the writes that any job actually performs). Snapshot of every job in the 13 workflows confirms contents:read is sufficient: - ci.yml: quality/tests/scope-parity have explicit contents:read job blocks; save-pr-meta uses upload-artifact only (no token scopes needed); ci-status is pure shell. - ci-e2e.yml, ci-quality.yml, ci-scope-parity.yml, ci-tests.yml: all jobs do checkout + npm + tsc/vitest/playwright/upload-artifact only; no API token scopes required. - claude.yml, codeql.yml, dependency-review.yml, docker.yml, gitleaks.yml, pr-labeler.yml, trivy.yml, workflow-lint.yml: all jobs already declare their own job-level blocks (security-events:write, pull-requests:write, packages:write, etc.) so the workflow-level default does not gate them. zizmor (--min-severity high) is clean on the resulting tree. Pre-existing medium findings (secrets-inherit, artipacked) are in unrelated workflows and untouched by this commit. scorecard.yml also uses read-all but pre-existed PR #1454 and is deferred to a follow-up PR per the plan's scope boundary. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
82 lines
2.6 KiB
YAML
82 lines
2.6 KiB
YAML
name: Trivy Image Scan
|
|
|
|
# Builds Dockerfile.cli and Dockerfile.web, then scans the resulting images
|
|
# for OS-package and language-package CVEs at MEDIUM+ severity.
|
|
# Findings upload to the Security tab; record-only (does not block merges).
|
|
#
|
|
# Trigger on Dockerfile changes in PRs so base-image/npm-layer remediation can
|
|
# be verified before merge without running image scans on every PR.
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- 'Dockerfile.cli'
|
|
- 'Dockerfile.web'
|
|
- 'gitnexus/Dockerfile.test'
|
|
- '.github/workflows/trivy.yml'
|
|
push:
|
|
branches: [main]
|
|
schedule:
|
|
- cron: '0 8 * * 1'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
scan:
|
|
name: Trivy (${{ matrix.image.name }})
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
permissions:
|
|
contents: read
|
|
security-events: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
image:
|
|
- { dockerfile: Dockerfile.cli, name: gitnexus-cli }
|
|
- { dockerfile: Dockerfile.web, name: gitnexus-web }
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup Buildx
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
|
|
- name: Build image (load locally for scan)
|
|
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
|
with:
|
|
context: .
|
|
file: ${{ matrix.image.dockerfile }}
|
|
load: true
|
|
push: false
|
|
tags: scan-target:${{ matrix.image.name }}
|
|
|
|
# aquasecurity/trivy-action versions < 0.35.0 are flagged by
|
|
# GHSA-69fq-xp46-6x23 (briefly compromised supply chain). Pinned to
|
|
# v0.36.0 (post-incident clean release) by commit SHA.
|
|
- name: Run Trivy
|
|
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
|
|
with:
|
|
image-ref: scan-target:${{ matrix.image.name }}
|
|
format: sarif
|
|
output: trivy-${{ matrix.image.name }}.sarif
|
|
severity: MEDIUM,HIGH,CRITICAL
|
|
# Hides CVEs with no available fix in the base image.
|
|
ignore-unfixed: true
|
|
exit-code: '0'
|
|
|
|
- name: Upload to Security tab
|
|
uses: github/codeql-action/upload-sarif@e46ed2cbd01164d986452f91f178727624ae40d7 # v4.35.3
|
|
with:
|
|
sarif_file: trivy-${{ matrix.image.name }}.sarif
|
|
category: trivy-${{ matrix.image.name }}
|