Skip to content
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

👷 Add sticky helm diff PR comment #70

Merged
merged 12 commits into from
Aug 15, 2022
Merged

Conversation

ddelange
Copy link
Contributor

@ddelange ddelange commented Aug 10, 2022

@ddelange
Copy link
Contributor Author

should start working once this workflow lives in twuni:main ref

@ddelange
Copy link
Contributor Author

ddelange commented Aug 10, 2022

tested here ddelange#2

@ddelange
Copy link
Contributor Author

now with filenames in the diff, and collapsed the markdown ddelange#5

Copy link
Member

@canterberry canterberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is great! It will save time on PR review, for sure.

I have a couple of concerns, which may or may not require adjustments. Just talking points to discuss before merge:

  1. marocchino/sticky-pull-request-comment is a privately maintained GitHub action, so I'm concerned about introducing a dependency on it. It creates a single point of failure and a heightened security risk compared to, say, a more popular and commercially-backed/community-led action. Not a blocking issue, but just wanted to bring it up.
  2. If the action is failing on this PR, what evidence supports that it would succeed on subsequent PRs? Are any repo configuration changes necessary in order to support the action-initiated PR comment? I can see it passing on your fork, but I don't yet understand why it passes there but fails here. I suspect it's because the branch the PR is based on is local to the target branch (vs any PRs opened against this repo which are coming from forks).

While (1) is not something I'm that concerned about, I'd like to understand (2) better to avoid potentially breaking mergability of PRs in this repo, although the risk is low, because if that were to happen, it would be trivial to fix by reverting this PR.

Copy link
Contributor Author

@ddelange ddelange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very valid concerns!

  1. could be remedied by pointing to a commit hash instead of a major version
  2. is probably a valid issue ref 'Send PR comment' step not working for people creating the PR that don't have permission to the repository keptn-contrib/artifacthub#89. I think you might be right that in the current state it won't work for any new PRs coming from forks, even when this code would live on twuni:main. I encountered the 'not on master' behaviour in a different setting, and must have gotten them confused. I think it had to do with the release trigger, not pull_request. Fix would be to run on pull_request_target trigger, barring all permissions to the target repo except for the pull request itself:

pull_request_target: "This event allows your workflow to do things like label or comment on pull requests from forks."

.github/workflows/pr_diff.yaml Show resolved Hide resolved
.github/workflows/pr_diff.yaml Outdated Show resolved Hide resolved
* Test permissions

* Add back pull_request

* Use full SHA
@canterberry
Copy link
Member

canterberry commented Aug 12, 2022

Thanks for (1) updating to the commit hash, and for the link on (2). This comment points out three potential solutions, and unfortunately, neither of them are viable. Granting the Action read/write repository permissions with access to secrets even when running on a fork is a non-starter:

TL;DR: Combining pull_request_target workflow trigger with an explicit checkout of an untrusted PR is a dangerous practice that may lead to repository compromise.

The value provided by this PR, however, is great enough that I'd still love to see it land in some form. Is there another way the diff can be presented or attached? I'm not familiar with GitHub Actions (my experience is mostly CircleCI and GitLab) -- is there something like Artifacts or Reports that can be attached to the action's result?


Edit: I'm reading the "Preventing pwn requests" post more thoroughly, where the example given is automating a PR comment. If this can be done safely, I do think a PR comment is more discoverable. It's just not clear to me (yet?) that it's possible to do so in a safe enough way.

Co-authored-by: ddelange <14880945+ddelange@users.noreply.github.com>
Copy link
Member

@canterberry canterberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Although the newly introduced action is currently failing, it seems probable that is because it's trying to do something the target hasn't authorized. Post-merge, the target will have authorized the action, so in theory will start working. If not, it's trivial to revert.

@canterberry canterberry merged commit 8707c92 into twuni:main Aug 15, 2022
@canterberry
Copy link
Member

Released in v2.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants