-
Notifications
You must be signed in to change notification settings - Fork 25
chore: eject repo policy compliance #665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2c94bc1
7ba3881
f19bbe7
8134a51
ef9b73c
d753dc7
89f2bad
4ffd599
4ecc739
2498169
dc3f022
1e10fff
d1d4c52
953fcb5
dc7c75d
f2c7378
e2350d0
32f9818
1eea0f7
56a182e
596a559
1e796ff
9200a9b
81fa6ec
d4a3453
7134402
a850b00
3ef26d0
5c3934b
f295341
97e063f
f528f45
2ffb626
ada2718
0e7133d
4b56fcd
eb7a72a
03102bb
ebcffe6
9e44423
3784ddb
4a7030c
2f8b0cd
ee2edee
8ed2ac2
54caba5
2cf25d9
6c938ad
23d0713
f40df95
ee73b59
aa7e39d
4114abe
68f8de6
cf571e2
f5cb83a
ff22f45
d89fd73
3f24503
185dc80
9220288
376cf5f
16a5a0c
3f3d3e5
4a47297
39c1a3f
3f76829
2f8bbad
f2c46a4
2db2abe
ecd2bda
459b1e8
00817b2
6a3a4fc
be8ab20
b5b39a9
9ea9786
85574bb
fbeb9d6
6d97fae
1e764f5
35fb1d2
ee17ea1
461744d
62ea95a
33d49e6
c323b96
30dc913
1a1a037
dadbf41
9886120
f51a1f4
cf54f91
f4b381e
eb8eb5b
2257373
86e6e0d
6946e3b
f166696
3e239c6
0b65ae2
445f252
86ba951
15d7e07
258789e
d6d3cde
c94f60a
18ac204
8ff827c
157d269
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,12 +6,13 @@ | |
|
|
||
| The charm manages GitHub self-hosted runners to run GitHub Actions jobs. This allows users on GitHub to execute code on the servers hosting the runners, which poses a remote code execution risk if the code is not trusted. Therefore, the charm should only spawn runners to trusted organizations or repositories. | ||
|
|
||
| For third-party contributions, the charm can integrate with the [Repo Policy Compliance charm](https://charmhub.io/repo-policy-compliance) to manage the repository policy. With this integration, the self-hosted runner will not execute the GitHub jobs if the policy is not met. See [working with outside collaborators](https://charmhub.io/github-runner/docs/how-to-comply-security#working-with-outside-collaborators) for the recommended settings to ensure the code is reviewed by a trusted user prior to execution in the runner. | ||
| For external contributor security, see [How to manage external contributors securely](../how-to/manage-external-contributors.md) for configuration options and recommended practices. | ||
|
|
||
| ### Good practices | ||
|
|
||
| - Only register the GitHub self-hosted runners to a trusted organization or repository so that only workflows from trusted users are able to run on the runners. | ||
| - For outside collaborators: Use the [`repo-policy-compliance` charm](https://charmhub.io/repo-policy-compliance) with [policy for outside collaborators](https://charmhub.io/github-runner/docs/how-to-comply-security#working-with-outside-collaborators) to ensure the code executed in runners are reviewed by a trusted user. | ||
| - For outside collaborators: Use the `allow-external-contributor` configuration option (set to `false`) to restrict workflow execution to users with COLLABORATOR, MEMBER, or OWNER status. This prevents unauthorized code execution from untrusted external contributors. | ||
|
Check failure on line 14 in docs/explanation/security.md
|
||
yanksyoon marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like "untrusted" has made Vale unhappy, I recommend adding it to accept.txt |
||
| - Configure appropriate repository settings and protection rules to ensure the code executed in runners are reviewed by a trusted user. | ||
|
|
||
| ## Permission for GitHub app or personal access token | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,9 +2,29 @@ | |||||||||||||
|
|
||||||||||||||
| According to GitHub, running code inside the GitHub self-hosted runner [poses a significant security risk of arbitrary code execution](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#self-hosted-runner-security). The self-hosted runners managed by the charm are isolated in its own single-use virtual machine instance. In addition, the charm enforces some repository settings to ensure all code running on the self-hosted runners is reviewed by someone trusted. | ||||||||||||||
|
|
||||||||||||||
| The charm can be integrated with the [Repo Policy Compliance charm](https://charmhub.io/repo-policy-compliance) to enforce a set of good practices around GitHub repository settings. Self-hosted runners managed by the charm will not run jobs on repositories unless they are compliant with the practices. | ||||||||||||||
| The charm provides the `allow-external-contributor` configuration option to control whether workflows triggered by external contributors can execute on the self-hosted runners. When set to `false`, only users with COLLABORATOR, MEMBER, or OWNER status can trigger workflows from pull requests, reviews, and comments. | ||||||||||||||
|
|
||||||||||||||
| In this guide, a recommended set of policies will be presented. | ||||||||||||||
| In this guide, a recommended set of policies and security practices will be presented. | ||||||||||||||
|
|
||||||||||||||
| ## External contributor access control | ||||||||||||||
|
|
||||||||||||||
| Configure the charm to restrict external contributor access: | ||||||||||||||
|
|
||||||||||||||
| ```bash | ||||||||||||||
| juju config github-runner allow-external-contributor=false | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| With this setting, workflows will only run for users with the following GitHub author associations: | ||||||||||||||
| - `OWNER` - Repository or organization owners | ||||||||||||||
| - `MEMBER` - Organization members | ||||||||||||||
| - `COLLABORATOR` - Users with explicit collaborator access | ||||||||||||||
|
Comment on lines
+18
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
To be consistent with the rest of the documentation |
||||||||||||||
|
|
||||||||||||||
| The charm checks author associations for these events: | ||||||||||||||
| - `pull_request` - Pull requests from external contributors | ||||||||||||||
| - `pull_request_target` - Pull request targeting (designed for handling PRs from forks) | ||||||||||||||
| - `pull_request_review` - Pull request reviews from external contributors | ||||||||||||||
| - `pull_request_review_comment` - Comments on pull request diffs from external contributors | ||||||||||||||
| - `issue_comment` - Comments on issues or pull requests from external contributors | ||||||||||||||
|
|
||||||||||||||
| ## Recommended policy | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -20,4 +40,12 @@ | |||||||||||||
|
|
||||||||||||||
| ### Working with outside collaborators | ||||||||||||||
|
|
||||||||||||||
| Generally, outside collaborators are not completely trusted, but still would need to contribute in some manner. As such, this charm requires pull requests by outside collaborators to be reviewed by someone with `write` permission or above. Once the review is completed, the reviewer should add a comment including the following string: `/canonical/self-hosted-runners/run-workflows <commit SHA>`, where `<commit SHA>` is the commit SHA of the approved commit. Once posted, the self-hosted runners will run the workflow for this commit. | ||||||||||||||
| When `allow-external-contributor` is set to `false`, outside collaborators can still contribute through the following secure workflow: | ||||||||||||||
|
|
||||||||||||||
| 1. External contributors create pull requests as usual | ||||||||||||||
| 2. A repository maintainer with COLLABORATOR, MEMBER, or OWNER status reviews the code | ||||||||||||||
| 3. If the code is safe, the maintainer can: | ||||||||||||||
| - Approve and merge the pull request to another branch (workflows will run with the maintainer's permissions) | ||||||||||||||
|
Check failure on line 48 in docs/how-to/comply-security.md
|
||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| - Manually trigger workflow runs if needed (using workflow dispatch on the target branch) | ||||||||||||||
|
|
||||||||||||||
| This approach ensures that all code from external contributors is reviewed by trusted users before execution on self-hosted runners, eliminating the need for manual comment-based approval workflows. | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make Vale happy