build-tools icon indicating copy to clipboard operation
build-tools copied to clipboard

feat: support forks in `e cherry-pick`

Open dsanders11 opened this issue 2 years ago • 6 comments

Closes #318.

dsanders11 avatar Mar 13 '22 06:03 dsanders11

@MarshallOfSound, does maintainer_can_modify not allow the bot to do its thing?

I think there's a real use-case for non-maintainers to want to use e cherry-pick, I know I had the need and wrote this code before I even saw that @samuelmaddock had opened the issue. If maintainer_can_modify doesn't let the bot work, I think we can find some middle ground with e cherry-pick which will at least make it easier for non-maintainers to do cherry picks from upstream.

dsanders11 avatar Mar 13 '22 20:03 dsanders11

I don't believe maintainer_can_modify allows apps to push to your fork (untested) but the actual issue is the app token won't be provided to the forked CI build for security reasons. So it won't have a token to push it, I'd hate to make it easy for these PRs to be made only for 80% of them to need to be rebased / conflict merged anyway.

MarshallOfSound avatar Mar 13 '22 20:03 MarshallOfSound

The following assumes maintainer_can_modify can be tested and does allow bots with write access on a repo to push commits to fork PRs. If not, I think we could abuse something like @electron-bot to be the "maintainer" to do the commit?

Could we redesign PatchUp bot a bit to make this viable? I don't have the full picture here, but from what I've scrapped together, what if the bot listened to CircleCI webhooks looking for jobs failing, then it gets the artifacts for the job, looks for the patches/update-patches.patch artifact, and if it exists, push the commit to the fork? Then PatchUp bot would be a more general solution to the problem.

dsanders11 avatar Mar 14 '22 01:03 dsanders11

@dsanders11 There is no webhook, it all happens from the CI machine.

https://github.com/electron/electron/blob/main/.circleci/build_config.yml#L279-L302

what if the bot listened to CircleCI webhooks looking for jobs failing, then it gets the artifacts for the job, looks for the patches/update-patches.patch artifact, and if it exists, push the commit to the fork? Then PatchUp bot would be a more general solution to the problem.

This would be a potential security hole as it would allow a forked PR to apply an arbitrary git patch coming from an authenticated user (in this case a github app) which on various systems may be considered trusted. I'm relatively confident in saying there's no safe way to do this without drastic rewrites / rearchitectures of how we do cherry picks.

It's unfortunate but the reality is we can't afford forks the same level of trust / ease of use as our maintainer branches 🤷

MarshallOfSound avatar Mar 14 '22 01:03 MarshallOfSound

Also in a similar vein.

If not, I think we could abuse something like @electron-bot to be the "maintainer" to do the commit?

We are actively trying to reduce the usage of that account and replacing it with much more scoped GitHub apps where we can

MarshallOfSound avatar Mar 14 '22 01:03 MarshallOfSound

@dsanders11 There is no webhook, it all happens from the CI machine.

Yes, I know it doesn't currently use a webhook, I was suggesting it could be changed to.

This would be a potential security hole as it would allow a forked PR to apply an arbitrary git patch coming from an authenticated user (in this case a github app) which on various systems may be considered trusted. I'm relatively confident in saying there's no safe way to do this without drastic rewrites / rearchitectures of how we do cherry picks.

@MarshallOfSound Can you expand on this? Not sure I follow what the security risk would be there. The commit would be made on the fork's branch, and they're already giving permission to allow maintainers to make commits there. Is the concern that the commit would be originating from the GitHub app, which makes it look trusted to Electron infra stuff? With "squash and merge" isn't that commit just an implementation detail which will fall away once merged? If the concern is the author of the commit, could a separate, considered untrusted, GitHub app make those commits for forks?

dsanders11 avatar Mar 14 '22 02:03 dsanders11

@MarshallOfSound do we still want to move this forward potentially? or is this DOA given the above security constraints/considerations?

codebytere avatar Jan 31 '23 12:01 codebytere

Unless someone spends the time making Patch Up work for forked PRs I don't think landing this is worth it unfortunately

MarshallOfSound avatar Jan 31 '23 21:01 MarshallOfSound

Since electron/patch-conflict-fixer looks to be creating a temp branch and then deleting it, probably not much hope that approach would work with forks. Will close this, but hopefully something changes in the future that makes it viable.

dsanders11 avatar Jan 31 '23 22:01 dsanders11

@dsanders11 patch-conflict-fixer isn't Patch Up 🙃 Confusing but they're two different things

MarshallOfSound avatar Jan 31 '23 22:01 MarshallOfSound

Confusing but they're two different things

@MarshallOfSound oh, that did indeed confuse me. Does PatchUp have a repo somewhere?

dsanders11 avatar Jan 31 '23 22:01 dsanders11

Nope, it's literally a single JS file in e/e

https://github.com/electron/electron/blob/main/script/push-patch.js

MarshallOfSound avatar Jan 31 '23 22:01 MarshallOfSound