-
Notifications
You must be signed in to change notification settings - Fork 102
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
JENKINS-64629: Fix "null" in error message #74
Conversation
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.
In both JENKINS-64629 and JENKINS-64850, the DisabledException
comes from line 92 of UserAttributesHelper#checkIfUserEnabled
:
org.springframework.security.authentication.DisabledException: The user "null" is administratively disabled.
at hudson.security.UserAttributesHelper.checkIfUserEnabled(UserAttributesHelper.java:92)
The Messages.UserDetails_Disabled
exception constructor takes as input an argument representing the user:
src/main/resources/jenkins/security/plugins/ldap/Messages.properties
63:UserDetails.Disabled=The user "{0}" is administratively disabled.
On line 92 of UserAttributesHelper#checkIfUserEnabled
, we pass in user.get("dn")
as this argument when creating Messages.UserDetails_Disabled
:
throw new DisabledException(Messages.UserDetails_Disabled(user.get("dn")));
This implies that user
was non-null, since we were able to successfully dereference it and call .get("dn")
. Otherwise we would have received a NullPointerException
, not a DisabledException
. So I doubt this fix is correct. This fix is assuming that we called UserAttributesHelper#checkIfUserEnabled
with a null user
argument, but that couldn't have been the case if we were able to successfully dereference it to create the DisabledException
that users reported. Feel free to let me know if I am misunderstanding something.
Alright, that starts to sound more like an end-user problem more so than a bug then. All LDAP objects have a |
Based on that description, though, I have a better idea. Let me update this. |
Sorry, I do not have the context to be able to meaningfully review this change. You might want to try reproducing the user-reported issue in a test using |
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.
Looks reasonable. Is there some known way to reproduce the error that could be added to a test?
I think the more pressing question is the impact of JENKINS-55813 on the existing implementation of SECURITY-372 in Mailer and Email Extension. The logic added in SECURITY-372 (in both Mailer and Email Extension) assumes that |
That was a bad assumption even before #60. The caller should have been handling |
I did a survey of all the uses of And given the lack of detailed reproduction steps (particularly related to LDAP config), I don't see how any additional tests would be useful here. |
Hello, and thanks for the work on this issue. I was the one who created the JIRA issue and am wondering if I can provide any additional detail to help identify the problem. The problem does seem to be build specific and I believe this is because the issue is related to a specific user's LDAP state, and that user had run some builds but not others. The issue (for us) manifests when the email plugin runs, which (I believe) tries to email all users since last successful build. But I'm not sure how to see what users are involved so I cannot debug any more on what their LDAP state is. If anyone has any ideas on how I can add meaningful/helpful detail, please advise. Thanks! |
This patch will fix the exception message so you'll at least see which username causes the problem. Then we can figure out an appropriate fix that will probably be needed for the mailer plugin since I can imagine a scenario already where this would get annoying (which might be similar to the one you're seeing). |
I don't disagree, Jesse. The problem is that this bad assumption didn't cause any problems for users before JENKINS-55813, but it does now, and the CERT team hasn't made any effort to deal with this, nor have they given plugin maintainers guidance as to how to adapt to this change in behavior. This puts plugin maintainers in an awkward situation with regard to dealing with user complaints. Ideally the CERT team would revise the implementation of SECURITY-372 to avoid this bad assumption and fix the user-visible regression. The next best thing would be for the CERT team to provide guidance as to how to adapt the implementation of SECURITY-372 with regard to the changes in JENKINS-55813, which would at least solve the problem for end users (but would still be an annoyance for plugin maintainers). |
In fact, that might be a separate bug in the mailer plugin in how it chooses who to email about a build. For example, whenever I release a plugin, I sometimes get emails from random Jenkins instances with my plugin's commits included in their changelog. The fact that the mailer plugin (or whichever plugin) is so extensive in who it emails may itself be a bug. |
The CERT team may have offered fixes years ago for security advisories in The fix should be simple enough: catch |
Of course it does not. Yes JENKINS-64629 is arguably a preëxisting issue in the SECURITY-372 logic that was merely exposed by JENKINS-55813. But on the other hand, it was JENKINS-55813 that exposed it: the SECURITY-372 logic in Mailer and Email Extension might have been brittle with respect to such changes, but it had at least worked prior to JENKINS-55813. My conclusion is that the problem isn't JENKINS-55813 per se, but rather the CERT team's decided lack of caution when modifying such a fragile subsystem, namely the due diligence of searching for and updating existing callers.
Agreed. This needs to be done for both Mailer and Email Extension. |
@jvz care to try ^^^? |
Sure, I'll look at what plugins are calling this improperly. |
@rsandell
https://issues.jenkins.io/browse/JENKINS-64629
Unfortunately, spotbugs does not appear to be sophisticated enough to have prevented this.