net-ldap 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of net-ldap might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.rdoc +0 -5
- data/lib/net/ber/core_ext/string.rb +3 -1
- data/lib/net/ldap.rb +12 -2
- data/lib/net/ldap/entry.rb +9 -1
- data/lib/net/ldap/filter.rb +21 -23
- data/lib/net/ldap/version.rb +1 -1
- data/spec/integration/ssl_ber_spec.rb +7 -4
- data/spec/spec_helper.rb +5 -0
- data/spec/unit/ber/ber_spec.rb +21 -21
- data/spec/unit/ber/core_ext/string_spec.rb +2 -2
- data/spec/unit/ldap/filter_parser_spec.rb +6 -0
- data/spec/unit/ldap/filter_spec.rb +2 -2
- data/test/test_snmp.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e84cd86cc0974d9380b18caa917cfa8d8f3e8f2
|
4
|
+
data.tar.gz: 6e6783c3b458b1c5b3abd72745a0e56b4e749d35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c3b405a5086b6f33522fe611cff02ca6e325498db1b54b9d4415222c870eedae5466a3e9c65ba9d16cfc6db89392eafbbcee4537a0b70a79a6651a92695e9d6
|
7
|
+
data.tar.gz: 81ce6fa1369f1a5bcbacd35efc939a8f9aa97ada21ef122314c029b9c0b3a32d6dddb8c9b43a3d2cf25d9fffad7d2fe97b992cd92c5597f8b26b72ceeacf1dc1
|
data/README.rdoc
CHANGED
@@ -16,13 +16,8 @@ the most recent LDAP RFCs (4510–4519, plus portions of 4520–4532).
|
|
16
16
|
|
17
17
|
== Where
|
18
18
|
|
19
|
-
* {RubyForge}[http://rubyforge.org/projects/net-ldap]
|
20
19
|
* {GitHub}[https://github.com/ruby-ldap/ruby-net-ldap]
|
21
20
|
* {ruby-ldap@googlegroups.com}[http://groups.google.com/group/ruby-ldap]
|
22
|
-
* {Documentation}[http://net-ldap.rubyforge.org/]
|
23
|
-
|
24
|
-
The Net::LDAP for Ruby documentation, project description, and main downloads
|
25
|
-
can currently be found on {RubyForge}[http://rubyforge.org/projects/net-ldap].
|
26
21
|
|
27
22
|
== Synopsis
|
28
23
|
|
data/lib/net/ldap.rb
CHANGED
@@ -1160,14 +1160,24 @@ class Net::LDAP::Connection #:nodoc:
|
|
1160
1160
|
end
|
1161
1161
|
end
|
1162
1162
|
|
1163
|
+
module FixSSLSocketSyncClose
|
1164
|
+
def close
|
1165
|
+
super
|
1166
|
+
io.close
|
1167
|
+
end
|
1168
|
+
end
|
1169
|
+
|
1163
1170
|
def self.wrap_with_ssl(io)
|
1164
1171
|
raise Net::LDAP::LdapError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL
|
1165
1172
|
ctx = OpenSSL::SSL::SSLContext.new
|
1166
1173
|
conn = OpenSSL::SSL::SSLSocket.new(io, ctx)
|
1167
1174
|
conn.connect
|
1168
|
-
|
1175
|
+
|
1176
|
+
# Doesn't work:
|
1177
|
+
# conn.sync_close = true
|
1169
1178
|
|
1170
1179
|
conn.extend(GetbyteForSSLSocket) unless conn.respond_to?(:getbyte)
|
1180
|
+
conn.extend(FixSSLSocketSyncClose)
|
1171
1181
|
|
1172
1182
|
conn
|
1173
1183
|
end
|
@@ -1206,7 +1216,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
1206
1216
|
# go here.
|
1207
1217
|
when :start_tls
|
1208
1218
|
msgid = next_msgid.to_ber
|
1209
|
-
request = [Net::LDAP::StartTlsOid.
|
1219
|
+
request = [Net::LDAP::StartTlsOid.to_ber_contextspecific(0)].to_ber_appsequence(Net::LDAP::PDU::ExtendedRequest)
|
1210
1220
|
request_pkt = [msgid, request].to_ber_sequence
|
1211
1221
|
@conn.write request_pkt
|
1212
1222
|
be = @conn.read_ber(Net::LDAP::AsnSyntax)
|
data/lib/net/ldap/entry.rb
CHANGED
@@ -113,6 +113,14 @@ class Net::LDAP::Entry
|
|
113
113
|
@myhash[name] || []
|
114
114
|
end
|
115
115
|
|
116
|
+
##
|
117
|
+
# Read the first value for the provided attribute. The attribute name
|
118
|
+
# is canonicalized prior to reading. Returns nil if the attribute does
|
119
|
+
# not exist.
|
120
|
+
def first(name)
|
121
|
+
self[name].first
|
122
|
+
end
|
123
|
+
|
116
124
|
##
|
117
125
|
# Returns the first distinguished name (dn) of the Entry as a \String.
|
118
126
|
def dn
|
@@ -147,7 +155,7 @@ class Net::LDAP::Entry
|
|
147
155
|
Net::LDAP::Dataset.from_entry(self).to_ldif_string
|
148
156
|
end
|
149
157
|
|
150
|
-
def respond_to?(sym) #:nodoc:
|
158
|
+
def respond_to?(sym, include_all = false) #:nodoc:
|
151
159
|
return true if valid_attribute?(self.class.attribute_name(sym))
|
152
160
|
return super
|
153
161
|
end
|
data/lib/net/ldap/filter.rb
CHANGED
@@ -65,22 +65,22 @@ class Net::LDAP::Filter
|
|
65
65
|
new(:eq, attribute, value)
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
68
|
+
##
|
69
|
+
# Creates a Filter object indicating a binary comparison.
|
70
|
+
# this prevents the search data from being forced into a UTF-8 string.
|
71
|
+
#
|
72
|
+
# This is primarily used for Microsoft Active Directory to compare
|
73
|
+
# GUID values.
|
74
|
+
#
|
75
|
+
# # for guid represented as hex charecters
|
76
|
+
# guid = "6a31b4a12aa27a41aca9603f27dd5116"
|
77
|
+
# guid_bin = [guid].pack("H*")
|
78
|
+
# f = Net::LDAP::Filter.bineq("objectGUID", guid_bin)
|
79
|
+
#
|
80
|
+
# This filter does not perform any escaping.
|
81
|
+
def bineq(attribute, value)
|
82
|
+
new(:bineq, attribute, value)
|
83
|
+
end
|
84
84
|
|
85
85
|
##
|
86
86
|
# Creates a Filter object indicating extensible comparison. This Filter
|
@@ -414,10 +414,8 @@ class Net::LDAP::Filter
|
|
414
414
|
case @op
|
415
415
|
when :ne
|
416
416
|
"!(#{@left}=#{@right})"
|
417
|
-
when :eq
|
417
|
+
when :eq, :bineq
|
418
418
|
"#{@left}=#{@right}"
|
419
|
-
when :bineq
|
420
|
-
"#{@left}=#{@right}"
|
421
419
|
when :ex
|
422
420
|
"#{@left}:=#{@right}"
|
423
421
|
when :ge
|
@@ -527,9 +525,9 @@ class Net::LDAP::Filter
|
|
527
525
|
else # equality
|
528
526
|
[@left.to_s.to_ber, unescape(@right).to_ber].to_ber_contextspecific(3)
|
529
527
|
end
|
530
|
-
|
531
|
-
|
532
|
-
|
528
|
+
when :bineq
|
529
|
+
# make sure data is not forced to UTF-8
|
530
|
+
[@left.to_s.to_ber, unescape(@right).to_ber_bin].to_ber_contextspecific(3)
|
533
531
|
when :ex
|
534
532
|
seq = []
|
535
533
|
|
@@ -755,7 +753,7 @@ class Net::LDAP::Filter
|
|
755
753
|
scanner.scan(/\s*/)
|
756
754
|
if op = scanner.scan(/<=|>=|!=|:=|=/)
|
757
755
|
scanner.scan(/\s*/)
|
758
|
-
if value = scanner.scan(/(?:[-\w
|
756
|
+
if value = scanner.scan(/(?:[-\w*.+:@=,#\$%&!'\s\xC3\x80-\xCA\xAF]|[^\x00-\x7F]|\\[a-fA-F\d]{2})+/u)
|
759
757
|
# 20100313 AZ: Assumes that "(uid=george*)" is the same as
|
760
758
|
# "(uid=george* )". The standard doesn't specify, but I can find
|
761
759
|
# no examples that suggest otherwise.
|
data/lib/net/ldap/version.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
require 'net/ldap'
|
4
|
+
require 'timeout'
|
4
5
|
|
5
6
|
describe "BER serialisation (SSL)" do
|
6
7
|
# Transmits str to #to and reads it back from #from.
|
7
8
|
#
|
8
9
|
def transmit(str)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
Timeout::timeout(1) do
|
11
|
+
to.write(str)
|
12
|
+
to.close
|
13
|
+
|
14
|
+
from.read
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
attr_reader :to, :from
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/ber/ber_spec.rb
CHANGED
@@ -33,28 +33,28 @@ describe "BER encoding of" do
|
|
33
33
|
context "numbers" do
|
34
34
|
# Sample based
|
35
35
|
{
|
36
|
-
0 => "\x02\x01\x00",
|
37
|
-
1 => "\x02\x01\x01",
|
38
|
-
127 => "\x02\x01\x7F",
|
39
|
-
128 => "\x02\x01\x80",
|
40
|
-
255 => "\x02\x01\xFF",
|
41
|
-
256 => "\x02\x02\x01\x00",
|
42
|
-
65535 => "\x02\x02\xFF\xFF",
|
43
|
-
65536 => "\x02\x03\x01\x00\x00",
|
44
|
-
16_777_215 => "\x02\x03\xFF\xFF\xFF",
|
45
|
-
0x01000000 => "\x02\x04\x01\x00\x00\x00",
|
46
|
-
0x3FFFFFFF => "\x02\x04\x3F\xFF\xFF\xFF",
|
47
|
-
0x4FFFFFFF => "\x02\x04\x4F\xFF\xFF\xFF",
|
48
|
-
|
36
|
+
0 => raw_string("\x02\x01\x00"),
|
37
|
+
1 => raw_string("\x02\x01\x01"),
|
38
|
+
127 => raw_string("\x02\x01\x7F"),
|
39
|
+
128 => raw_string("\x02\x01\x80"),
|
40
|
+
255 => raw_string("\x02\x01\xFF"),
|
41
|
+
256 => raw_string("\x02\x02\x01\x00"),
|
42
|
+
65535 => raw_string("\x02\x02\xFF\xFF"),
|
43
|
+
65536 => raw_string("\x02\x03\x01\x00\x00"),
|
44
|
+
16_777_215 => raw_string("\x02\x03\xFF\xFF\xFF"),
|
45
|
+
0x01000000 => raw_string("\x02\x04\x01\x00\x00\x00"),
|
46
|
+
0x3FFFFFFF => raw_string("\x02\x04\x3F\xFF\xFF\xFF"),
|
47
|
+
0x4FFFFFFF => raw_string("\x02\x04\x4F\xFF\xFF\xFF"),
|
48
|
+
|
49
49
|
# Some odd samples...
|
50
|
-
5 => "\002\001\005",
|
51
|
-
500 => "\002\002\001\364",
|
52
|
-
50_000 => "\x02\x02\xC3P",
|
53
|
-
5_000_000_000 => "\002\005\001*\005\362\000"
|
54
|
-
}.each do |number, expected_encoding|
|
50
|
+
5 => raw_string("\002\001\005"),
|
51
|
+
500 => raw_string("\002\002\001\364"),
|
52
|
+
50_000 => raw_string("\x02\x02\xC3P"),
|
53
|
+
5_000_000_000 => raw_string("\002\005\001*\005\362\000")
|
54
|
+
}.each do |number, expected_encoding|
|
55
55
|
it "should encode #{number} as #{expected_encoding.inspect}" do
|
56
56
|
number.to_ber.should == expected_encoding
|
57
|
-
end
|
57
|
+
end
|
58
58
|
end
|
59
59
|
|
60
60
|
# Round-trip encoding: This is mostly to be sure to cover Bignums well.
|
@@ -79,7 +79,7 @@ describe "BER encoding of" do
|
|
79
79
|
context "strings" do
|
80
80
|
it "should properly encode UTF-8 strings" do
|
81
81
|
"\u00e5".force_encoding("UTF-8").to_ber.should ==
|
82
|
-
"\x04\x02\xC3\xA5"
|
82
|
+
raw_string("\x04\x02\xC3\xA5")
|
83
83
|
end
|
84
84
|
it "should properly encode strings encodable as UTF-8" do
|
85
85
|
"teststring".encode("US-ASCII").to_ber.should == "\x04\nteststring"
|
@@ -87,7 +87,7 @@ describe "BER encoding of" do
|
|
87
87
|
it "should properly encode binary data strings using to_ber_bin" do
|
88
88
|
# This is used for searching for GUIDs in Active Directory
|
89
89
|
["6a31b4a12aa27a41aca9603f27dd5116"].pack("H*").to_ber_bin.should ==
|
90
|
-
"\x04\x10" + "j1\xB4\xA1*\xA2zA\xAC\xA9`?'\xDDQ\x16"
|
90
|
+
raw_string("\x04\x10" + "j1\xB4\xA1*\xA2zA\xAC\xA9`?'\xDDQ\x16")
|
91
91
|
end
|
92
92
|
it "should not fail on strings that can not be converted to UTF-8" do
|
93
93
|
error = Encoding::UndefinedConversionError
|
@@ -6,7 +6,7 @@ describe String, "when extended with BER core extensions" do
|
|
6
6
|
context "when passed an ldap bind request and some extra data" do
|
7
7
|
attr_reader :str, :result
|
8
8
|
before(:each) do
|
9
|
-
@str = "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus UNCONSUMED"
|
9
|
+
@str = raw_string("0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus UNCONSUMED")
|
10
10
|
@result = str.read_ber!(Net::LDAP::AsnSyntax)
|
11
11
|
end
|
12
12
|
|
@@ -22,7 +22,7 @@ describe String, "when extended with BER core extensions" do
|
|
22
22
|
before(:each) do
|
23
23
|
stub_exception_class = Class.new(StandardError)
|
24
24
|
|
25
|
-
@initial_value = "0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus"
|
25
|
+
@initial_value = raw_string("0$\002\001\001`\037\002\001\003\004\rAdministrator\200\vad_is_bogus")
|
26
26
|
@str = initial_value.dup
|
27
27
|
|
28
28
|
# Defines a string
|
@@ -16,5 +16,11 @@ describe Net::LDAP::Filter::FilterParser do
|
|
16
16
|
expect(Net::LDAP::Filter::FilterParser.parse(filter_string)).to be_a Net::LDAP::Filter
|
17
17
|
end
|
18
18
|
end
|
19
|
+
context "Given string including colons ':'" do
|
20
|
+
let(:filter_string) { "(ismemberof=cn=edu:berkeley:app:calmessages:deans,ou=campus groups,dc=berkeley,dc=edu)" }
|
21
|
+
specify "should generate filter object" do
|
22
|
+
expect(Net::LDAP::Filter::FilterParser.parse(filter_string)).to be_a Net::LDAP::Filter
|
23
|
+
end
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
@@ -83,12 +83,12 @@ describe Net::LDAP::Filter do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
context 'with a well-known BER string' do
|
86
|
-
ber = "\xa4\x2d" \
|
86
|
+
ber = raw_string("\xa4\x2d" \
|
87
87
|
"\x04\x0b" "objectclass" \
|
88
88
|
"\x30\x1e" \
|
89
89
|
"\x80\x08" "foo" "*\\" "bar" \
|
90
90
|
"\x81\x08" "foo" "*\\" "bar" \
|
91
|
-
"\x82\x08" "foo" "*\\" "bar"
|
91
|
+
"\x82\x08" "foo" "*\\" "bar")
|
92
92
|
|
93
93
|
describe "<- .to_ber" do
|
94
94
|
[
|
data/test/test_snmp.rb
CHANGED
@@ -4,10 +4,15 @@ require 'common'
|
|
4
4
|
require 'net/snmp'
|
5
5
|
|
6
6
|
class TestSnmp < Test::Unit::TestCase
|
7
|
-
|
8
|
-
|
7
|
+
def self.raw_string(s)
|
8
|
+
# Conveniently, String#b only needs to be called when it exists
|
9
|
+
s.respond_to?(:b) ? s.b : s
|
10
|
+
end
|
11
|
+
|
12
|
+
SnmpGetRequest = raw_string("0'\002\001\000\004\006public\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000")
|
13
|
+
SnmpGetResponse = raw_string("0+\002\001\000\004\006public\242\036\002\002'\017\002\001\000\002\001\0000\0220\020\006\b+\006\001\002\001\001\001\000\004\004test")
|
9
14
|
|
10
|
-
SnmpGetRequestXXX = "0'\002\001\000\004\006xxxxxx\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000"
|
15
|
+
SnmpGetRequestXXX = raw_string("0'\002\001\000\004\006xxxxxx\240\032\002\002?*\002\001\000\002\001\0000\0160\f\006\b+\006\001\002\001\001\001\000\005\000")
|
11
16
|
|
12
17
|
def test_invalid_packet
|
13
18
|
data = "xxxx"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-ldap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Francis Cianfrocca
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2014-04
|
16
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rdoc
|