From 17d9032cd31fffb7b201c5d024c04f5a3d4bfabd Mon Sep 17 00:00:00 2001 From: StepSecurity Bot Date: Sun, 29 Dec 2024 07:12:33 -0800 Subject: [PATCH] Improve code score card (#1999) --- .github/dependabot.yml | 11 +++++ .github/workflows/Build and test.yml | 54 ++++++++++++++++++++----- .github/workflows/codeql.yml | 16 ++++++-- .github/workflows/dependency-review.yml | 27 +++++++++++++ .github/workflows/scorecard.yml | 5 +++ 5 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dependency-review.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..8b2c4c078 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + + - package-ecosystem: npm + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/Build and test.yml b/.github/workflows/Build and test.yml index 353c50e39..f5067d6cb 100644 --- a/.github/workflows/Build and test.yml +++ b/.github/workflows/Build and test.yml @@ -10,56 +10,88 @@ permissions: read-all jobs: Build: + permissions: + contents: write runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - - uses: actions/checkout@v4 - - name: Bulid from src - uses: useblacksmith/setup-node@v5 + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Build from src + uses: useblacksmith/setup-node@65c6ca86fdeb0ab3d85e78f57e4f6a7e4780b391 # v5.0.4 with: node-version: '20.x' + - run: yarn install --frozen-lockfile - run: yarn build-only - - uses: actions/upload-artifact@master + + - uses: actions/upload-artifact@v3 with: name: dist path: dist/ + - run: tar -cvf node_modules.tar node_modules - - uses: actions/upload-artifact@master + + - uses: actions/upload-artifact@v3 with: name: node_modules path: node_modules.tar test_node: + permissions: + contents: read needs: Build runs-on: blacksmith-4vcpu-ubuntu-2204 strategy: matrix: node-version: [15.x, 16.x, 17.x, 18.x, 19.x, latest] steps: - - uses: actions/checkout@v4 + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Run prod version with Node v${{ matrix.node-version }} - uses: useblacksmith/setup-node@v5 + uses: useblacksmith/setup-node@65c6ca86fdeb0ab3d85e78f57e4f6a7e4780b391 # v5.0.4 with: node-version: ${{ matrix.node-version }} - - uses: actions/download-artifact@master + + - uses: actions/download-artifact@2a5974104b6d5dbdb2f9468a3e54da3bdd241578 # master with: name: dist path: dist/ - - uses: actions/download-artifact@master + + - uses: actions/download-artifact@2a5974104b6d5dbdb2f9468a3e54da3bdd241578 # master with: name: node_modules path: ./ + - run: tar -xvf node_modules.tar - run: yarn test-only test_browser: + permissions: + contents: read needs: Build runs-on: blacksmith-4vcpu-ubuntu-2204 steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@master + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - uses: actions/download-artifact@2a5974104b6d5dbdb2f9468a3e54da3bdd241578 # master with: name: dist path: dist/ + - run: echo '::warning ::Not able to automate browser tests yet' - run: '# yarn test-browser-ci' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f2c9a4f52..092756d45 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -20,6 +20,9 @@ on: schedule: - cron: '32 13 * * 0' +permissions: + contents: read + jobs: analyze: name: Analyze @@ -45,12 +48,17 @@ jobs: # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -64,7 +72,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v3 + uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 # ℹī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -77,6 +85,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 000000000..21a469b13 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,27 @@ +# 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: + runs-on: ubuntu-latest + steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + + - 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.yml b/.github/workflows/scorecard.yml index 015aa536e..bf84ac926 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -31,6 +31,11 @@ jobs: # actions: read steps: + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit + - name: "Checkout code" uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: