From 44c7b9090ba7a6d22bb0c977514a58fa22973c0e Mon Sep 17 00:00:00 2001 From: "Marcus R. Brown" Date: Sat, 23 Nov 2024 21:31:11 -0700 Subject: [PATCH] ci: add QoL workflows (#641) --- .github/settings.yml | 3 +- .github/workflows/codeql-analysis.yaml | 43 +++++++++++++++ .github/workflows/dependency-review.yaml | 24 ++++++++ .github/workflows/scorecard.yaml | 70 ++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/codeql-analysis.yaml create mode 100644 .github/workflows/dependency-review.yaml create mode 100644 .github/workflows/scorecard.yaml diff --git a/.github/settings.yml b/.github/settings.yml index ccccd42c..e4537ee7 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -11,7 +11,8 @@ branches: protection: required_status_checks: strict: false - contexts: ['CI', 'Release', 'Renovate / Renovate'] + contexts: + ['Analyze', 'CI', 'CodeQL', 'Release', 'Renovate / Renovate', 'Review Dependencies'] enforce_admins: true required_pull_request_reviews: null restrictions: null diff --git a/.github/workflows/codeql-analysis.yaml b/.github/workflows/codeql-analysis.yaml new file mode 100644 index 00000000..48926061 --- /dev/null +++ b/.github/workflows/codeql-analysis.yaml @@ -0,0 +1,43 @@ +--- +name: CodeQL + +'on': + pull_request: + branches: [main] + push: + branches: [main] + schedule: + - cron: '54 19 * * 6' # Every Saturday at 7:54 PM UTC + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + analyze: + env: + language: javascript + name: Analyze + runs-on: ubuntu-latest + permissions: + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Initialize CodeQL + uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + with: + languages: ${{ env.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + with: + category: '/language:${{ env.language }}' diff --git a/.github/workflows/dependency-review.yaml b/.github/workflows/dependency-review.yaml new file mode 100644 index 00000000..30f8d5d2 --- /dev/null +++ b/.github/workflows/dependency-review.yaml @@ -0,0 +1,24 @@ +--- +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, +# surfacing known-vulnerable versions of the packages declared or updated in the PR. +# Once installed, if the workflow run is marked as required, +# PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +name: Dependency Review +'on': [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + name: Review Dependencies + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Dependency Review + uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0 diff --git a/.github/workflows/scorecard.yaml b/.github/workflows/scorecard.yaml new file mode 100644 index 00000000..91a1cfbc --- /dev/null +++ b/.github/workflows/scorecard.yaml @@ -0,0 +1,70 @@ +--- +# 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. + +name: Scorecard supply-chain security +'on': + # For Branch-Protection check. Only the default branch is supported. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection + branch_protection_rule: + # To guarantee Maintained check is occasionally updated. See + # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained + schedule: + - cron: '20 7 * * 2' # Every Tuesday at 7:20 AM UTC + push: + branches: ['main'] + +# Declare default permissions as read only. +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + # Needed to upload the results to code-scanning dashboard. + security-events: write + # Needed to publish results and get a badge (see publish_results below). + id-token: write + + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + + - name: Run analysis + uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0 + with: + results_file: results.sarif + results_format: sarif + # (Optional) "write" PAT token. Uncomment the `repo_token` line below if: + # - you want to enable the Branch-Protection check on a *public* repository, or + # - you are installing Scorecards on a *private* repository + # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat. + # repo_token: ${{ secrets.SCORECARD_TOKEN }} + + # Public repositories: + # - Publish results to OpenSSF REST API for easy access by consumers + # - Allows the repository to include the Scorecard badge. + # - See https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories: + # - `publish_results` will always be set to `false`, regardless + # of the value entered here. + publish_results: true + + # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF + # format to the repository Actions tab. + - name: Upload artifact + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + + # Upload the results to GitHub's code scanning dashboard. + - name: Upload to code-scanning + uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + with: + sarif_file: results.sarif