Repository navigation
ci: add PR quality, security and build checks #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3ccbbb9
ci: add PR checks, container build, scorecard and image scan workflows
vermorag afea629
ci: add build, coverage and phpcs checks; pin and harden workflows
vermorag 8f18c2a
ci: fix Trivy image export and dependency review scopes
vermorag 4f8a155
ci(tests): self-contained coverage reporting instead of Codecov
vermorag c3cf4e6
ci(tests): keep diff-cover failures out of the required PHPUnit result
vermorag 9a17158
ci: render the Helm chart with dummy keys in the Trivy config scan
vermorag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,17 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "npm" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| - package-ecosystem: "composer" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| - package-ecosystem: "docker" | ||
| # Keeps the SHA-pinned actions in .github/workflows up to date. | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| cooldown: | ||
| default-days: 7 | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| name: Container | ||
|
|
||
| # Advisory: builds the application image the same way release.yml does | ||
| # (same Dockerfile, buildah, linux/amd64, OCI) without pushing, then scans it | ||
| # with Trivy. Only the application layer is verified: the build uses the | ||
| # published builder-latest / runtime-latest base images (the Dockerfile | ||
| # defaults), so changes to build/base/** and build/packages/** are not | ||
| # covered here. Until release.yml has published the Wolfi base images and | ||
| # moved builder-latest / runtime-latest to them, those tags still point at the | ||
| # legacy Alpine/nginx images and this build is expected to fail. | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | ||
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Container build | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 60 | ||
| permissions: | ||
| contents: read | ||
| env: | ||
| # See the Trivy note in pr-checks.yml: official image pinned by digest | ||
| # instead of the (once tag-hijacked) trivy-action. | ||
| TRIVY_IMAGE: aquasec/trivy@sha256:790fd66d1697395d8693d1acaa1ea702406a20f109b6fc7bac8db623eca6c06c # 0.76.1 | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| # A failing build is real breakage and fails the job. | ||
| - name: Build Cattr server | ||
| id: build | ||
| uses: redhat-actions/buildah-build@719e3c40d8af9790c23eca13f7daa339f2867034 # v3.1.0 | ||
| with: | ||
| context: . | ||
| containerfiles: | | ||
| ./Dockerfile | ||
| image: server | ||
| tags: ci | ||
| # Same as release.yml: Cattr images are linux/amd64 only, OCI format. | ||
| arch: amd64 | ||
| oci: true | ||
| build-args: | | ||
| APP_VERSION=0.0.0-ci | ||
| layers: true | ||
|
|
||
| - name: Export image | ||
| env: | ||
| IMAGE: ${{ steps.build.outputs.image-with-tag }} | ||
| run: | | ||
| set -euo pipefail | ||
| buildah push "${IMAGE}" "oci-archive:${RUNNER_TEMP}/image.tar" | ||
|
|
||
| # The scan is advisory: it never fails the job. Findings (HIGH/CRITICAL | ||
| # with an available fix) are written to the job summary. | ||
| - name: Scan image with Trivy | ||
| continue-on-error: true | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| docker run --rm -v "${RUNNER_TEMP}:/scan" "${TRIVY_IMAGE}" \ | ||
| image \ | ||
| --input /scan/image.tar \ | ||
| --scanners vuln \ | ||
| --severity HIGH,CRITICAL \ | ||
| --ignore-unfixed \ | ||
| --format json \ | ||
| --output /scan/trivy.json \ | ||
| --exit-code 0 \ | ||
| --no-progress | ||
|
|
||
| docker run --rm -v "${RUNNER_TEMP}:/scan" "${TRIVY_IMAGE}" \ | ||
| convert --scanners vuln --format table --output /scan/trivy.txt /scan/trivy.json | ||
|
|
||
| cat "${RUNNER_TEMP}/trivy.txt" | ||
|
|
||
| { | ||
| echo '## Trivy image scan (advisory)' | ||
| echo | ||
| echo 'HIGH/CRITICAL vulnerabilities with an available fix:' | ||
| echo | ||
| echo '```' | ||
| cat "${RUNNER_TEMP}/trivy.txt" | ||
| echo '```' | ||
| } >> "${GITHUB_STEP_SUMMARY}" | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| name: Image scan | ||
|
|
||
| # Scheduled Trivy scan of the published images. Wolfi packages in the base | ||
| # images receive CVEs between releases; new alerts here signal that a | ||
| # base-image rebuild (IMAGE_BUILD_REVISION / build/base/rebuild) is due. | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '27 5 * * 1' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }} | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| scan: | ||
| name: Scan ${{ matrix.name }} | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 30 | ||
| permissions: | ||
| contents: read | ||
| security-events: write # Upload SARIF to GitHub code scanning. | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| # Latest stable application release (release.yml tags it `latest`). | ||
| - name: server | ||
| image: ghcr.io/cattr-app/server:latest | ||
| - name: server-runtime | ||
| image: ghcr.io/cattr-app/server-runtime:runtime-latest | ||
| env: | ||
| # See the Trivy note in pr-checks.yml: official image pinned by digest | ||
| # instead of the (once tag-hijacked) trivy-action. | ||
| TRIVY_IMAGE: aquasec/trivy@sha256:790fd66d1697395d8693d1acaa1ea702406a20f109b6fc7bac8db623eca6c06c # 0.76.1 | ||
| steps: | ||
| # upload-sarif resolves the commit and ref from the checkout. | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Scan image with Trivy | ||
| env: | ||
| IMAGE: ${{ matrix.image }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| docker run --rm -v "${RUNNER_TEMP}:/scan" "${TRIVY_IMAGE}" \ | ||
| image \ | ||
| --image-src remote \ | ||
| --scanners vuln \ | ||
| --severity HIGH,CRITICAL \ | ||
| --ignore-unfixed \ | ||
| --format json \ | ||
| --output /scan/trivy.json \ | ||
| --exit-code 0 \ | ||
| --no-progress \ | ||
| "${IMAGE}" | ||
|
|
||
| docker run --rm -v "${RUNNER_TEMP}:/scan" "${TRIVY_IMAGE}" \ | ||
| convert --format sarif --output /scan/trivy.sarif /scan/trivy.json | ||
|
|
||
| docker run --rm -v "${RUNNER_TEMP}:/scan" "${TRIVY_IMAGE}" \ | ||
| convert --scanners vuln --format table --output /scan/trivy.txt /scan/trivy.json | ||
|
|
||
| { | ||
| echo "## Trivy scan of \`${IMAGE}\`" | ||
| echo | ||
| echo 'HIGH/CRITICAL vulnerabilities with an available fix:' | ||
| echo | ||
| echo '```' | ||
| cat "${RUNNER_TEMP}/trivy.txt" | ||
| echo '```' | ||
| } >> "${GITHUB_STEP_SUMMARY}" | ||
|
|
||
| - name: Upload SARIF | ||
| uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 | ||
| with: | ||
| sarif_file: ${{ runner.temp }}/trivy.sarif | ||
| category: trivy-image-${{ matrix.name }} |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.