From 5fb8aaa05aeb0298f41f2172bb7a10b9abfac8ca Mon Sep 17 00:00:00 2001 From: StepSecurity Bot Date: Wed, 28 Feb 2024 22:40:21 +0000 Subject: [PATCH 1/3] [StepSecurity] Apply security best practices Signed-off-by: StepSecurity Bot --- .github/dependabot.yml | 16 ++++ .github/workflows/PR-gcc-openmpi.yml | 10 ++- .github/workflows/clang_format.yml | 10 +-- .github/workflows/codeql.yml | 78 +++++++++++++++++++ .github/workflows/dependency-review.yml | 27 +++++++ .github/workflows/detect-git-lfs.yml | 5 +- .github/workflows/detect-mpi-comm-world.yml | 5 +- .github/workflows/flag_prs_to_master.yml | 4 +- .github/workflows/scorecards.yml | 71 +++++++++++++++++ .github/workflows/stale.yml | 2 +- .github/workflows/title_to_mention.yml | 4 +- .../tpetra_muelu_label_to_project.yml | 10 +-- 12 files changed, 223 insertions(+), 19 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 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000000..d7242a0f42c5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily + + - package-ecosystem: pip + directory: /cmake/tribits/doc/sphinx + schedule: + interval: daily + + - package-ecosystem: pip + directory: /packages/kokkos-kernels/docs + schedule: + interval: daily diff --git a/.github/workflows/PR-gcc-openmpi.yml b/.github/workflows/PR-gcc-openmpi.yml index 2f0b618aebf3..7eb91f341044 100644 --- a/.github/workflows/PR-gcc-openmpi.yml +++ b/.github/workflows/PR-gcc-openmpi.yml @@ -11,8 +11,14 @@ on: - develop workflow_dispatch: +permissions: + contents: read + jobs: trilogpu02-gcc: + permissions: + actions: write # for styfle/cancel-workflow-action to cancel/stop running workflows + contents: read # for actions/checkout to fetch code runs-on: [self-hosted, trilogpu02] container: image: registry-ex.sandia.gov/trilinos-project/trilinos-containers/rhel8/trilinos-pr-env:gcc-8.5.0 @@ -29,7 +35,7 @@ jobs: bash -l -c "module list" printenv PATH - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.11.0 + uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # 0.11.0 with: access_token: ${{ github.token }} - name: make dirs @@ -38,7 +44,7 @@ jobs: mkdir -p /home/Trilinos/src/Trilinos mkdir -p /home/Trilinos/build - name: Clone trilinos - uses: actions/checkout@v4 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: fetch-depth: 0 - name: Repo status diff --git a/.github/workflows/clang_format.yml b/.github/workflows/clang_format.yml index 95ec174a8123..ca6c86305fee 100644 --- a/.github/workflows/clang_format.yml +++ b/.github/workflows/clang_format.yml @@ -7,8 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: DoozyX/clang-format-lint-action@v0.16.2 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: DoozyX/clang-format-lint-action@1566bcec081dcb246ab02e7c5f9786c0b629dd4d # v0.16.2 with: source: './packages/muelu ./packages/tempus ./packages/teko ./packages/xpetra' exclude: './packages/tempus/examples' @@ -18,7 +18,7 @@ jobs: - run: git diff HEAD > format_patch.txt - run: if [ "$(cat format_patch.txt)" == "" ] ; then rm format_patch.txt ; else cat format_patch.txt; fi - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 id: upload-artf if: ${{ hashFiles('format_patch.txt') != '' }} with: @@ -32,13 +32,13 @@ jobs: # This does not work for PRs from forks. - name: Post artifact in issue comment - uses: mshick/add-pr-comment@v2.8.1 + uses: mshick/add-pr-comment@7c0890544fb33b0bdd2e59467fbacb62e028a096 # v2.8.1 if: ${{ (hashFiles('format_patch.txt') != '') && (github.event.pull_request.head.repo.full_name == github.repository) }} with: message: | Your PR updated files that did not respect package clang formatting settings. Please apply the patch found [here](${{ steps.upload-artf.outputs.artifact-url }}) - - uses: actions/github-script@v3 + - uses: actions/github-script@ffc2c79a5b2490bd33e0a41c1de74b877714d736 # v3.2.0 if: ${{ hashFiles('format_patch.txt') != '' }} with: script: | diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000000..560d45c17bc1 --- /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: ["master"] + pull_request: + # The branches below must be a subset of the branches above + branches: ["master"] + 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: ["cpp", "javascript", "python"] + # 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@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + 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@a56a03b370b87b26fde6d680755f818cfda0372b # v2.24.5 + 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@a56a03b370b87b26fde6d680755f818cfda0372b # v2.24.5 + + # ℹī¸ 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@a56a03b370b87b26fde6d680755f818cfda0372b # v2.24.5 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 000000000000..3f3456223b0a --- /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@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 + 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/detect-git-lfs.yml b/.github/workflows/detect-git-lfs.yml index c601f25358c4..42811f4d1eac 100644 --- a/.github/workflows/detect-git-lfs.yml +++ b/.github/workflows/detect-git-lfs.yml @@ -3,13 +3,16 @@ name: Check for git LFS pointers on: pull_request: +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: fetch-depth: 0 diff --git a/.github/workflows/detect-mpi-comm-world.yml b/.github/workflows/detect-mpi-comm-world.yml index 8ee7180ef044..8d6b57826631 100644 --- a/.github/workflows/detect-mpi-comm-world.yml +++ b/.github/workflows/detect-mpi-comm-world.yml @@ -3,13 +3,16 @@ name: Check MPI_COMM_WORLD on: pull_request: +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: fetch-depth: 0 diff --git a/.github/workflows/flag_prs_to_master.yml b/.github/workflows/flag_prs_to_master.yml index 151d8118ae5b..38cc6cb9da1e 100644 --- a/.github/workflows/flag_prs_to_master.yml +++ b/.github/workflows/flag_prs_to_master.yml @@ -19,12 +19,12 @@ jobs: steps: - name: Add label - uses: actions-ecosystem/action-add-labels@v1 + uses: actions-ecosystem/action-add-labels@18f1af5e3544586314bbe15c0273249c770b2daf # v1.1.3 if: "!contains(github.event.sender.login,'trilinos-autotester')" with: labels: "AT: WIP" - name: Add comment - uses: mshick/add-pr-comment@v2 + uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2.8.2 if: "!contains(github.event.sender.login,'trilinos-autotester')" with: message: | diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml new file mode 100644 index 000000000000..85f6e38986b3 --- /dev/null +++ b/.github/workflows/scorecards.yml @@ -0,0 +1,71 @@ +# 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: ["master"] + +# 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: "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@a56a03b370b87b26fde6d680755f818cfda0372b # v2.24.5 + with: + sarif_file: results.sarif diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index b931c1984ed5..bf8e74755e96 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -26,7 +26,7 @@ jobs: pull-requests: write # for actions/stale to close stale PRs runs-on: ubuntu-latest steps: - - uses: actions/stale@v4 + - uses: actions/stale@a20b814fb01b71def3bd6f56e7494d667ddf28da # v4.1.1 with: debug-only: false ascending: true diff --git a/.github/workflows/title_to_mention.yml b/.github/workflows/title_to_mention.yml index 9cbf1d83e8ce..f0c0be816763 100644 --- a/.github/workflows/title_to_mention.yml +++ b/.github/workflows/title_to_mention.yml @@ -18,14 +18,14 @@ jobs: steps: - name: Mention MueLu - uses: peter-evans/create-or-update-comment@v2 + uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d # v2.1.1 if: (contains(github.event.action, 'labeled') && contains(github.event.label.name, 'MueLu')) || (contains(github.event.action, 'opened') && contains(github.event.issue.title, 'MueLu')) with: issue-number: ${{ github.event.issue.number }} body: | Automatic mention of the @trilinos/muelu team - name: Mention Ifpack2 - uses: peter-evans/create-or-update-comment@v2 + uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d # v2.1.1 if: (contains(github.event.action, 'labeled') && contains(github.event.label.name, 'Ifpack2')) || (contains(github.event.action, 'opened') && contains(github.event.issue.title, 'Ifpack2')) with: issue-number: ${{ github.event.issue.number }} diff --git a/.github/workflows/tpetra_muelu_label_to_project.yml b/.github/workflows/tpetra_muelu_label_to_project.yml index 47ec3a77ebf3..8f856769c04a 100644 --- a/.github/workflows/tpetra_muelu_label_to_project.yml +++ b/.github/workflows/tpetra_muelu_label_to_project.yml @@ -13,13 +13,13 @@ permissions: jobs: assign_one_project: permissions: - issues: write # for actions/github-script@v6 + issues: write # for actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 repository-projects: write # for srggrs/assign-one-project-github-action to assign issues and PRs to repo project name: Assign to MueLu or Tpetra Project runs-on: ubuntu-latest steps: - name: Add MueLu Label - uses: actions/github-script@v6 + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 if: contains(github.event.issue.title, 'MueLu') with: script: | @@ -30,7 +30,7 @@ jobs: labels: ["pkg: MueLu"] }) - name: Add Tpetra Label - uses: actions/github-script@v6 + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 if: contains(github.event.issue.title, 'Tpetra') with: script: | @@ -41,13 +41,13 @@ jobs: labels: ["pkg: Tpetra"] }) - name: Add to MueLu Project - uses: srggrs/assign-one-project-github-action@1.3.0 + uses: srggrs/assign-one-project-github-action@37de3321023f8c12ea85372d748ab2017b995bfd # 1.3.0 if: contains(github.event.label.name, 'MueLu') || contains(github.event.issue.title, 'MueLu') with: project: 'https://github.com/trilinos/Trilinos/projects/5' column_name: 'Backlog' - name: Add to Tpetra Project - uses: srggrs/assign-one-project-github-action@1.3.0 + uses: srggrs/assign-one-project-github-action@37de3321023f8c12ea85372d748ab2017b995bfd # 1.3.0 if: contains(github.event.label.name, 'Tpetra') || contains(github.event.issue.title, 'Tpetra') with: project: 'https://github.com/trilinos/Trilinos/projects/2' From ca8439e760156acea9a5df8b58ceedd24e7802bb Mon Sep 17 00:00:00 2001 From: Chris Siefert Date: Wed, 28 Feb 2024 15:44:21 -0700 Subject: [PATCH 2/3] Update codeql.yml Down with javascript --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 560d45c17bc1..9b11aabd7118 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -35,7 +35,7 @@ jobs: strategy: fail-fast: false matrix: - language: ["cpp", "javascript", "python"] + language: ["cpp", "python"] # CodeQL supports [ $supported-codeql-languages ] # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support From 9025704e6285dd75a25bed7726a60e8315079c01 Mon Sep 17 00:00:00 2001 From: Chris Siefert Date: Wed, 28 Feb 2024 19:00:50 -0700 Subject: [PATCH 3/3] Delete .github/workflows/codeql.yml Because autobuild doesn't work --- .github/workflows/codeql.yml | 78 ------------------------------------ 1 file changed, 78 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 9b11aabd7118..000000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,78 +0,0 @@ -# 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: ["master"] - pull_request: - # The branches below must be a subset of the branches above - branches: ["master"] - 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: ["cpp", "python"] - # 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@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 - 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@a56a03b370b87b26fde6d680755f818cfda0372b # v2.24.5 - 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@a56a03b370b87b26fde6d680755f818cfda0372b # v2.24.5 - - # ℹī¸ 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@a56a03b370b87b26fde6d680755f818cfda0372b # v2.24.5 - with: - category: "/language:${{matrix.language}}"