Skip to content

Commit 9c38680

Browse files
authored
Restrict token permissions (#1706)
1 parent a801a43 commit 9c38680

9 files changed

+48
-8
lines changed

.github/renovate.json5

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,17 @@
9999
"matchUpdateTypes": ["major"],
100100
"enabled": false,
101101
}
102+
],
103+
"customManagers": [
104+
{
105+
"customType": "regex",
106+
"datasourceTemplate": "npm",
107+
"fileMatch": [
108+
"^.github/workflows/"
109+
],
110+
"matchStrings": [
111+
"npx (?<depName>[^@]+)@(?<currentValue>[^\\s]+)"
112+
]
113+
}
102114
]
103115
}

.github/workflows/assign-reviewers.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ on:
88
# because repository write permission is needed to assign reviewers
99
pull_request_target:
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
assign-reviewers:
16+
permissions:
17+
contents: read
18+
pull-requests: write # for assigning reviewers
1319
runs-on: ubuntu-latest
1420
steps:
1521
- uses: open-telemetry/assign-reviewers-action@b101a9c17274e3d4fff0853898007e9e3a366675 # main

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
pull_request:
99
workflow_dispatch:
1010

11+
permissions:
12+
contents: read
13+
1114
concurrency:
1215
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
1316
cancel-in-progress: true
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
name: Issue management - remove needs feedback label
1+
name: Issue management - remove labels as needed
22

33
on:
44
issue_comment:
55
types: [created]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
issue_comment:
12+
permissions:
13+
contents: read
14+
issues: write
915
if: >
1016
contains(github.event.issue.labels.*.name, 'needs author feedback') &&
1117
github.event.comment.user.login == github.event.issue.user.login
1218
runs-on: ubuntu-latest
1319
steps:
1420
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1521

16-
- name: Remove label
22+
- name: Remove labels
1723
env:
1824
ISSUE_NUMBER: ${{ github.event.issue.number }}
1925
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2026
run: |
2127
gh issue edit --remove-label "needs author feedback" $ISSUE_NUMBER
28+
gh issue edit --remove-label "stale" $ISSUE_NUMBER

.github/workflows/issue-management-stale-action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ permissions:
1111
jobs:
1212
stale:
1313
permissions:
14+
contents: read
1415
issues: write # for actions/stale to close stale issues
1516
pull-requests: write # for actions/stale to close stale PRs
1617
runs-on: ubuntu-latest
@@ -21,11 +22,15 @@ jobs:
2122
days-before-stale: 7
2223
days-before-close: 7
2324
only-labels: "needs author feedback"
25+
stale-issue-label: stale
2426
stale-issue-message: >
2527
This has been automatically marked as stale because it has been marked
2628
as needing author feedback and has not had any activity for 7 days.
27-
It will be closed if no further activity occurs within 7 days of this comment.
29+
It will be closed automatically if there is no response from the author
30+
within 7 additional days from this comment.
31+
stale-pr-label: stale
2832
stale-pr-message: >
2933
This has been automatically marked as stale because it has been marked
3034
as needing author feedback and has not had any activity for 7 days.
31-
It will be closed if no further activity occurs within 7 days of this comment.
35+
It will be closed automatically if there is no response from the author
36+
within 7 additional days from this comment.

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Release
22
on:
33
workflow_dispatch:
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
build:
710
runs-on: ubuntu-latest
@@ -50,6 +53,8 @@ jobs:
5053
path: jmx-metrics/build/reports/tests/integrationTest
5154

5255
release:
56+
permissions:
57+
contents: write # for creating the release
5358
runs-on: ubuntu-latest
5459
needs:
5560
- build
@@ -186,6 +191,8 @@ jobs:
186191
echo "version=$VERSION" >> $GITHUB_OUTPUT
187192
188193
merge-change-log-to-main:
194+
permissions:
195+
contents: write # for git push to PR branch
189196
runs-on: ubuntu-latest
190197
needs:
191198
- release

.github/workflows/reusable-markdown-link-check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: Reusable - Markdown link check
33
on:
44
workflow_call:
55

6+
permissions:
7+
contents: read
8+
69
jobs:
710
markdown-link-check:
811
runs-on: ubuntu-latest

.github/workflows/reusable-markdown-lint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1414

15-
- name: Install markdownlint
16-
run: npm install -g markdownlint-cli
17-
1815
- name: Run markdownlint
1916
run: |
20-
markdownlint -c .github/config/markdown-lint-config.yml **/*.md
17+
npx markdownlint[email protected] -c .github/config/markdownlint.yml **/*.md

0 commit comments

Comments
 (0)