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

Fix GitOps Command Issue on Pushed Commit by Unautorized User #1922

Conversation

zakisk
Copy link
Contributor

@zakisk zakisk commented Feb 10, 2025

Issue: when an unautorized user sends GitOps comment on a pushed commit, PAC is triggering CI since access check is done only for pull_request event in verifyRepoAndUser func of controller.

Solution: added a check for push event and Ops comment event type in verifyRepoAndUser func.

https://issues.redhat.com/browse/SRVKP-7110

Changes

Submitter Checklist

  • 📝 Ensure your commit message is clear and informative. Refer to the How to write a git commit message guide. Include the commit message in the PR body rather than linking to an external site (e.g., Jira ticket).

  • ♽ Run make test lint before submitting a PR to avoid unnecessary CI processing. Consider installing pre-commit and running pre-commit install in the repository root for an efficient workflow.

  • ✨ We use linters to maintain clean and consistent code. Run make lint before submitting a PR. Some linters offer a --fix mode, executable with make fix-linters (ensure markdownlint and golangci-lint are installed).

  • 📖 Document any user-facing features or changes in behavior.

  • 🧪 While 100% coverage isn't required, we encourage unit tests for code changes where possible.

  • 🎁 If feasible, add an end-to-end test. See README for details.

  • 🔎 Address any CI test flakiness before merging, or provide a valid reason to bypass it (e.g., token rate limitations).

  • If adding a provider feature, fill in the following details:

Git Provider Supported
GitHub App ✅️
GitHub Webhook ❌️
Gitea ❌️
GitLab ❌️
Bitbucket Cloud ❌️
Bitbucket Server ❌️

(update the documentation accordingly)

@zakisk zakisk requested a review from chmouel February 10, 2025 06:37
Copy link
Member

@chmouel chmouel left a comment

Choose a reason for hiding this comment

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

we still need some sort of unittest at least...

@zakisk zakisk force-pushed the fix-gitops-command-issue-for-external-user branch from 2668911 to 9956fdd Compare February 11, 2025 05:29
@zakisk
Copy link
Contributor Author

zakisk commented Feb 11, 2025

/test

@chmouel
Copy link
Member

chmouel commented Feb 11, 2025

After some thought, I think we really need to try to do the e2e test like done here: https://github.com/chmouel/pipelines-as-code/blob/main/test/github_pullrequest_oktotest_test.go#L79-L88. It shouldn't be too hard using that same technique, and since this is sensitive, we want to cover it.

pkg/pipelineascode/match.go Outdated Show resolved Hide resolved
pkg/pipelineascode/match.go Outdated Show resolved Hide resolved
@zakisk zakisk force-pushed the fix-gitops-command-issue-for-external-user branch from 9956fdd to ee59992 Compare February 12, 2025 15:58
@chmouel
Copy link
Member

chmouel commented Feb 13, 2025

seems like it fails on --- FAIL: TestGiteaPolicyPullRequest (266.04s)

@zakisk zakisk force-pushed the fix-gitops-command-issue-for-external-user branch from 8c343bc to 4c7784e Compare February 13, 2025 14:19
@zakisk
Copy link
Contributor Author

zakisk commented Feb 13, 2025

seems like it fails on --- FAIL: TestGiteaPolicyPullRequest (266.04s)

should work on 🚀

@zakisk zakisk force-pushed the fix-gitops-command-issue-for-external-user branch from 4c7784e to 82e1020 Compare February 13, 2025 15:53
Issue: when an unautorized user sends GitOps comment on a pushed commit,
PAC is triggering CI since access check is done only for pull_request
event in verifyRepoAndUser func of controller.

Solution: added a check for push event and Ops comment event
type in verifyRepoAndUser func.

https://issues.redhat.com/browse/SRVKP-7110

Signed-off-by: Zaki Shaikh <[email protected]>
@zakisk zakisk force-pushed the fix-gitops-command-issue-for-external-user branch from 82e1020 to 69ade58 Compare February 14, 2025 05:49
@zakisk
Copy link
Contributor Author

zakisk commented Feb 14, 2025

/test

@chmouel
Copy link
Member

chmouel commented Feb 14, 2025

/retest

@chmouel
Copy link
Member

chmouel commented Feb 14, 2025

ci error will be fixed by #1933

@zakisk
Copy link
Contributor Author

zakisk commented Feb 14, 2025

/lable fix

@zakisk
Copy link
Contributor Author

zakisk commented Feb 14, 2025

/lable fix

didn't work for me 😕

@chmouel
Copy link
Member

chmouel commented Feb 14, 2025

/rebase

Copy link

✅ Rebased the PR branch on the base branch.

@zakisk
Copy link
Contributor Author

zakisk commented Feb 14, 2025

/rebase

Copy link

✅ Rebased the PR branch on the base branch.

@chmouel
Copy link
Member

chmouel commented Feb 14, 2025

/merge

Copy link

❌ Insufficient Approvals

  • Current valid LGTM votes: 0
  • Required votes: 1

Please obtain additional approvals before merging.

@chmouel
Copy link
Member

chmouel commented Feb 14, 2025

/lgtm

@chmouel
Copy link
Member

chmouel commented Feb 14, 2025

/merge

Copy link

@pipelines-as-code pipelines-as-code bot left a comment

Choose a reason for hiding this comment

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

✅ Pull Request Approved

Approval Status:

  • Required Approvals: 1
  • Current Approvals: 1

👥 Approved By:

Reviewer Permission Status
@chmouel admin

📝 Next Steps

  • All required checks must pass
  • Branch protection rules apply
  • Get a maintainer to use the /merge command to merge the PR

Thank you for your contributions! 🎉

@pipelines-as-code pipelines-as-code bot merged commit d51c912 into openshift-pipelines:main Feb 14, 2025
5 checks passed
Copy link

✅ PR Successfully Merged

  • Merge method: rebase
  • Merged by: @chmouel
  • Total approvals: 1/1

Approvals Summary:

Reviewer Permission Status
@chmouel admin

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.

3 participants