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(api): properly authorize GET workflow fallback to archive #13957

Merged
merged 4 commits into from
Dec 2, 2024

Conversation

Joibel
Copy link
Member

@Joibel Joibel commented Dec 2, 2024

Cherry pick of patch for GHSA-h36c-m3rf-34h9

Anton Gilgur added 3 commits December 2, 2024 13:05
- the authorization was accidentally removed in f1ab5aa

- also if no archived workflow is found, properly return the original error as per ac9e2de

Signed-off-by: Anton Gilgur <[email protected]>
- the permission suite seemed to not have previously tested this
- add good, bad, and fake token checks
  - where "bad" is valid, but unauthorized, while "fake" is valid in format, but not corresponding to a real token

Signed-off-by: Anton Gilgur <[email protected]>
- these tests were relying on ordering of assignments before, i.e. 1. good 2. bad 3. bad
  - should just assign before each test instead for simplicity / less complexity / less mistakes

Signed-off-by: Anton Gilgur <[email protected]>
@Joibel Joibel marked this pull request as ready for review December 2, 2024 14:13
Signed-off-by: Alan Clucas <[email protected]>
@Joibel Joibel force-pushed the fix-get-workflow-archived-auth branch from ca32f0c to d2859eb Compare December 2, 2024 14:16
@Joibel Joibel merged commit 97b94f0 into main Dec 2, 2024
29 checks passed
@Joibel Joibel deleted the fix-get-workflow-archived-auth branch December 2, 2024 16:05
// Test get wf w/ archive fallback with good token
s.bearerToken = goodToken
s.Run("GetWFsFallbackArchivedGoodToken", func() {
s.e().GET("/api/v1/workflows/"+nsName).
Copy link

@agilgur5 agilgur5 Dec 2, 2024

Choose a reason for hiding this comment

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

nit: so the spacing around the + is different on this line than on line 641 and 649 below. I would think gofmt would make these consistent though -- it didn't make changes in #12979 (comment) either so I was thinking it's possibly not running on test files? Afaik gofmt usually does x + y with a space on both sides of the +

See also golang/go#12105 -- only one argument here

Copy link
Member Author

@Joibel Joibel Dec 2, 2024

Choose a reason for hiding this comment

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

Yeah, this is pretty bonkers, and I don't understand why. I haven't analysed it in any way because I was concentrating on getting the release out.

CI does pick it up, as you can see here when I pushed it up initially with the fixed formatting. The original test has the same thing, so the linter had 'formatted' it there too when you wrote it.

I'm most thrown by the fact the other two lines you pointed out are formatted correctly, it's just this one that's "wrong", yet they are all so similar.

Copy link

Choose a reason for hiding this comment

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

I haven't analysed it in any way because I was concentrating on getting the release out.

For sure 👍
I just noticed it incidentally

CI does pick it up, as you can see here when I pushed it up initially with the fixed formatting. The original test has the same thing, so the linter had 'formatted' it there too when you wrote it.

Well that's more bizarre than I thought 👀 Thanks for checking that!
In this case I'd hazard a guess this might be a gofmt bug or some fairly odd quirk explained by some other line widths; potentially worth filing a bug report in either scenario 😅

@agilgur5
Copy link

agilgur5 commented Dec 5, 2024

@Joibel could you update GHSA-h36c-m3rf-34h9 to mention that it is resolved by this PR? Usually we've had it written at the bottom of the "Summary" section (for example, see GHSA-ghjw-32xw-ffwr)

Just to be able to follow the fix accordingly and posterity/historical lineage.
(Right now you have to dissect the version numbers and diff to find this as there is no direct link from the advisory itself. The GH reviewed version includes the PR and commit if it's in the original as well.)

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.

2 participants