GH Actions: "pin" all action runners
Recently there has been more and more focus on securing GH Actions workflows - in part due to some incidents.
The problem with "unpinned" action runners is as follows:
* Tags are mutable, which means that a tag could point to a safe commit today, but to a malicious commit tomorrow.
Note that GitHub is currently beta-testing a new "immutable releases" feature (= tags and release artifacts can not be changed anymore once the release is published), but whether that has much effect depends on the ecosystem of the packages using the feature.
Aside from that, it will likely take years before all projects adopt _immutable releases_.
* Action runners often don't even point to a tag, but to a branch, making the used action runner a moving target.
_Note: this type of "floating major" for action runners used to be promoted as good practice when the ecosystem was "young". Insights have since changed._
While it is convenient to use "floating majors" of action runners, as this means you only need to update the workflows on a new major release of the action runner, the price is higher risk of malicious code being executed in workflows.
Dependabot, by now, can automatically submit PRs to update pinned action runners too, as long as the commit-hash pinned runner is followed by a comment listing the released version the commit is pointing to.
So, what with Dependabot being capable of updating workflows with pinned action runners, I believe it is time to update the workflows to the _current_ best practice of using commit-hash pinned action runners.
The downside of this change is that there will be more frequent Dependabot PRs.
If this would become a burden/irritating, the following mitigations can be implemented:
1. Updating the Dependabot config to group updates instead of sending individual PRs per action runner.
2. A workflow to automatically merge Dependabot PRs as long as CI passes.
Includes updating the version for `ossf/scorecard-action` as it was a couple of version behind.
Ref: https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions
This commit is contained in:
parent
6f0f7a7f68
commit
086dfbe727
|
|
@ -14,13 +14,13 @@ jobs:
|
|||
if: github.repository == 'PHPMailer/PHPMailer'
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Build Docs
|
||||
uses: ./.github/actions/build-docs
|
||||
- name: Publish Docs to gh-pages
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4.7.3
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: docs
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46
|
||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
|
|
@ -52,7 +52,7 @@ jobs:
|
|||
# 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@v4
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
|
|
@ -60,6 +60,6 @@ jobs:
|
|||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
uses: github/codeql-action/upload-sarif@192325c86100d080feab897ff886c34abd4c83a3 # v3.30.3
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
|
||||
with:
|
||||
php-version: 'latest'
|
||||
coverage: none
|
||||
|
|
@ -29,7 +29,7 @@ jobs:
|
|||
# Install dependencies and handle caching in one go.
|
||||
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
|
||||
- name: Install Composer dependencies
|
||||
uses: "ramsey/composer-install@v3"
|
||||
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
|
||||
with:
|
||||
# Bust the cache at least once a month - output format: YYYY-MM.
|
||||
custom-cache-suffix: $(date -u "+%Y-%m")
|
||||
|
|
@ -57,10 +57,10 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||
|
||||
- name: Install PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
ini-values: error_reporting=-1, display_errors=On, display_startup_errors=On
|
||||
|
|
@ -70,7 +70,7 @@ jobs:
|
|||
# Install dependencies and handle caching in one go.
|
||||
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
|
||||
- name: Install Composer dependencies
|
||||
uses: "ramsey/composer-install@v3"
|
||||
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
|
||||
with:
|
||||
# Bust the cache at least once a month - output format: YYYY-MM.
|
||||
custom-cache-suffix: $(date -u "+%Y-%m")
|
||||
|
|
@ -127,7 +127,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||
|
||||
# About the "extensions":
|
||||
#
|
||||
|
|
@ -157,7 +157,7 @@ jobs:
|
|||
fi
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
|
||||
|
|
@ -168,7 +168,7 @@ jobs:
|
|||
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
|
||||
- name: Install PHP packages - normal
|
||||
if: ${{ matrix.php != '8.5' }}
|
||||
uses: "ramsey/composer-install@v3"
|
||||
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
|
||||
with:
|
||||
composer-options: ${{ steps.set_extensions.outputs.COMPOSER_OPTIONS }}
|
||||
# Bust the cache at least once a month - output format: YYYY-MM.
|
||||
|
|
@ -176,7 +176,7 @@ jobs:
|
|||
|
||||
- name: Install PHP packages - ignore-platform-reqs
|
||||
if: ${{ matrix.php == '8.5' }}
|
||||
uses: "ramsey/composer-install@v3"
|
||||
uses: "ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520" # 3.1.1
|
||||
with:
|
||||
composer-options: --ignore-platform-reqs ${{ steps.set_extensions.outputs.COMPOSER_OPTIONS }}
|
||||
# Bust the cache at least once a month - output format: YYYY-MM.
|
||||
|
|
@ -185,7 +185,7 @@ jobs:
|
|||
# Install postfix and automatically retry if the install failed, which happens reguarly.
|
||||
# @link https://github.com/marketplace/actions/retry-step
|
||||
- name: Install postfix
|
||||
uses: nick-invision/retry@v3
|
||||
uses: nick-invision/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
|
||||
with:
|
||||
timeout_minutes: 2
|
||||
max_attempts: 3
|
||||
|
|
@ -214,7 +214,7 @@ jobs:
|
|||
|
||||
- name: Send coverage report to Codecov
|
||||
if: ${{ success() && matrix.coverage == true }}
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
with:
|
||||
|
|
|
|||
Loading…
Reference in New Issue