-
Notifications
You must be signed in to change notification settings - Fork 398
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
Crumb exclusion should be more forgiving if the user leaves off the trailing slash #152
Conversation
3a1df8f
to
098e1cb
Compare
What is the purpose of this? If Jenkins receives a request to
so you would better use the form ending with |
I also don't understand profit of it. Url format should be also documented. A lot of APIs are sensitive and users should follow docs. |
Agree with @KostyaSha. So many code to avoid user mistake... |
@jglick from my testing it seems Github wasn't following the redirect. |
github does not follow the redirect. @lanwen its a net increase of 4 lines of code for something that bites users daily - is that a lot of code? (did you see that most of it is test cases) @jglick github does not follow the redirect: isaacs/github#574. You do realise this PR is about the "github plugin" so the redirect won't work (github won't change this, they haven't so far, they are not going to). Did you read the PR? |
@KostyaSha @lanwen I strongly disagree - it's very easy to leave a slash off of the end of the URL and not pick up on why it's not working. This removes the problem all together at the cost of a few lines of code in the Git plugin (and I even wrote some tests!) We can make more users satisfied with Jenkins if we are more forgiving with their mistakes. So closing this PR as WONTFIX is 🐛 |
I'll just leave this link here: |
Where did you found this? |
I also ran into this problem myself which motivated me to take time out of my weekend to make this change. |
@KostyaSha years of using github with random webhook services that send 302's |
Could you please stop editing your comments? I can't collect everything to follow. |
} | ||
return false; | ||
pathInfo = !pathInfo.endsWith("/") ? pathInfo + '/' : pathInfo; |
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.
Please place comment here and with link to source of crazy GH API nuances.
if (pathInfo != null && pathInfo.equals(getExclusionPath())) { | ||
chain.doFilter(req, resp); | ||
return true; | ||
if (pathInfo == null || pathInfo.equals("")) { |
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.
Use StringUtils.isEmpty()
(AFAIR) with static import
Second time on this week i shocked how GH handle HTTP. |
@michaelneale blocked me on GH so i have no notifications about his comments. |
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.
comments
@KostyaSha I've updated the PR with the requested changes. |
return false; | ||
} | ||
// Github will not follow redirects https://github.com/isaacs/github/issues/574 | ||
pathInfo = !pathInfo.endsWith("/") ? pathInfo + '/' : pathInfo; |
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.
please swap arguments to exclude negative logic
pathInfo = pathInfo.endsWith("/") ? pathInfo : pathInfo + '/' ;
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.
Fixed
return false; | ||
} | ||
// Github will not follow redirects https://github.com/isaacs/github/issues/574 | ||
pathInfo = pathInfo.endsWith("/") ? pathInfo : pathInfo + '/'; |
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.
extra space...
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.
Fixed
Thanks @KostyaSha |
…es off the trailing slash
d25704e
to
b522499
Compare
Will keep for @lanwen review. 4am. 💤 |
Squashed these commits. |
@i386 no need, github has squash button. |
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.
lgtm
ok guys, you've convinced me |
released as 1.23.1 |
thanks! @lanwen hahaha yes. I have no idea why github don't follow, but I suspect that it doesn't as it adds latency that is "hidden" (my theory). Anyway, they do what they do, and they are the 400 pound gorrilla so we have to follow their rules ;) |
Thank you! |
Discovered that if I left out the trailing slash on my webhook configuration in Github (e.g.
/github-webook
rather than/github-webhook/
) then incoming requests would not be covered by the crumb exclusion.This change also adds tests for
GitHubWebHookCrumbExclusion
.PTAL @jenkinsci/code-reviewers @KostyaSha
This change is