From c9277e0c5d6f079377f2dabef708b42863b89d40 Mon Sep 17 00:00:00 2001 From: mhucka Date: Tue, 17 Nov 2026 02:09:17 +0000 Subject: [PATCH] Update Scorecard scanner workflow This updates the workflow for Scorecard to resolve some security problems now flagged by Google's automated workflow scanners, and bring it in line with what is used in our other projects --- .github/workflows/ossf-scorecard.yaml | 60 --------------- .github/workflows/scorecard-scanner.yaml | 98 ++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/ossf-scorecard.yaml create mode 100644 .github/workflows/scorecard-scanner.yaml diff --git a/.github/workflows/ossf-scorecard.yaml b/.github/workflows/ossf-scorecard.yaml deleted file mode 100644 index 2caefeb..0000000 --- a/.github/workflows/ossf-scorecard.yaml +++ /dev/null @@ -1,60 +0,0 @@ -# Summary: workflow for OSSF Scorecard (https://github.com/ossf/scorecard). -# -# Scorecard is an automated tool that assesses a number of important heuristics -# associated with software security and assigns each check a score of 0-10. The -# use of Scorecard is suggested in Google's internal GitHub guidance -# (go/github-docs). -# -# Scorecard creates a report page at the following URL (for a repo ORG/REPO): -# https://scorecard.dev/viewer/?uri=github.com/ORG/REPO -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -name: Scorecard code scan -run-name: Run Scorecard code scan - -on: - schedule: - - cron: '19 20 * * 6' - - # Allow manual invocation. - workflow_dispatch: - -# Declare default permissions as read only. -permissions: read-all - -# Cancel any previously-started but still active runs on the same branch. -concurrency: - cancel-in-progress: true - group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}} - -jobs: - scorecard: - name: Perform Scorecard analysis - runs-on: ubuntu-22.04 - timeout-minutes: 10 - permissions: - # Needed to upload the results to the code-scanning dashboard. - security-events: write - # Needed to publish results and get a badge (see publish_results below). - id-token: write - steps: - - name: Check out a copy of the git repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - with: - persist-credentials: false - - - name: Run Scorecard analysis - uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1 - with: - # Save the results - results_file: results.sarif - results_format: sarif - - # Publish results to OpenSSF REST API. - # See https://github.com/ossf/scorecard-action#publishing-results. - publish_results: true - - - name: Upload results to code-scanning dashboard - uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3 - with: - sarif_file: results.sarif diff --git a/.github/workflows/scorecard-scanner.yaml b/.github/workflows/scorecard-scanner.yaml new file mode 100644 index 0000000..0ca3ea2 --- /dev/null +++ b/.github/workflows/scorecard-scanner.yaml @@ -0,0 +1,98 @@ +# Copyright 2026 Google LLC +# +# Licensed 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: Scorecard analysis +run-name: Run Scorecard analyzer + +# Scorecard (https://github.com/ossf/scorecard) is a repository-scanning tool +# that evaluates a project's security practices. Its use is suggested by +# Google's GitHub team. Scorecard's findings are reported in a repo's scanning +# results page, https://github.com/quantumlib/REPO/security/code-scanning/. + +on: + schedule: + # Run weekly on Saturdays. + - cron: '30 9 * * 6' + + pull_request: + types: + - opened + - synchronize + - reopened + - ready_for_review + branches: + - main + + workflow_dispatch: + +concurrency: + cancel-in-progress: true + group: ${{github.workflow}}-${{github.event.pull_request.number||github.ref}} + +permissions: {} + +jobs: + run-scorecard: + # Skip fork PRs to avoid "Analysis configuration not found" errors. + if: >- + github.repository_owner == 'quantumlib' && + (github.event_name != 'pull_request' || + github.event.pull_request.head.repo.fork == false) + name: Scorecard analyzer + runs-on: ubuntu-24.04 + permissions: + security-events: write + id-token: write + contents: read + actions: read + issues: read + pull-requests: read + checks: read + timeout-minutes: 15 + steps: + - name: Check out a copy of the git repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Run Scorecard analysis + # yamllint disable rule:line-length + uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0 + with: + results_file: scorecard-results.sarif + results_format: sarif + publish_results: true + + - name: Upload results to code-scanning dashboard + # yamllint disable rule:line-length + uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 + with: + sarif_file: scorecard-results.sarif + + # Scorecard doesn't allow submissions from jobs having steps that use "run:". + # Printing a summary needs to use "run:", so we have to use a separate job. + write-summary: + name: Scorecard results + needs: run-scorecard + runs-on: ubuntu-slim + timeout-minutes: 5 + steps: + - name: Write the Scorecard report page link to the workflow summary + run: | + repo="${{github.repository}}" + url="https://scorecard.dev/viewer/?uri=github.com/${repo}" + { + echo -n "The results are available on the OpenSSF Scorecard " + echo "[report page for ${{github.repository}}]($url)." + } >> "$GITHUB_STEP_SUMMARY"