geyanggang commented on code in PR #14778: URL: https://github.com/apache/gravitino/pull/14778#discussion_r4547513047
########## .github/workflows/cve-scan.yml: ########## @@ -0,0 +1,345 @@ +# +# 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 +# +# http://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: CVE Scan + +# Weekly Trivy scan of the artifacts Gravitino ships. See .github/trivy/README.md for what is +# scanned, how to run the same scan locally and how exemptions work. +# +# A target (one shipped artifact) fails when a HIGH or CRITICAL finding remains after the +# exemptions in .github/trivy are applied, or when Trivy produced no valid report. Expired +# exemptions bring their findings back, so a red run is also the reminder to re-triage them. +on: + schedule: + - cron: '0 3 * * 1' # Mondays 03:00 UTC + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: cve-scan-${{ github.ref }} + cancel-in-progress: false + +env: + TRIVY_REPORT_DIR: ${{ github.workspace }}/trivy-reports + TARGET_DIR: ${{ github.workspace }}/trivy-targets + +jobs: + # Downloads the vulnerability DBs once per run. The scan jobs restore them read-only and run + # without network access. + trivy-db: + name: Trivy DB + # Forks can start the workflow manually, but only apache/gravitino runs the schedule. + if: github.event_name != 'schedule' || github.repository == 'apache/gravitino' + runs-on: ubuntu-latest + timeout-minutes: 20 + outputs: + cache-key: ${{ steps.key.outputs.cache-key }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Compute the cache key once for the whole run + id: key + run: echo "cache-key=trivy-db-v1-$(date -u +%Y-%m-%d)" >> "${GITHUB_OUTPUT}" + - name: Restore the DB cache + id: cache + uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + with: + path: ~/.cache/trivy + key: ${{ steps.key.outputs.cache-key }} + - name: Download the DBs + if: steps.cache.outputs.cache-hit != 'true' + run: | + .github/trivy/scan.sh pull + .github/trivy/scan.sh download-db + - name: Record the DB snapshot + run: .github/trivy/scan.sh db-info + + server: + name: Server packages + if: github.event_name != 'schedule' || github.repository == 'apache/gravitino' + needs: trivy-db + runs-on: ubuntu-latest + timeout-minutes: 90 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: ./.github/actions/setup-java-toolchains + - name: Free up disk space + run: dev/ci/util_free_space.sh + - name: Restore the DB cache + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 + with: + path: ~/.cache/trivy + key: ${{ needs.trivy-db.outputs.cache-key }} + fail-on-cache-miss: true + - name: Pull the Trivy image + run: .github/trivy/scan.sh pull + # The web UI is not built: its WAR holds a minified static export that Trivy cannot inspect. + # Its lock files are scanned in the lockfiles job (see .github/trivy/README.md). + - name: Build the server packages + run: ./gradlew compileDistribution compileIcebergRESTServer compileLanceRESTServer -PskipWeb=true -x test + # The standalone REST server directories hold the same third-party jars as the copies in + # distribution/package; they are scanned too so that each shipped package has its own report. + - name: Scan + run: | + rc=0 + .github/trivy/scan.sh scan server-distribution distribution/package || rc=1 + .github/trivy/scan.sh scan iceberg-rest-server distribution/gravitino-iceberg-rest-server || rc=1 + .github/trivy/scan.sh scan lance-rest-server distribution/gravitino-lance-rest-server || rc=1 + exit "${rc}" + - name: Upload the reports + if: ${{ !cancelled() }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: cve-scan-server + path: ${{ env.TRIVY_REPORT_DIR }} + retention-days: 30 + if-no-files-found: error Review Comment: Done: every upload step uses `warn` now, with a comment explaining that a missing report always follows an earlier failed step. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
