From 3ca50a7e803a81e27292a88d0221330f28eeba03 Mon Sep 17 00:00:00 2001 From: StepSecurity Bot Date: Thu, 13 Jun 2024 14:35:58 +0000 Subject: [PATCH] [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot --- .github/dependabot.yml | 11 ++ .github/workflows/ci_cd.yml | 190 ++++++++++++++++-------- .github/workflows/codeql.yml | 78 ++++++++++ .github/workflows/dependency-review.yml | 27 ++++ .github/workflows/scorecards.yml | 76 ++++++++++ .pre-commit-config.yaml | 18 +++ 6 files changed, 340 insertions(+), 60 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/dependency-review.yml create mode 100644 .github/workflows/scorecards.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..bb85b6f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + + - package-ecosystem: npm + directory: / + schedule: + interval: daily diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index d6400d8..e1fdaa9 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -13,17 +13,22 @@ jobs: name: Run Unit Tests runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies run: npm ci - name: Run Unit Tests run: npm test - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 with: directory: ./coverage/ verbose: true @@ -32,10 +37,15 @@ jobs: name: Run Integration Tests runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -48,7 +58,7 @@ jobs: timeout_minutes: 1 max_attempts: 2 command: npm -v - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: true actual: ${{ steps.happy_path.outputs.total_attempts == '1' && steps.happy_path.outputs.exit_code == '0' }} @@ -67,11 +77,11 @@ jobs: timeout_minutes: 1 max_attempts: 2 command: node -e "process.exit(1)" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.sad_path_error.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.sad_path_error.outcome }} @@ -85,15 +95,15 @@ jobs: max_attempts: 3 retry_on: timeout command: node -e "process.exit(2)" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 1 actual: ${{ steps.retry_on_timeout_fail.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.retry_on_timeout_fail.outcome }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.retry_on_timeout_fail.outputs.exit_code }} @@ -107,15 +117,15 @@ jobs: max_attempts: 2 retry_on: error command: node -e "process.exit(2)" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.retry_on_error.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.retry_on_error.outcome }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.retry_on_error.outputs.exit_code }} @@ -129,11 +139,11 @@ jobs: max_attempts: 2 shell: cmd command: 'dir' - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.wrong_shell.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.wrong_shell.outcome }} @@ -142,10 +152,15 @@ jobs: name: Run Integration Env Var Tests runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -163,10 +178,15 @@ jobs: name: Run Integration Large Output Tests runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -180,12 +200,12 @@ jobs: timeout_minutes: 5 command: 'make -C ./test-data/large-output bytes-102400' - name: Assert test had expected result - uses: nick-invision/assert-action@v1 + uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.large-output.outcome }} - name: Assert exit code is expected - uses: nick-invision/assert-action@v1 + uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.large-output.outputs.exit_code }} @@ -194,10 +214,15 @@ jobs: name: Run Integration retry_on_exit_code Tests runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -211,11 +236,11 @@ jobs: retry_on_exit_code: 2 max_attempts: 3 command: node -e "process.exit(2)" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.retry_on_exit_code_expected.outcome }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 3 actual: ${{ steps.retry_on_exit_code_expected.outputs.total_attempts }} @@ -229,11 +254,11 @@ jobs: retry_on_exit_code: 2 max_attempts: 3 command: node -e "process.exit(1)" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.retry_on_exit_code_unexpected.outcome }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 1 actual: ${{ steps.retry_on_exit_code_unexpected.outputs.total_attempts }} @@ -242,10 +267,15 @@ jobs: name: Run Integration continue_on_error Tests runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -265,22 +295,22 @@ jobs: timeout_minutes: 1 continue_on_error: true - name: Verify continue_on_error returns correct exit code on success - uses: nick-invision/assert-action@v1 + uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 0 actual: ${{ steps.happy_path_continue_on_error.outputs.exit_code }} - name: Verify continue_on_error exits with correct outcome on success - uses: nick-invision/assert-action@v1 + uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: success actual: ${{ steps.happy_path_continue_on_error.outcome }} - name: Verify continue_on_error returns correct exit code on error - uses: nick-invision/assert-action@v1 + uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 33 actual: ${{ steps.sad_path_continue_on_error.outputs.exit_code }} - name: Verify continue_on_error exits with successful outcome when an error occurs - uses: nick-invision/assert-action@v1 + uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: success actual: ${{ steps.sad_path_continue_on_error.outcome }} @@ -289,10 +319,15 @@ jobs: name: Run Integration Tests (retry_wait_seconds) runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -307,15 +342,15 @@ jobs: max_attempts: 3 retry_wait_seconds: 15 command: npm install this-isnt-a-real-package-name-zzz - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 3 actual: ${{ steps.sad_path_wait_sec.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.sad_path_wait_sec.outcome }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 'Final attempt failed' actual: ${{ steps.sad_path_wait_sec.outputs.exit_error }} @@ -325,10 +360,15 @@ jobs: name: Run Integration Tests (on_retry_command) runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -368,10 +408,15 @@ jobs: name: Run Integration Timeout Tests (seconds) runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -385,11 +430,11 @@ jobs: timeout_seconds: 15 max_attempts: 2 command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.sad_path_timeout.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.sad_path_timeout.outcome }} @@ -398,10 +443,15 @@ jobs: name: Run Integration Timeout Tests (retry_on timeout) runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -416,11 +466,11 @@ jobs: max_attempts: 2 retry_on: timeout command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.retry_on_timeout.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.retry_on_timeout.outcome }} @@ -429,10 +479,15 @@ jobs: name: Run Integration Timeout Tests (retry_on error) runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -447,15 +502,15 @@ jobs: max_attempts: 2 retry_on: error command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 1 actual: ${{ steps.retry_on_error_fail.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.retry_on_error_fail.outcome }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 1 actual: ${{ steps.retry_on_error_fail.outputs.exit_code }} @@ -464,10 +519,15 @@ jobs: name: Run Integration Timeout Tests (minutes) runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -481,11 +541,11 @@ jobs: timeout_minutes: 1 max_attempts: 2 command: node -e "(async()=>await new Promise(r => setTimeout(r, 120000)))()" - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: 2 actual: ${{ steps.sad_path_timeout_minutes.outputs.total_attempts }} - - uses: nick-invision/assert-action@v1 + - uses: nick-invision/assert-action@1e012cc9f1bf73ccc96470b56c8887478c647e8a # v1.3.1 with: expected: failure actual: ${{ steps.sad_path_timeout_minutes.outcome }} @@ -494,10 +554,15 @@ jobs: name: Run Windows Tests runs-on: windows-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: 20 - name: Install dependencies @@ -561,4 +626,9 @@ jobs: ] runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + - run: echo "If this is hit, all tests successfully passed" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..7393ce7 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,78 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: ["main"] + pull_request: + # The branches below must be a subset of the branches above + branches: ["main"] + schedule: + - cron: "0 0 * * 1" + +permissions: + contents: read + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: ["javascript", "typescript"] + # CodeQL supports [ $supported-codeql-languages ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@b9bbe2d60639154188464569b9ad28bdf33eab91 # v2.25.9 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@b9bbe2d60639154188464569b9ad28bdf33eab91 # v2.25.9 + + # ℹī¸ 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 + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@b9bbe2d60639154188464569b9ad28bdf33eab91 # v2.25.9 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..ce491d1 --- /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@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + + - name: 'Checkout Repository' + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - name: 'Dependency Review' + uses: actions/dependency-review-action@0efb1d1d84fc9633afcdaad14c485cbbc90ef46c # v2.5.1 diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml new file mode 100644 index 0000000..479aa0f --- /dev/null +++ b/.github/workflows/scorecards.yml @@ -0,0 +1,76 @@ +# 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' + 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 + contents: read + actions: read + + steps: + - name: Harden Runner + uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1 + with: + egress-policy: audit + + - name: "Checkout code" + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@99c53751e09b9529366343771cc321ec74e9bd3d # v2.0.6 + 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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.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@b9bbe2d60639154188464569b9ad28bdf33eab91 # v2.25.9 + with: + sarif_file: results.sarif diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..723e338 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: +- repo: https://github.com/gitleaks/gitleaks + rev: v8.16.3 + hooks: + - id: gitleaks +- repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: shellcheck +- repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.38.0 + hooks: + - id: eslint +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace