Skip to content

Commit 9330ea5

Browse files
sashashuraBurntSushi
authored andcommitted
ci: harden configuration
This makes it so the permissions are locked down by default. The threat model here is something like, "what happens if an authorized party gains control of the non-PR CI configuration somehow." To be honest, I (BurntSushi) don't quite understand how that might happen without also the ability to set the permissions itself. But locking permissions down by default does seem like a good and sensible thing to do. Closes #932
1 parent ac2d0e1 commit 9330ea5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: .github/workflows/ci.yml

+21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ on:
66
- master
77
schedule:
88
- cron: '00 01 * * *'
9+
10+
# The section is needed to drop write-all permissions that are granted on
11+
# `schedule` event. By specifying any permission explicitly all others are set
12+
# to none. By using the principle of least privilege the damage a compromised
13+
# workflow can do (because of an injection or compromised third party tool or
14+
# action) is restricted. Currently the worklow doesn't need any additional
15+
# permission except for pulling the code. Adding labels to issues, commenting
16+
# on pull-requests, etc. may need additional permissions:
17+
#
18+
# Syntax for this section:
19+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
20+
#
21+
# Reference for how to assign permissions on a job-by-job basis:
22+
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
23+
#
24+
# Reference for available permissions that we can enable if needed:
25+
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
26+
permissions:
27+
# to fetch code (actions/checkout)
28+
contents: read
29+
930
jobs:
1031
test:
1132
name: test

0 commit comments

Comments
 (0)