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

TST: small change to csvs to test xml generation #54

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

tangkong
Copy link
Contributor

Previous PR is working and (presumably) checking out the repo with an ssh key. This aims to fully flex the xml-generation

@tangkong
Copy link
Contributor Author

I don't think that specifying the ref in a workflow works for PRs originating from forks. I also think we have to merge this to see if I'm right
image

@@ -23,7 +23,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
Copy link
Contributor

@KaushikMalapati KaushikMalapati Dec 14, 2024

Choose a reason for hiding this comment

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

SInce this job triggers on pull_request_target and not pull_request, the default checkout would be the branch we are merging into. So if we are trying to merge into the master branch, we would just compare it with itself and post an empty diff.

I think what's happening is that it's trying to checkout the source branch from the target repo (I hope I'm using the right terminology) which doesn't exist. Maybe this would work?

ref: "${{ github.event.pull_request.head.ref }}"
repository: "${{ github.event.pull_request.head.repo.full_name }}"

where we explicitly define where the branch is coming from

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call 👍

0,QRIX,,,,,,
,,MR1K1:BEND:RTD:US:1_RBV,TEMPERATURE,,,,
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, I think we still have to merge this to test it. Was this change meant to just test the daff workflow or do you actually want to add it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR wasn't meant to test the daff workflow at all, it was meant to test the xml generation with some modified repository permissions / push-access-bypass settings.

I just got side-tracked by the big red ❌ from the daff workflow

@tangkong
Copy link
Contributor Author

tangkong commented Dec 16, 2024

A bit more reading revealed that the pull_request_target workflow trigger gives the GITHUB_TOKEN write permissions, which we don't need here. I'm going to try setting this to the standard pull-request trigger, which only grants read access.

https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target

Take 2: The comment workflow requires write permissions or pull_request_target. I don't know how I feel about this currently. While I'm uncomfortable granting write permissions to a workflow generally, according to documentation the pull_request_target trigger only ever runs on the base of the PR'd branch (not the modified PR contents). This protects us slightly, and also explains our difficulty testing the workflow in a PR.

@KaushikMalapati
Copy link
Contributor

A bit more reading revealed that the pull_request_target workflow trigger gives the GITHUB_TOKEN write permissions, which we don't need here. I'm going to try setting this to the standard pull-request trigger, which only grants read access.

https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target

Take 2: The comment workflow requires write permissions or pull_request_target. I don't know how I feel about this currently. While I'm uncomfortable granting write permissions to a workflow generally, according to documentation the pull_request_target trigger only ever runs on the base of the PR'd branch (not the modified PR contents). This protects us slightly, and also explains our difficulty testing the workflow in a PR.

I didn't consider anything security wise when I wrote this, but could we make a secret github key that only has write permissions on pull requests? Alternatively we could follow the security lab paper and sotre the diff in an artifact in a pull-request workflow, and have another job trigger on workflow-run to make the comment.

@tangkong
Copy link
Contributor Author

If we want to fully restrict access, I think the github approved way of posting a comment is through the rest API through github-script: https://github.com/actions/github-script#comment-on-an-issue

We can scope out a fine-grained access token specifically allowed to post comments only

@tangkong
Copy link
Contributor Author

I'm going to request that we focus on the daff workflow in a different PR, since it's distracting from the goal of this effort.

The diff workflow is close (I think)

@KaushikMalapati KaushikMalapati self-requested a review December 17, 2024 05:35
@ZLLentz
Copy link
Member

ZLLentz commented Dec 17, 2024

To finish here, the last step is probably to undo the tiny csv change, right?

@tangkong
Copy link
Contributor Author

The csv change was to test xml push generation on PR merge, so it's actually necessary here. The goal of this was to test if we could give this job permissions via deploy-key, rather than by just omitting branch protections

This was poorly established / lost in the nerd snipe 😆

@tangkong
Copy link
Contributor Author

I'm going to merge so I can find out how I messed this one up and try again

@tangkong tangkong merged commit af95db3 into pcdshub:master Dec 17, 2024
2 of 4 checks passed
@tangkong
Copy link
Contributor Author

image
ahahahahahaahahit worked

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

Successfully merging this pull request may close these issues.

3 participants