Skip to content

Commit 357d2fe

Browse files
authored
chore: apply security best practices and onboard stepsecurity (#131)
This pull request updates the GitHub Actions workflows to improve security and reliability. The main changes include hardening the CI runners, pinning action versions to specific commit SHAs, and updating permissions for certain jobs. **Security hardening and workflow improvements:** * Added the `step-security/harden-runner` action to all workflows (`commit-lint.yml`, `npm-publish.yml`, `pull_request_checks.yml`), blocking all network egress except for globally allowed endpoints. [[1]](diffhunk://#diff-f9aa500b86b242f58f185509ad323b3526cf5effc683df4b5cb4d78df4108c5fR7-R26) [[2]](diffhunk://#diff-8a5ce8b612395836520d0655143f732d08e747af57f3cfe76b5e283600106240L16-R23) [[3]](diffhunk://#diff-ae3a094ad37eeebef2d33cfc7571af414c00ce49e02be88f32f3de2905a8a2d1L12-R19) * Replaced version tags for `actions/checkout` and `actions/setup-node` with specific commit SHAs to prevent supply chain attacks. [[1]](diffhunk://#diff-f9aa500b86b242f58f185509ad323b3526cf5effc683df4b5cb4d78df4108c5fR7-R26) [[2]](diffhunk://#diff-8a5ce8b612395836520d0655143f732d08e747af57f3cfe76b5e283600106240L16-R23) [[3]](diffhunk://#diff-ae3a094ad37eeebef2d33cfc7571af414c00ce49e02be88f32f3de2905a8a2d1L12-R19) * Pinned AWS-related actions (`aws-actions/configure-aws-credentials`, `aws-actions/aws-secretsmanager-get-secrets`) to specific commit SHAs in `npm-publish.yml`. **Permissions and access control:** * Added or updated `permissions` blocks to restrict and explicitly define required permissions for jobs, including granting `id-token: write` where needed for OIDC authentication. [[1]](diffhunk://#diff-f9aa500b86b242f58f185509ad323b3526cf5effc683df4b5cb4d78df4108c5fR7-R26) [[2]](diffhunk://#diff-8a5ce8b612395836520d0655143f732d08e747af57f3cfe76b5e283600106240R32-R56)
1 parent 5b34ebb commit 357d2fe

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

.github/workflows/commit-lint.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,26 @@ on:
44
pull_request:
55
branches: [master]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
commit_lint:
912
name: "Lint commit messages"
1013
runs-on: ubuntu-latest
14+
permissions:
15+
id-token: write
1116
steps:
12-
- uses: actions/checkout@v4
17+
- name: Harden the runner
18+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
19+
with:
20+
egress-policy: block
21+
policy: global-allowed-endpoints-policy
22+
23+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
1324
with:
1425
fetch-depth: 0
15-
- uses: actions/setup-node@v4
26+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1627
with:
1728
node-version: 16
1829
- run: yarn install --frozen-lockfile

.github/workflows/npm-publish.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ jobs:
1313
build:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v4
17-
- uses: actions/setup-node@v4
16+
- name: Harden the runner
17+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
18+
with:
19+
egress-policy: block
20+
policy: global-allowed-endpoints-policy
21+
22+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
23+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1824
with:
1925
node-version: 16
2026
- run: yarn install --frozen-lockfile
@@ -23,23 +29,31 @@ jobs:
2329
publish-npm:
2430
needs: build
2531
runs-on: ubuntu-latest
32+
permissions:
33+
id-token: write
2634
steps:
27-
- uses: actions/checkout@v4
28-
- uses: actions/setup-node@v4
35+
- name: Harden the runner
36+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
37+
with:
38+
egress-policy: block
39+
policy: global-allowed-endpoints-policy
40+
41+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
42+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2943
with:
3044
node-version: 16
3145
registry-url: https://registry.npmjs.com/
3246
- run: yarn install --frozen-lockfile
3347
- run: yarn run build
3448

3549
- name: Configure AWS Credentials
36-
uses: aws-actions/configure-aws-credentials@v4
50+
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1
3751
with:
3852
aws-region: us-east-1
3953
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID_PAY }}:role/github-actions-service-role
4054

4155
- name: Read secrets from AWS Secrets Manager into environment variables
42-
uses: aws-actions/aws-secretsmanager-get-secrets@v2.0.5
56+
uses: aws-actions/aws-secretsmanager-get-secrets@98c2d6bf1dd67c2575fa2bb14294aa64103d426c # v2.0.5
4357
with:
4458
secret-ids: |
4559
/prod/circle-nodejs-sdk/npm/automation-token

.github/workflows/pull_request_checks.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ jobs:
88
lint:
99
name: "Lint, Build and Test"
1010
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
1113
steps:
12-
- uses: actions/checkout@v4
13-
- uses: actions/setup-node@v4
14+
- name: Harden the runner
15+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
16+
with:
17+
egress-policy: block
18+
policy: global-allowed-endpoints-policy
19+
20+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
21+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
1422
- name: Installing dependencies
1523
run: yarn install --frozen-lockfile
1624
- name: Prettier check

0 commit comments

Comments
 (0)