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

Update github action gradle-check to use pull_request_target for accessing token #3728

Merged
merged 2 commits into from
Jun 28, 2022

Conversation

peterzhuamazon
Copy link
Member

@peterzhuamazon peterzhuamazon commented Jun 28, 2022

Signed-off-by: Peter Zhu zhujiaxi@amazon.com

Description

Update github action gradle-check to use pull_request_target for accessing token
Since Jenkins workflow needs to be triggered through github workflow with a token, pull_request does not allow fork repo to read secret just to be safe, therefore change to use pull_request_target for this access.

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

Workflows triggered via pull_request_target have write permission to the target repository. They also have access to target repository secrets. The same is true for workflows triggered on pull_request from a branch in the same repository, but not from external forks. The reasoning behind the latter is that it is safe to share the repository secrets if the user creating the PR has write permission to the target repository already.

Issues Resolved

opensearch-project/opensearch-build#851

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
@peterzhuamazon peterzhuamazon added the bug Something isn't working label Jun 28, 2022
@peterzhuamazon peterzhuamazon requested review from a team and reta as code owners June 28, 2022 17:37
@peterzhuamazon peterzhuamazon self-assigned this Jun 28, 2022
@peterzhuamazon
Copy link
Member Author

peterzhuamazon commented Jun 28, 2022

@CEHENKLE note that pull_request_target will not trigger in the 1st PR unless it is already merged.

This is my test run on this: #3727

Thanks.

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
@peterzhuamazon peterzhuamazon merged commit 4f7bf08 into main Jun 28, 2022
@peterzhuamazon peterzhuamazon added backport 1.x backport 2.x Backport to 2.x branch backport 2.0 Backport to 2.0 branch backport 2.1 labels Jun 28, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 28, 2022
…ssing token (#3728)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 4f7bf08)
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.0 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.0 2.0
# Navigate to the new working tree
cd .worktrees/backport-2.0
# Create a new branch
git switch --create backport/backport-3728-to-2.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 4f7bf08c1eaf0a4a37597920119616e862b5f6ed
# Push it to GitHub
git push --set-upstream origin backport/backport-3728-to-2.0
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.0

Then, create a pull request where the base branch is 2.0 and the compare/head branch is backport/backport-3728-to-2.0.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 28, 2022
…ssing token (#3728)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 4f7bf08)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 28, 2022
…ssing token (#3728)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 4f7bf08)
peterzhuamazon added a commit that referenced this pull request Jun 28, 2022
…ssing token (#3728) (#3729)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 4f7bf08)

Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>
peterzhuamazon added a commit that referenced this pull request Jun 28, 2022
…ssing token (#3728) (#3731)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 4f7bf08)

Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>
peterzhuamazon added a commit that referenced this pull request Jun 28, 2022
…ssing token (#3728) (#3730)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 4f7bf08)

Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>
@peterzhuamazon peterzhuamazon deleted the test-gradle-check branch June 28, 2022 18:49
imRishN pushed a commit to imRishN/OpenSearch that referenced this pull request Jul 3, 2022
…ssing token (opensearch-project#3728)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
mch2 pushed a commit to mch2/OpenSearch that referenced this pull request Jul 5, 2022
…ssing token (opensearch-project#3728) (opensearch-project#3730)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 4f7bf08)

Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>
mch2 added a commit that referenced this pull request Jul 6, 2022
* [Backport 1.x] Add gradle check test for github workflows (Testing again) (#3724)

* [Backport 1.x] Add gradle check test for github workflows (Testing again)

* [Backport 1.x] Add gradle check test for github workflows (Testing again)

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Remove linter

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Update github action gradle-check to use pull_request_target for accessing token (#3728) (#3730)

* Check out gradle

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak titles

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 4f7bf08)

Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>

* Move gradle-check code to its own scripts and upload codecov (#3742) (#3744)

* Move gradle-check to script, add codecov, add comments

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add more improvements on comments handling

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Add more comments

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
(cherry picked from commit 3681ac7)

Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>

Co-authored-by: Peter Zhu <zhujiaxi@amazon.com>
Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.x backport 2.x Backport to 2.x branch backport 2.0 Backport to 2.0 branch backport 2.1 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants