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

Net::LDAP#open does not cache bind result #334

Merged
merged 7 commits into from
Nov 18, 2019
Merged

Net::LDAP#open does not cache bind result #334

merged 7 commits into from
Nov 18, 2019

Conversation

vroldanbet
Copy link
Contributor

@vroldanbet vroldanbet commented Nov 15, 2019

Hi friends 👋 this is a follow up to #331, same fix, but including the fixed CI build 🎉

What

I identified that clients cannot safely rely on Net::LDAP#get_operation_result when using Net::LDAP#open because @result is not set. As a consequence, clients calling Net::LDAP#get_operation_result would get the previous cached @result. Yikes 🙀

How

The solution is simple: to cache @result accordingly, like other methods in the class do. You can see the 🐛 reproduced in ab18e5b. The test is 8ba3f95

<49> expected but was <0>

And then going 🍏 in 92be710

Assumptions

It's not clear to me if this was an intentional design choice. Maybe no one was meant to call Net::LDAP#get_operation_result after Net::LDAP#open? If that's the case, I couldn't find any evidence.

I see there are some comments explicitly calling out the result is deliberately ignored ¯_(ツ)_/¯

we identified that clients cannot safely rely on
Net::LDAP#get_operation_result when using Net::LDAP#open
because @Result is not set.

As a consequence,clients calling
Net::LDAP#get_operation_result would get the previous
last cached result @Result.
aligns implementation of open with other methods, so the result
becomes accessible via get_operation_result
@vroldanbet vroldanbet marked this pull request as ready for review November 15, 2019 13:06
@vroldanbet
Copy link
Contributor Author

@mtodd this is ready for review 👍

Copy link
Member

@mtodd mtodd left a comment

Choose a reason for hiding this comment

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

👍 thanks for tracking this down and making the fix.

Also 👍 to bumping the version to 0.16.2 as this isn't modifying any API interfaces; if anything, it will improve existing functionality by properly setting the @result as expected, which would classify this as a bug fix.

@mtodd
Copy link
Member

mtodd commented Nov 18, 2019

I see there are some comments explicitly calling out the result is deliberately ignored

I believe this comment is indicating that the result isn't checked and acted on, not necessarily that the result should be dropped altogether.

@mtodd mtodd merged commit 8935eed into ruby-ldap:master Nov 18, 2019
@mtodd mtodd mentioned this pull request Nov 18, 2019
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Dec 3, 2019
Update ruby-net-ldap to 0.16.2.


=== Net::LDAP 0.16.2

* Net::LDAP#open does not cache bind result {#334}[ruby-ldap/ruby-net-ldap#334]
* Fix CI build {#333}[ruby-ldap/ruby-net-ldap#333]
* Fix to "undefined method 'result_code'" {#308}[ruby-ldap/ruby-net-ldap#308]
* Fixed Exception: incompatible character encodings: ASCII-8BIT and UTF-8 in filter.rb {#285}[ruby-ldap/ruby-net-ldap#285]
This was referenced Jan 24, 2023
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