diff --git a/.github/workflows/000-codeql.yaml b/.github/workflows/000-codeql.yaml index 60fe190..5310902 100644 --- a/.github/workflows/000-codeql.yaml +++ b/.github/workflows/000-codeql.yaml @@ -23,6 +23,9 @@ on: schedule: - cron: '41 9 * * 1' +permissions: + contents: read + jobs: analyze: name: Analyze @@ -42,12 +45,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@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@3e0e84636c6f5df46a2cb232ae1dd1384713150d # v2.25.15 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -75,7 +83,7 @@ jobs: ${GITHUB_WORKSPACE}/ux-src/MkGCC.sh ${GITHUB_WORKSPACE}/ux-src - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@3e0e84636c6f5df46a2cb232ae1dd1384713150d # v2.25.15 with: category: "/language:${{matrix.language}}" \ No newline at end of file diff --git a/.github/workflows/001-flawfinder.yaml b/.github/workflows/001-flawfinder.yaml index 0d8175e..63e225d 100644 --- a/.github/workflows/001-flawfinder.yaml +++ b/.github/workflows/001-flawfinder.yaml @@ -17,6 +17,9 @@ on: schedule: - cron: '45 19 * * 1' +permissions: + contents: read + jobs: flawfinder: name: Flawfinder @@ -26,8 +29,13 @@ jobs: contents: read security-events: write steps: + - name: Harden Runner + uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Prepare RISC OS source tree run: bash ${GITHUB_WORKSPACE}/.rocog/scripts/ux-src gen github ${GITHUB_WORKSPACE} @@ -39,4 +47,4 @@ jobs: output: 'flawfinder_results.sarif' - name: Upload analysis results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v2 \ No newline at end of file + uses: github/codeql-action/upload-sarif@3e0e84636c6f5df46a2cb232ae1dd1384713150d # v2.25.15 \ No newline at end of file diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 0000000..f072eab --- /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@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + + - name: 'Checkout Repository' + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: 'Dependency Review' + uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml new file mode 100644 index 0000000..7dce4f6 --- /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@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + + - name: "Checkout code" + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + persist-credentials: false + + - name: "Run analysis" + uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 + 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@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5 + 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@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15 + with: + sarif_file: results.sarif diff --git a/.github/workflows/sync-from-template.yaml b/.github/workflows/sync-from-template.yaml index fe46ebe..777714a 100644 --- a/.github/workflows/sync-from-template.yaml +++ b/.github/workflows/sync-from-template.yaml @@ -34,6 +34,9 @@ env: REPO_TEMPLATE: RISC-OS-Community/StandardRepoTemplate THIS_REPO: ${{ github.repository }} +permissions: + contents: read + jobs: sync-from-template: # Do not run on the template repository itself @@ -50,8 +53,13 @@ jobs: steps: # Clone the template repository + - name: Harden Runner + uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + - name: Check out template repository - uses: actions/checkout@v2 + uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0 with: repository: ${{ env.REPO_TEMPLATE }} token: ${{ github.token }} @@ -65,7 +73,7 @@ jobs: # Clone the target repository. Check out a branch - name: Check out ${{ github.repository }} - uses: actions/checkout@v2 + uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # v2.7.0 with: repository: ${{ github.repository }} token: ${{ github.token }} diff --git a/.github/workflows/tweet-pull-request.yaml b/.github/workflows/tweet-pull-request.yaml index ed87c73..e8160a8 100644 --- a/.github/workflows/tweet-pull-request.yaml +++ b/.github/workflows/tweet-pull-request.yaml @@ -25,6 +25,9 @@ on: env: THIS_REPO: ${{ github.repository }} +permissions: + contents: read + jobs: # init: # runs-on: ubuntu-latest @@ -42,10 +45,15 @@ jobs: tweet: runs-on: ubuntu-latest steps: + - name: Harden Runner + uses: step-security/harden-runner@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0 + with: + egress-policy: audit + - name: Set current date as env variable run: echo "MSG_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - name: Send Tweet - uses: ethomson/send-tweet-action@v1 + uses: ethomson/send-tweet-action@288f9339e0412e3038dce350e0da5ecdf12133a6 # v1.0.0 with: status: "🎉 Today: ${{ env.MSG_DATE }}, new merge in ${{ env.THIS_REPO }}! ${{ github.event.pull_request.title }} You can check it out here: https://github.com/${{ env.THIS_REPO }} #RISC_OS #RISCOS #ROCOnGitHub #OpenSource #DevCommunity" consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d8562a4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +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/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace