ci(pipelines): update #902
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
| --- | |
| # Copyright 2016-present Thomas Leplus | |
| # | |
| # 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. | |
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| # A sample workflow which sets up periodic OSV-Scanner scanning for vulnerabilities, | |
| # in addition to a PR check which fails if new vulnerabilities are introduced. | |
| # | |
| # For more examples and options, including how to ignore specific vulnerabilities, | |
| # see https://google.github.io/osv-scanner/github-action/ | |
| name: OSV Scanner | |
| on: | |
| push: | |
| branches: ["main"] | |
| schedule: | |
| - cron: "0 0 * * 0" | |
| workflow_dispatch: | |
| permissions: {} | |
| jobs: | |
| osv-scanner: | |
| permissions: | |
| # Required to upload the SARIF file to the security tab | |
| security-events: write | |
| # Required to read the code | |
| contents: read | |
| # Required to read the code | |
| actions: read | |
| uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@9a498708959aeaef5ef730655706c5a1df1edbc2" # v2.3.8 | |
| with: | |
| fail-on-vuln: false | |
| check: | |
| runs-on: ubuntu-latest | |
| needs: osv-scanner | |
| steps: | |
| - name: Check OSV scan results | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| # jq expression: | |
| # - iterate packages -> vulnerabilities -> full osv entry -> severity[] (type, score) | |
| # - extract numeric scores for CVSS types (cvss_v3 or numeric severity[].score) | |
| # - compare to threshold | |
| if echo "${RESULTS}" | jq ' | |
| .results[] | |
| | .packages[]? | |
| | .vulnerabilities[]? | |
| | ( .severity[]?.score // "" ) as $s | |
| | select($s != "") | |
| | ($s | tonumber) >= 4.0 | |
| ' | grep -q -e . ; then | |
| >&2 echo "error: found one or more vulnerabilities with a medium or higher severity (see step 'scan > osv-scanner > Run osv-scanner-reporter' for details)" | |
| exit 1 | |
| fi | |
| env: | |
| RESULTS: ${{ needs.osv-scanner.outputs.results }} |