.github: add github action to automate PR handling
PATCH 1/1 .github: add github action to automate PR handling
From: Dongdong Zhang <[email protected]>
This patch updates the Buildroot repository's GitHub configuration to better manage incoming pull requests.
- Removed the existing pull request template that advised contributors to use the mailing list for patch submissions.
- Added a new GitHub Actions workflow (repo-lockdown.yml) to automatically handle new pull requests.
The new workflow:
- Triggers on new pull requests.
- Uses the dessant/repo-lockdown action to:
- Comment on the pull request, guiding contributors to use the mailing list for patch submission.
- Lock the pull request to prevent further discussion.
- Close the pull request.
This change ensures that contributors are properly directed to the preferred method of patch submission via the mailing list, maintaining consistency and streamlining the review process.
--- .github/pull_request_template.md | 6 ------ .github/workflows/repo-lockdown.yml | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) delete mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/repo-lockdown.yml
.github/pull_request_template.md deleted +0 -6
@@ -1,6 +0,0 @@ -Please do not submit a Pull Request via GitHub. Buildroot makes use of a -[mailing list](http://lists.buildroot.org/mailman/listinfo/buildroot) for patch submission and review. -See [submitting your own patches](http://buildroot.org/manual.html#submitting-patches) for more info. - -Thanks for your help! -
.github/workflows/repo-lockdown.yml new file +23 -0
@@ -0,0 +1,23 @@ +name: 'Repo Lockdown' + +on: + pull_request_target: + types: opened + +permissions: + pull-requests: write + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/repo-lockdown@v4 + with: + pr-comment: | + Please do not submit a Pull Request via GitHub. Buildroot makes use of a + [mailing list](http://lists.buildroot.org/mailman/listinfo/buildroot) for patch submission and review. + See [submitting your own patches](http://buildroot.org/manual.html#submitting-patches) for more info. + + Thanks for your help! + lock-pr: true + close-pr: true
Signature · 6 lines
2.17.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Dongdong,
Quoted 10 lines · On 01/07/2024 04:43, [email protected] wrote:
From: Dongdong Zhang <[email protected]>
This patch updates the Buildroot repository's GitHub configuration to better manage incoming pull requests.
- Removed the existing pull request template that advised contributors to use the mailing list for patch submissions.
- Added a new GitHub Actions workflow (repo-lockdown.yml) to automatically handle new pull requests.
Quoted 7 lines
The new workflow:
- Triggers on new pull requests.
- Uses thedessant/repo-lockdownaction to:
- Comment on the pull request, guiding contributors to use the mailing list for patch submission.
- Lock the pull request to prevent further discussion.
- Close the pull request.
Thank you very much for this patch - that looks like an excellent plan!
I have one question though (since I'm not super familiar with how github
workflows work). It is possible for people to modify the workflows yaml files and make a pull request that can do anything. This is a risk because those workflows may have access to project-specific resources and abuse that to do some things (although I'm not entirely sure what can be done, since I'm not sure, I prefer to block everything). Right now, we have turned on the option "Require approval for all outside collaborators". In other words, the workflow will not run until one of the maintainers approves it.
Of course, that kind of defeats the purpose of this automatic closing of pull
requests, because we still have to go to the github web interface to trigger the workflow...
So, is there a way to make this actually automatic without risking abuse?
And in fact, I have a similar question about the dessant/repo-lockdown
workflow. Is there anything stopping that workflow provider from installing a backdoor in all the projects that use that workflow?
Sorry if this sounds paranoid, but xz, you know...
Regards,
Arnout
Quoted 45 lines
This change ensures that contributors are properly directed to the preferred method of patch submission via the mailing list, maintaining consistency and streamlining the review process.
Signed-off-by Dongdong Zhang <[email protected]>--- .github/pull_request_template.md | 6 ------ .github/workflows/repo-lockdown.yml | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-)delete mode 100644
.github/pull_request_template.mdcreate mode 100644.github/workflows/repo-lockdown.yml.github/pull_request_template.md deleted +0
-6@@ -1,6 +0,0 @@ -Please do not submit a Pull Request via GitHub. Buildroot makes use of a -[mailing list](http://lists.buildroot.org/mailman/listinfo/buildroot) for patch submission and review. -See [submitting your own patches](http://buildroot.org/manual.html#submitting-patches) for more info. - -Thanks for your help! -.github/workflows/repo-lockdown.yml new file +14
-0@@ -0,0 +1,23 @@ +name: 'Repo Lockdown' + +on: + pull_request_target: + types: opened + +permissions: + pull-requests: write + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/repo-lockdown@v4
.github/workflows/repo-lockdown.yml line 23
Quoted 10 lines
.github/workflows/repo-lockdown.yml new file +9
-0+ with: + pr-comment: | + Please do not submit a Pull Request via GitHub. Buildroot makes use of a + [mailing list](http://lists.buildroot.org/mailman/listinfo/buildroot) for patch submission and review. + See [submitting your own patches](http://buildroot.org/manual.html#submitting-patches) for more info. + + Thanks for your help! + lock-pr: true + close-pr: true
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 2 lines · Arnout Vandecappelle
Is there anything stopping that workflow provider from installing a backdoor in all the projects that use that workflow?
No, there isn't. A common protection against such attacks is to not rely on a tag like “v4”, but instead
```yaml uses: provider/action@<specific SHA1> ```
Cheers!
Edgar Bonet.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Arnout,
Thank you for your feedback. I'll address your questions one by one.
1. How to prevent workflow abuse?
Since Buildroot on GitHub is merely a read-only mirror and we do not plan to use complex workflows in the future, this workflow file should remain unchanged and thus should be safe. Additionally, GitHub provides some security measures. You can set the workflow's read/write permissions in Buildroot-Settings-Actions-General-Workflow permissions-Read repository contents and packages permissions. This way, the workflow will never write content to Buildroot.
2. Does enabling "Require approval for all outside collaborators" mean that maintainers need to manually trigger the workflow?
The official documentation for Workflow includes the following:
Note: Workflows triggered by pull_request_target events are run in the context of the base branch. Since the base branch is considered trusted, workflows triggered by these events will always run, regardless of approval settings. For more information about the pull_request_target event, see "Events that trigger workflows."
Quoted 4 lines
.github/workflows/repo-lockdown.yml line 6
Quoted 4 lines
.github/workflows/repo-lockdown.yml new file +4
-0+on: + pull_request_target: + types: opened +
In short, this means that when a pull_request_target event triggers, the workflow will run on the base branch. Since the base branch is trusted, workflows triggered by these events will always run, regardless of the approval settings. Therefore, even if "Require approval for all outside collaborators" is enabled, the workflow will still run on the base branch without requiring maintainers to manually trigger it. I have tested this process in a repository I created. After a colleague submitted a pull request, the workflow ran automatically.
3. How to prevent the repo-lockdown workflow provider from installing backdoors in all projects using repo-lockdown?
Your cautious approach is highly commendable. However, we need not worry about this issue. Firstly, repo-lockdown is a public repository, and everyone can review its source code:
https://github.com/dessant/repo-lockdown.
Secondly, the workflow runs on GitHub's servers, not locally, so there is no risk to our development machines. Most importantly, your concern is whether it will affect the Buildroot repository. This has already been addressed by setting the workflow permissions; it will not modify any content in the Buildroot repository.
Lastly, I would like to mention that the idea of adding repo-lockdown came from the QEMU community, which also uses this
workflow: https://github.com/qemu/qemu. It has been running stably for three years. Therefore, I believe this workflow is safe.
I hope this clarifies everything. If you have any other questions, feel free to ask!
PS: My English is not very good, and some parts were machine-translated. Please forgive any inappropriate phrasing. Thank you.
Regards,
Dongdong
---
Quoted 96 lines
-----原始邮件-----发件人:"Arnout Vandecappelle" <[email protected]>发送时间:2024-07-01 15:24:21 (星期一)收件人:[email protected], [email protected]抄送:主题:Re: [Buildroot] [PATCH] .github: add github action to automate PR handling
Hi Dongdong,
Quoted 10 lines · On 01/07/2024 04:43, [email protected] wrote:
From: Dongdong Zhang <[email protected]>
This patch updates the Buildroot repository's GitHub configuration to better manage incoming pull requests.
- Removed the existing pull request template that advised contributors to use the mailing list for patch submissions.
- Added a new GitHub Actions workflow (repo-lockdown.yml) to automatically handle new pull requests.Quoted 7 lines
The new workflow:
- Triggers on new pull requests.
- Uses thedessant/repo-lockdownaction to:
- Comment on the pull request, guiding contributors to use the mailing list for patch submission.
- Lock the pull request to prevent further discussion.
- Close the pull request.Thank you very much for this patch - that looks like an excellent plan!
I have one question though (since I'm not super familiar with how github
workflows work). It is possible for people to modify the workflows yaml files and make a pull request that can do anything. This is a risk because those workflows may have access to project-specific resources and abuse that to do some things (although I'm not entirely sure what can be done, since I'm not sure, I prefer to block everything). Right now, we have turned on the option "Require approval for all outside collaborators". In other words, the workflow will not run until one of the maintainers approves it.Of course, that kind of defeats the purpose of this automatic closing of pull
requests, because we still have to go to the github web interface to trigger the workflow...So, is there a way to make this actually automatic without risking abuse?
And in fact, I have a similar question about the dessant/repo-lockdown
workflow. Is there anything stopping that workflow provider from installing a backdoor in all the projects that use that workflow?Sorry if this sounds paranoid, but xz, you know...
Regards,
ArnoutQuoted 47 lines
This change ensures that contributors are properly directed to the preferred method of patch submission via the mailing list, maintaining consistency and streamlining the review process.
Signed-off-by Dongdong Zhang <[email protected]>--- .github/pull_request_template.md | 6 ------ .github/workflows/repo-lockdown.yml | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-)delete mode 100644
.github/pull_request_template.mdcreate mode 100644.github/workflows/repo-lockdown.yml.github/pull_request_template.md deleted +0
-6@@ -1,6 +0,0 @@ -Please do not submit a Pull Request via GitHub. Buildroot makes use of a -[mailing list](http://lists.buildroot.org/mailman/listinfo/buildroot) for patch submission and review. -See [submitting your own patches](http://buildroot.org/manual.html#submitting-patches) for more info. - -Thanks for your help! -.github/workflows/repo-lockdown.yml new file +16
-0@@ -0,0 +1,23 @@ +name: 'Repo Lockdown' + +on: + pull_request_target: + types: opened + +permissions: + pull-requests: write + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/repo-lockdown@v4 + with: + pr-comment: |
Quoted 8 lines
.github/workflows/repo-lockdown.yml line 23
Quoted 8 lines
.github/workflows/repo-lockdown.yml new file +7
-0+ Please do not submit a Pull Request via GitHub. Buildroot makes use of a + [mailing list](http://lists.buildroot.org/mailman/listinfo/buildroot) for patch submission and review. + See [submitting your own patches](http://buildroot.org/manual.html#submitting-patches) for more info. + + Thanks for your help! + lock-pr: true + close-pr: true
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hello!
Quoted 2 lines · Dongdong Zhang
This patch [...] Removed the existing pull request template that advised contributors to use the mailing list for patch submissions.
What is the rationale for doing so? The sooner the contributor learns about the procedure, the more convenient it is for them. Keeping this template would then be friendlier to would-be contributors.
Of course, there is still the possibility that they do not read the template, so there is value in having the workflow *in addition to* (not instead of) the pull request template.
Regards,
Edgar Bonet.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Sorry, Edgar Bonet, I might not have received your emails due to the company's email filtering. I only found your email today when I checked the buildroot thread list, I apologize for that.
When I was adding this workflow, I felt that reminding developers twice was a bit redundant. However, your suggestion is great, as the pull request template can remind developers immediately, rather than waiting until after the pull request is created. I will restore the pull request template in the next version and keep it.
Thank you.
------------------------------------------------------
Hello!
Quoted 2 lines · Dongdong Zhang
This patch [...] Removed the existing pull request template that advised contributors to use the mailing list for patch submissions.
What is the rationale for doing so? The sooner the contributor learns about the procedure, the more convenient it is for them. Keeping this template would then be friendlier to would-be contributors.
Of course, there is still the possibility that they do not read the template, so there is value in having the workflow *in addition to* (not instead of) the pull request template.
Regards,
Edgar Bonet.
Quoted 76 lines
-----原始邮件-----发件人:[email protected]发送时间:2024-07-01 10:43:16 (星期一)收件人:[email protected]抄送:[email protected]主题:[PATCH] .github: add github action to automate PR handling
From: Dongdong Zhang <[email protected]>
This patch updates the Buildroot repository's GitHub configuration to better manage incoming pull requests.
- Removed the existing pull request template that advised contributors to use the mailing list for patch submissions.
- Added a new GitHub Actions workflow (repo-lockdown.yml) to automatically handle new pull requests.The new workflow:
- Triggers on new pull requests.
- Uses thedessant/repo-lockdownaction to:
- Comment on the pull request, guiding contributors to use the mailing list for patch submission.
- Lock the pull request to prevent further discussion.
- Close the pull request.This change ensures that contributors are properly directed to the preferred method of patch submission via the mailing list, maintaining consistency and streamlining the review process.
Signed-off-by Dongdong Zhang <[email protected]>--- .github/pull_request_template.md | 6 ------ .github/workflows/repo-lockdown.yml | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) delete mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/repo-lockdown.yml.github/pull_request_template.md deleted +0
-6@@ -1,6 +0,0 @@ -Please do not submit a Pull Request via GitHub. Buildroot makes use of a -[mailing list](http://lists.buildroot.org/mailman/listinfo/buildroot) for patch submission and review. -See [submitting your own patches](http://buildroot.org/manual.html#submitting-patches) for more info. - -Thanks for your help! -.github/workflows/repo-lockdown.yml new file +23
-0@@ -0,0 +1,23 @@ +name: 'Repo Lockdown' + +on: + pull_request_target: + types: opened + +permissions: + pull-requests: write + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/repo-lockdown@v4 + with: + pr-comment: | + Please do not submit a Pull Request via GitHub. Buildroot makes use of a + [mailing list](http://lists.buildroot.org/mailman/listinfo/buildroot) for patch submission and review. + See [submitting your own patches](http://buildroot.org/manual.html#submitting-patches) for more info. + + Thanks for your help! + lock-pr: true + close-pr: trueSignature · 1 line
2.17.1
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot