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

Bump.sh diff adjustments #186909

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

paulRbr
Copy link

@paulRbr paulRbr commented Jun 25, 2024

Summary

Two adjustments on the Bump.sh workflow when creating a diff comment about the OAS changes:

  • Use GH event pull_request_target to allow comments from PRs of forks
  • Don't create extra API doc preview, as a preview link is already available on automatic comment

(see commit descriptions for details of each change)

@paulRbr paulRbr requested a review from a team as a code owner June 25, 2024 16:43
paulRbr added 2 commits June 26, 2024 15:01
In order for the Bump.sh action to be able to post github comments on
PRs opened from forks, the GH action needs to listen to the
'pull_request_target' event (instead of the 'pull_request' event).

More details about the introduction of this event in this GH blog
post:
https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/

Complete documentation about this event:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
Since the latest release of the Bump.sh GH
action (https://github.com/bump-sh/github-action/releases/tag/v1.1.11),
a PR comment is published for all changes made to the OAS file.

The extra preview command should thus not be needed as a preview link
is available in the automatic diff comment.
@paulRbr paulRbr force-pushed the bump-diff-ajustements branch from a52a148 to c6e9886 Compare June 26, 2024 13:01
@lcawl lcawl added Feature:OAS Work or issues related to Core-provided mechanisms for generating OAS release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting docs labels Jun 26, 2024
@jbudz
Copy link
Member

jbudz commented Jun 26, 2024

buildkite test this

@kibana-ci
Copy link
Collaborator

💔 Build Failed

Failed CI Steps

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@lcawl lcawl enabled auto-merge (squash) June 26, 2024 16:16
@jbudz jbudz disabled auto-merge June 26, 2024 16:21
.github/workflows/bump.yml Show resolved Hide resolved
@paulRbr
Copy link
Author

paulRbr commented Jul 8, 2024 via email

@v1v
Copy link
Member

v1v commented Jul 9, 2024

I probably was too quick to type here without checking whether the checkout was from the head, but we, Observability, agreed to ban pull_request_target to avoid surprises, such as someone accidentally changing the checkout in a follow-up. That's why I applied the same pattern here.

GitHub itself says if you use it, then use a label to control when:

Add a condition to the pull_request_target to run only if a certain label is assigned the PR, like safe to test that indicates the PR has been vetted by someone with write privileges to the target repository.

https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

In addition, this repository could be configured with this in case it's not yet.

Regardless, I suggest asking the infosec team to clarify if that's okay (cc @ismisepaul).

@paulRbr
Copy link
Author

paulRbr commented Aug 9, 2024

GitHub itself says if you use it, then use a label to control when:

Add a condition to the pull_request_target to run only if a certain label is assigned the PR, like safe to test that indicates the PR has been vetted by someone with write privileges to the target repository.

Hi @v1v, thanks for the suggestion.

Indeed controlling the run of the action based on a label (added by code owners) on the PR would be a good balance to make sure the security risk is mitigated 👍.

I hope the discussions with the infosec team worked out 🤞 (the next PR from Lisa isn't really reassuring 😅)

@v1v
Copy link
Member

v1v commented Aug 9, 2024

I hope the discussions with the infosec team worked out 🤞 (the #188169 isn't really reassuring 😅)

I didn't start any discussion with Infosec; I guess that's something the Repo Owners or GitHub workflow owners should do. I only reviewed this PR following some of the hardening practices we have in place.

@delanni delanni self-requested a review August 9, 2024 13:09
@@ -33,21 +33,12 @@ jobs:
file: oas_docs/kibana.serverless.yaml

api-diff:
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request_target' }}
name: Check API diff on Bump.sh
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uses: actions/checkout@v3
uses: actions/checkout@v4

@delanni delanni changed the title Bump.sh diff ajustements Bump.sh diff adjustments Aug 9, 2024
@delanni delanni self-requested a review August 12, 2024 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting 💝community docs Feature:OAS Work or issues related to Core-provided mechanisms for generating OAS release_note:skip Skip the PR/issue when compiling release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants