# Analyzes the code base and GitHub project configuration for adherence to
# security best practices for open source software. Identified issues are
# registered with GitHub's code scanning dashboard. When a pull request is
# analyzed, any offending lines are annotated. See
# https://securityscorecards.dev for details.
name: OpenSSF Scorecard update
on:
  pull_request:
  push:
    branches: [ master ]
  schedule:
    - cron: '0 4 * * 1'
permissions:
  contents: read
jobs:
  analyze:
    permissions:
      contents: read
      security-events: write
      id-token: write
    runs-on: ubuntu-22.04
    steps:
      - name: Install Harden-Runner
        uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
        with:
          disable-sudo: true
          egress-policy: block
          allowed-endpoints: >
            api.github.com:443
            api.osv.dev:443
            api.scorecard.dev:443
            api.securityscorecards.dev:443
            github.com:443
            oss-fuzz-build-logs.storage.googleapis.com:443
            *.sigstore.dev:443
            www.bestpractices.dev:443
      - name: Check out code
        uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
        with:
          persist-credentials: false
      - name: Run OpenSSF Scorecard analysis
        uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
        with:
          results_file: results.sarif
          results_format: sarif
          publish_results: ${{ github.ref == 'refs/heads/master' }}
      - name: Update GitHub's code scanning dashboard
        uses: github/codeql-action/upload-sarif@c7f9125735019aa87cfc361530512d50ea439c71 # v3.25.1
        with:
          sarif_file: results.sarif
