Skip to content

Commit b0bc38c

Browse files
authored
Merge pull request #6000 from netomi/security-improvements-workflows
Apply various security improvements to GitHub workflows
2 parents f04cef8 + 608f46e commit b0bc38c

File tree

5 files changed

+50
-27
lines changed

5 files changed

+50
-27
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
groups:
8+
github-actions:
9+
patterns:
10+
- "*"

.github/workflows/claim-namespace.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
name: Claim Namespace
2+
3+
# The workflow is compromised as people can claim namespaces even though the claim is invalid.
4+
# Disable it for now to avoid further damage.
5+
26
on:
37
# alibi value to not show the workflow as broken
48
workflow_dispatch:
@@ -17,7 +21,7 @@ jobs:
1721
steps:
1822
- id: get_namespace
1923
name: Get namespace name
20-
uses: actions/github-script@v7
24+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
2125
with:
2226
script: |
2327
let namespace = context.payload.issue.title.substring('Claiming namespace'.length);
@@ -41,17 +45,19 @@ jobs:
4145
}
4246
- id: log_namespace
4347
name: Log namespace name
44-
run: echo '${{steps.get_namespace.outputs.namespace}}'
48+
run: echo '${NAMESPACE}'
49+
env:
50+
NAMESPACE: ${{steps.get_namespace.outputs.namespace}}
4551
- id: api_get_namespace
4652
name: Namespace API request
47-
uses: JamesIves/fetch-api-data-action@v2
53+
uses: JamesIves/fetch-api-data-action@e9b926da66aea24f5e628e11f36dfbab75dd7b0a # v2.4.2
4854
with:
4955
endpoint: https://open-vsx.org/api/${{steps.get_namespace.outputs.namespace}}
5056
configuration: '{ "method": "GET" }'
5157
- id: namespace_not_found_should_close
5258
if: ${{ failure() && steps.get_namespace.outputs.namespace != null }}
5359
name: Check issue is still open before editing issue
54-
uses: octokit/request-action@v2.x
60+
uses: octokit/request-action@dad4362715b7fb2ddedf9772c8670824af564f0d # v2.4.0
5561
with:
5662
route: GET /repos/{repo}/issues/{issue_number}
5763
repo: ${{ github.repository }}
@@ -71,20 +77,20 @@ jobs:
7177
ASSIGNEE: tfroment
7278
- id: api_get_namespace_members
7379
name: Namespace members API request
74-
uses: JamesIves/fetch-api-data-action@v2
80+
uses: JamesIves/fetch-api-data-action@e9b926da66aea24f5e628e11f36dfbab75dd7b0a # v2.4.2
7581
with:
7682
endpoint: https://open-vsx.org/admin/api/namespace/${{steps.get_namespace.outputs.namespace}}/members?token=${{secrets.OPENVSX_TOKEN}}
7783
configuration: '{ "method": "GET" }'
7884
- id: namespace_members
79-
uses: actions/github-script@v7
85+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
8086
env:
8187
DATA: ${{ steps.api_get_namespace_members.outputs.fetchApiData }}
8288
with:
8389
script: |
8490
const json = JSON.parse(process.env.DATA);
8591
core.setOutput('members', JSON.stringify(json.namespaceMemberships));
8692
- id: make_owner
87-
uses: actions/github-script@v7
93+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
8894
env:
8995
MEMBERS: ${{ steps.namespace_members.outputs.members }}
9096
LOGIN_NAME: ${{ github.event.issue.user.login }}
@@ -96,7 +102,7 @@ jobs:
96102
- id: should_change_member
97103
if: ${{ steps.make_owner.outputs.makeOwner == 'true' }}
98104
name: Check issue is still open before changing namespace membership
99-
uses: octokit/request-action@v2.x
105+
uses: octokit/request-action@dad4362715b7fb2ddedf9772c8670824af564f0d # v2.4.0
100106
with:
101107
route: GET /repos/{repo}/issues/{issue_number}
102108
repo: ${{ github.repository }}
@@ -106,7 +112,7 @@ jobs:
106112
- id: change_member
107113
name: Namespace change member API request
108114
if: ${{ steps.make_owner.outputs.makeOwner == 'true' && fromJSON(steps.should_change_member.outputs.data).state == 'open' }}
109-
uses: JamesIves/fetch-api-data-action@v2
115+
uses: JamesIves/fetch-api-data-action@e9b926da66aea24f5e628e11f36dfbab75dd7b0a # v2.4.2
110116
with:
111117
endpoint: https://open-vsx.org/admin/api/namespace/${{steps.get_namespace.outputs.namespace}}/change-member?user=${{github.event.issue.user.login}}&provider=github&role=owner&token=${{secrets.OPENVSX_TOKEN}}
112118
configuration: '{ "method": "POST" }'

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
run: echo ${{ github.event.number }} > PR_NUMBER.txt
1818
- name: Archive PR number
1919
if: github.event_name == 'pull_request'
20-
uses: actions/upload-artifact@v4
20+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2121
with:
2222
name: PR_NUMBER
2323
path: PR_NUMBER.txt

.github/workflows/smoketest.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ jobs:
1010
timeout-minutes: 60
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
1414
with:
1515
path: open-vsx.org
16-
- uses: actions/checkout@v4
16+
persist-credentials: false
17+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
1718
with:
1819
repository: eclipse/openvsx
1920
path: openvsx
20-
- uses: actions/setup-node@v4
21+
persist-credentials: false
22+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2123
with:
2224
node-version: 18.x
2325
- name: Install dependencies
@@ -36,7 +38,7 @@ jobs:
3638
run: sleep 10m
3739
- name: Get running server version
3840
id: running_version
39-
uses: fjogeleit/http-request-action@v1
41+
uses: fjogeleit/http-request-action@1297c6fc63a79b147d1676540a3fd9d2e37817c5 # v1.16.5
4042
with:
4143
url: "https://open-vsx.org/api/version"
4244
method: GET
@@ -48,15 +50,17 @@ jobs:
4850
if: steps.check_version.outputs.is_version == 'true'
4951
working-directory: ./openvsx/webui
5052
run: yarn smoke-tests
51-
- uses: actions/upload-artifact@v4
53+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
5254
if: steps.check_version.outputs.is_version == 'true'
5355
with:
5456
name: playwright-report
5557
path: openvsx/webui/playwright-report/
5658
retention-days: 30
5759
- name: Fail smoke test
5860
if: steps.check_version.outputs.is_version != 'true'
59-
uses: actions/github-script@v7
61+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
62+
env:
63+
VERSION: ${{ steps.read_version.outputs.version }}
6064
with:
6165
script: |
62-
core.setFailed('Deployed version is not ${{ steps.read_version.outputs.version }}')
66+
core.setFailed(`Deployed version is not ${process.env.VERSION}`)

.github/workflows/sonar.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99
permissions:
1010
pull-requests: read
1111
runs-on: ubuntu-latest
12-
if: github.event.workflow_run.conclusion == 'success'
12+
if: github.repository == 'EclipseFdn/open-vsx.org' && github.event.workflow_run.conclusion == 'success'
1313
steps:
1414
- name: Create artifacts directory
1515
run: mkdir -p ${{ runner.temp }}/artifacts
1616
- name: Download PR number artifact
1717
if: github.event.workflow_run.event == 'pull_request'
18-
uses: dawidd6/action-download-artifact@v6
18+
uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6
1919
with:
2020
workflow: Build
2121
run_id: ${{ github.event.workflow_run.id }}
@@ -24,37 +24,40 @@ jobs:
2424
- name: Read PR_NUMBER.txt
2525
if: github.event.workflow_run.event == 'pull_request'
2626
id: pr_number
27-
uses: juliangruber/read-file-action@v1
27+
uses: juliangruber/read-file-action@b549046febe0fe86f8cb4f93c24e284433f9ab58 # v1.1.7
2828
with:
2929
path: ${{ runner.temp }}/artifacts/PR_NUMBER.txt
3030
- name: Request GitHub API for PR data
3131
if: github.event.workflow_run.event == 'pull_request'
32-
uses: octokit/request-action@v2.x
32+
uses: octokit/request-action@dad4362715b7fb2ddedf9772c8670824af564f0d # v2.4.0
3333
id: get_pr_data
3434
with:
3535
route: GET /repos/{full_name}/pulls/{number}
3636
number: ${{ steps.pr_number.outputs.content }}
3737
full_name: ${{ github.event.repository.full_name }}
3838
env:
3939
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
- uses: actions/checkout@v4
40+
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
4141
with:
4242
repository: ${{ github.event.workflow_run.head_repository.full_name }}
4343
ref: ${{ github.event.workflow_run.head_branch }}
4444
fetch-depth: 0
45+
persist-credentials: false
4546
- name: Checkout base branch
4647
if: github.event.workflow_run.event == 'pull_request'
4748
env:
4849
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
50+
CLONE_URL: ${{ github.event.repository.clone_url }}
51+
BASE_REF: ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
4952
run: |
50-
git remote add upstream ${{ github.event.repository.clone_url }}
53+
git remote add upstream ${CLONE_URL}
5154
git fetch upstream
52-
git checkout -B ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }} upstream/${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
53-
git checkout $HEAD_BRANCH
55+
git checkout -B ${BASE_REF} upstream/${BASE_REF}
56+
git checkout ${HEAD_BRANCH}
5457
git clean -ffdx && git reset --hard HEAD
5558
- name: SonarCloud Scan on PR
5659
if: github.event.workflow_run.event == 'pull_request'
57-
uses: SonarSource/sonarqube-scan-action@master
60+
uses: SonarSource/sonarqube-scan-action@2f77a1ec69fb1d595b06f35ab27e97605bdef703 # v5.3.2
5861
env:
5962
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6063
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -66,7 +69,7 @@ jobs:
6669
-Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
6770
- name: SonarCloud Scan on push
6871
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.head_repository.full_name == github.event.repository.full_name
69-
uses: SonarSource/sonarqube-scan-action@master
72+
uses: SonarSource/sonarqube-scan-action@2f77a1ec69fb1d595b06f35ab27e97605bdef703 # v5.3.2
7073
env:
7174
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7275
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)