-
Notifications
You must be signed in to change notification settings - Fork 14
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
chore: Fixing non-propagated custom GH token in forked PRs #134
Conversation
6c986c3
to
c911071
Compare
c911071
to
859e91e
Compare
What happens if some one creates a PR to this action with a script to exfiltrate the token before the check runs? |
He needs to gain GH_TOKEN first, but he should be blocked on the first step which checks his membership |
.github/workflows/docs-ci.yaml
Outdated
response=$(curl -H "Authorization: Bearer $GH_TOKEN" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
"https://api.github.com/orgs/Mellanox/teams/cloud-orchestration/members/$ACTOR") | ||
|
||
if [[ $(echo "$response" | jq -r '.message') == "Not Found" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the GH API return an appropriate status code (404
?) if the actor is not part of the organization?
If so, this could be shortened to if curl -f ... ; then
?
What if I create an MR which changes that first step? |
So this is not only related to my PR change, if anyone can create its own workflow file which will be engaged in PR then we're in a bad shape. |
The current trigger configuration doesn't trigger on PRs, so shouldn't this not be a problem? And either way - we can configure the repository (Settings -> Actions -> General -> Approval for running fork pull request workflows from contributors to Require approval for all external contributors. |
.github/workflows/docs-ci.yaml
Outdated
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }} | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it GITHUB_TOKEN ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to make sure the GITHUB_TOKEN used in network-operator is sufficient.
.github/workflows/docs-ci.yaml
Outdated
@@ -27,10 +31,24 @@ jobs: | |||
PR_NUMBER: ${{ github.event.number }} | |||
PR_TITLE_PREFIX: "task: update documentation for" | |||
steps: | |||
- name: Check if PR actor is part of team |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont think this is needed.
this workflow is only triggered by other workflows not PRs.
the other workflow needs to have the needed ppermissions in order to trigger workflow in this repo.
currently only members of Mellanox org can trigger workflows for this project (i just modfied this in setting)
A new step has been added to verify that actor is a member of Mellanox/cloud-orchestration team
859e91e
to
1f0bd13
Compare
.github/workflows/docs-ci.yaml
Outdated
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we using this env var in the job ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adrianchiris see my comment from the original line 33 in this file:
# token must be explicitly set here for push to work in following step
@heyvister1 , although you renamed the secret variable (in line 33) - perhaps it's worth preserving the comment (unless you tested that after your change the token no longer needs to be explicitly set?).
… contributers from triggering workflows
1f0bd13
to
7145c22
Compare
@@ -65,7 +65,8 @@ jobs: | |||
run: | | |||
git config user.name nvidia-ci-cd | |||
git config user.email [email protected] | |||
gh repo fork --remote --default-branch-only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to fork docs repo, since there is already an existing fork for nvidia-ci-cd user
Since custom GH secrets are not propagated for forked repos, we need a way to have GH token to generate docs repo PRs under network-operator repo.
Solution:
GH_DOCS_TOKEN
PAT token fornvidia-ci-cd
user