Skip to content

Commit 42bcfb8

Browse files
build: restrict permissions for commitlint (#195)
The pr-title workflow gives elevated pull-request write permissions to the third-party commitlint tool. This is a potential supply-chain vulnerability. This change restricts the permissions to only read for the commitlint tool. Signed-off-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
1 parent fef2b94 commit 42bcfb8

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

.github/workflows/pr_title.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ on:
44
pull_request_target:
55
types: [opened, edited, synchronize, reopened]
66

7+
# Default to the minimum read-only token for all jobs.
78
permissions:
8-
pull-requests: write
9+
contents: read
910

1011
jobs:
1112
commitlint:
1213
name: PR title / description conforms to semantic-release
1314
runs-on: ubuntu-latest
15+
outputs:
16+
outcome: ${{ steps.commitlint.outcome }}
1417
steps:
1518
- uses: actions/setup-node@v6
1619
with:
@@ -37,6 +40,14 @@ jobs:
3740
${{ github.event.pull_request.title }}
3841
3942
${{ github.event.pull_request.body }}
43+
44+
comment:
45+
name: Post / remove PR comment
46+
runs-on: ubuntu-latest
47+
needs: commitlint
48+
permissions:
49+
pull-requests: write
50+
steps:
4051
- uses: actions/github-script@v9
4152
with:
4253
script: |
@@ -45,14 +56,10 @@ jobs:
4556
const message = `${marker}
4657
**ACTION NEEDED**
4758
48-
Substrait follows the [Conventional Commits
49-
specification](https://www.conventionalcommits.org/en/v1.0.0/) for
50-
release automation.
59+
Substrait follows the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) for release automation.
5160
52-
The PR title and description are used as the merge commit message.
53-
Please update your PR title and description to match the specification.
54-
`;
55-
const passed = "${{ steps.commitlint.outcome }}" === "success";
61+
The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.`;
62+
const passed = "${{ needs.commitlint.outputs.outcome }}" === "success";
5663
5764
// Find an existing comment from this job, if any.
5865
const comments = await github.paginate(github.rest.issues.listComments, {

0 commit comments

Comments
 (0)