Skip to content

8.0 (fix): Start with another CacheManager next to the Grails cache plugin's #4002

8.0 (fix): Start with another CacheManager next to the Grails cache plugin's

8.0 (fix): Start with another CacheManager next to the Grails cache plugin's #4002

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "Vulnerability Scan"
on:
schedule:
# Run every Monday at 03:00 UTC
- cron: '0 3 * * 1'
workflow_dispatch:
# Opt in per pull request by applying the "vulnerability scan" label. Applying a label
# requires write access, so only a committer can start a scan.
pull_request:
# ready_for_review is not a default type: a labelled draft is scanned once it is ready or labelled "run ci".
types: [labeled, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
scan-grails-core:
name: "Vulnerability Scan - grails-core"
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- name: "📥 Checkout repository"
uses: actions/checkout@v7.0.1
- name: "☕️ Determine Java version from .sdkmanrc"
# Read the JDK the build targets out of the file that already declares it, so a
# baseline bump does not leave a stale literal behind here. Only the major is kept:
# a scan is outside the reproducible-build surface, so CI takes the runner's current
# release of that major rather than pinning the patch version.
id: sdkmanrc
run: |
set -euo pipefail
sdkman_java=$(grep -E '^java=' .sdkmanrc | cut -d= -f2 || true)
if [ -z "${sdkman_java}" ]; then
echo "❌ Could not determine the java version from .sdkmanrc" >&2
exit 1
fi
echo "Scanning with JDK ${sdkman_java%%.*} (from .sdkmanrc: ${sdkman_java})"
echo "java-version=${sdkman_java%%.*}" >> "$GITHUB_OUTPUT"
- name: "☕️ Setup JDK"
uses: actions/setup-java@v6.1.0
with:
distribution: liberica
java-version: ${{ steps.sdkmanrc.outputs.java-version }}
- name: "🗄️ Decide the Gradle cache mode"
id: gradle-cache-policy
uses: ./.github/actions/gradle-cache-policy
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
with:
# Decided by the step above; see .github/actions/gradle-cache-policy.
cache-read-only: ${{ steps.gradle-cache-policy.outputs.read-only }}
develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Run Vulnerability Scan"
# Looks up every resolved dependency in the OSV database (https://osv.dev) and in Sonatype Guide.
# --continue lets the summary report the projects whose scan failed.
env:
SONATYPE_GUIDE_USERNAME: ${{ secrets.SONATYPE_GUIDE_USERNAME }}
SONATYPE_GUIDE_TOKEN: ${{ secrets.SONATYPE_GUIDE_TOKEN }}
run: ./gradlew vulnerabilityScan vulnerabilityScanReport --continue
- name: "📋 Publish Vulnerability Summary"
if: always()
run: >
.github/scripts/vulnerabilityReport.sh
'🔍 Vulnerability Scan — grails-core'
>> "$GITHUB_STEP_SUMMARY"
scan-pull-request:
name: "Vulnerability Scan - pull request"
# `synchronize` and `reopened` re-scan a pull request that already carries the label.
# A pull request labelled "no ci", or a draft without the "run ci" label, is never scanned.
if: >-
github.event_name == 'pull_request'
&& contains(github.event.pull_request.labels.*.name, 'vulnerability scan')
&& !contains(github.event.pull_request.labels.*.name, 'no ci')
&& (!github.event.pull_request.draft || contains(github.event.pull_request.labels.*.name, 'run ci'))
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
steps:
- name: "📥 Checkout pull request"
uses: actions/checkout@v7.0.1
- name: "☕️ Determine Java version from .sdkmanrc"
# Read the JDK the build targets out of the file that already declares it, so a
# baseline bump does not leave a stale literal behind here. Only the major is kept:
# a scan is outside the reproducible-build surface, so CI takes the runner's current
# release of that major rather than pinning the patch version.
id: sdkmanrc
run: |
set -euo pipefail
sdkman_java=$(grep -E '^java=' .sdkmanrc | cut -d= -f2 || true)
if [ -z "${sdkman_java}" ]; then
echo "❌ Could not determine the java version from .sdkmanrc" >&2
exit 1
fi
echo "Scanning with JDK ${sdkman_java%%.*} (from .sdkmanrc: ${sdkman_java})"
echo "java-version=${sdkman_java%%.*}" >> "$GITHUB_OUTPUT"
- name: "☕️ Setup JDK"
uses: actions/setup-java@v6.1.0
with:
distribution: liberica
java-version: ${{ steps.sdkmanrc.outputs.java-version }}
- name: "🗄️ Decide the Gradle cache mode"
id: gradle-cache-policy
uses: ./.github/actions/gradle-cache-policy
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
with:
# Decided by the step above; see .github/actions/gradle-cache-policy.
cache-read-only: ${{ steps.gradle-cache-policy.outputs.read-only }}
develocity-access-key: ${{ secrets.GRAILS_DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Run Vulnerability Scan"
# GitHub withholds secrets from a pull request raised by a fork, so its scan consults OSV only,
# and the report says Sonatype Guide was not consulted.
# 60000 bytes keeps the whole summary, with the marker and heading the scripts add to it, clear of
# GitHub's 65536 character comment limit.
env:
SONATYPE_GUIDE_USERNAME: ${{ secrets.SONATYPE_GUIDE_USERNAME }}
SONATYPE_GUIDE_TOKEN: ${{ secrets.SONATYPE_GUIDE_TOKEN }}
run: ./gradlew vulnerabilityScan vulnerabilityScanReport --continue -PvulnerabilityScan.reportMaxBytes=60000
- name: "📋 Build Vulnerability Report"
if: always()
run: >
.github/scripts/vulnerabilityReport.sh
'🔍 Vulnerability Scan — pull request'
> /tmp/vulnerability-report.md
- name: "📝 Publish Vulnerability Summary"
if: always()
run: cat /tmp/vulnerability-report.md >> "$GITHUB_STEP_SUMMARY"
- name: "💬 Comment Vulnerability Report"
# A pull request from a fork runs with a read-only token, which cannot comment;
# its report is in the job summary instead.
if: always() && github.event.pull_request.head.repo.full_name == github.repository
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
.github/scripts/postStickyComment.sh
'${{ github.event.pull_request.number }}'
'<!-- grails-vulnerability-scan -->'
/tmp/vulnerability-report.md