net-ldap 0.10.1 → 0.11
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/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +462 -0
- data/.travis.yml +1 -1
- data/Contributors.rdoc +2 -0
- data/History.rdoc +9 -0
- data/README.rdoc +15 -0
- data/Rakefile +13 -2
- data/lib/net/ldap.rb +46 -97
- data/lib/net/ldap/connection.rb +30 -28
- data/lib/net/ldap/entry.rb +1 -1
- data/lib/net/ldap/error.rb +38 -0
- data/lib/net/ldap/filter.rb +9 -10
- data/lib/net/ldap/password.rb +5 -5
- data/lib/net/ldap/version.rb +1 -1
- data/net-ldap.gemspec +1 -0
- data/test/test_filter.rb +7 -2
- data/test/test_ldap_connection.rb +3 -3
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 093221df6c10572671e2d05af258d473d1c17e78
|
4
|
+
data.tar.gz: e27ca24638d8d46f2a8a39900fb90d8ca6a7f1fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f1bdba62c083cfc5b128226107f94815fb6d8b2d4d04fb47e30271289d6ffa193dc5e9363a2f44a04b7d5a30af08a97bba3d5afeda4ce035d7581f533db639a
|
7
|
+
data.tar.gz: 9ff4126e94e791948777a1ed4396c21cdf62fb9a446a4eb240364302367c08a27566243af69bdf907fd2f8bfbe92117513eccc033db97f3c47acefab348971a1
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,462 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-12-19 15:32:44 +1100 using RuboCop version 0.28.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 12
|
9
|
+
# Configuration parameters: AllowSafeAssignment.
|
10
|
+
Lint/AssignmentInCondition:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
# Configuration parameters: AlignWith, SupportedStyles.
|
15
|
+
Lint/EndAlignment:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
# Offense count: 1
|
19
|
+
Lint/RescueException:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
# Offense count: 1
|
23
|
+
Lint/ShadowingOuterLocalVariable:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
# Offense count: 9
|
27
|
+
# Cop supports --auto-correct.
|
28
|
+
Lint/UnusedBlockArgument:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
# Offense count: 3
|
32
|
+
# Cop supports --auto-correct.
|
33
|
+
Lint/UnusedMethodArgument:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
# Offense count: 7
|
37
|
+
Lint/UselessAssignment:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
# Offense count: 47
|
41
|
+
Metrics/AbcSize:
|
42
|
+
Max: 114
|
43
|
+
|
44
|
+
# Offense count: 11
|
45
|
+
Metrics/BlockNesting:
|
46
|
+
Max: 4
|
47
|
+
|
48
|
+
# Offense count: 9
|
49
|
+
# Configuration parameters: CountComments.
|
50
|
+
Metrics/ClassLength:
|
51
|
+
Max: 470
|
52
|
+
|
53
|
+
# Offense count: 20
|
54
|
+
Metrics/CyclomaticComplexity:
|
55
|
+
Max: 41
|
56
|
+
|
57
|
+
# Offense count: 193
|
58
|
+
# Configuration parameters: AllowURI, URISchemes.
|
59
|
+
Metrics/LineLength:
|
60
|
+
Max: 360
|
61
|
+
|
62
|
+
# Offense count: 71
|
63
|
+
# Configuration parameters: CountComments.
|
64
|
+
Metrics/MethodLength:
|
65
|
+
Max: 130
|
66
|
+
|
67
|
+
# Offense count: 13
|
68
|
+
Metrics/PerceivedComplexity:
|
69
|
+
Max: 36
|
70
|
+
|
71
|
+
# Offense count: 1
|
72
|
+
Style/AccessorMethodName:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
# Offense count: 4
|
76
|
+
# Cop supports --auto-correct.
|
77
|
+
Style/AlignArray:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
# Offense count: 3
|
81
|
+
# Cop supports --auto-correct.
|
82
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
83
|
+
Style/AlignParameters:
|
84
|
+
Enabled: false
|
85
|
+
|
86
|
+
# Offense count: 36
|
87
|
+
# Cop supports --auto-correct.
|
88
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
89
|
+
Style/AndOr:
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
# Offense count: 1
|
93
|
+
# Cop supports --auto-correct.
|
94
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
95
|
+
Style/BarePercentLiterals:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
# Offense count: 1
|
99
|
+
# Cop supports --auto-correct.
|
100
|
+
Style/BlockComments:
|
101
|
+
Enabled: false
|
102
|
+
|
103
|
+
# Offense count: 20
|
104
|
+
# Cop supports --auto-correct.
|
105
|
+
Style/Blocks:
|
106
|
+
Enabled: false
|
107
|
+
|
108
|
+
# Offense count: 2
|
109
|
+
# Cop supports --auto-correct.
|
110
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
111
|
+
Style/BracesAroundHashParameters:
|
112
|
+
Enabled: false
|
113
|
+
|
114
|
+
# Offense count: 4
|
115
|
+
# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
|
116
|
+
Style/CaseIndentation:
|
117
|
+
Enabled: false
|
118
|
+
|
119
|
+
# Offense count: 4
|
120
|
+
# Cop supports --auto-correct.
|
121
|
+
Style/CharacterLiteral:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
# Offense count: 22
|
125
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
126
|
+
Style/ClassAndModuleChildren:
|
127
|
+
Enabled: false
|
128
|
+
|
129
|
+
# Offense count: 1
|
130
|
+
# Cop supports --auto-correct.
|
131
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
132
|
+
Style/ClassCheck:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
# Offense count: 13
|
136
|
+
# Cop supports --auto-correct.
|
137
|
+
Style/ColonMethodCall:
|
138
|
+
Enabled: false
|
139
|
+
|
140
|
+
# Offense count: 2
|
141
|
+
# Configuration parameters: Keywords.
|
142
|
+
Style/CommentAnnotation:
|
143
|
+
Enabled: false
|
144
|
+
|
145
|
+
# Offense count: 86
|
146
|
+
Style/ConstantName:
|
147
|
+
Enabled: false
|
148
|
+
|
149
|
+
# Offense count: 18
|
150
|
+
# Cop supports --auto-correct.
|
151
|
+
Style/DeprecatedHashMethods:
|
152
|
+
Enabled: false
|
153
|
+
|
154
|
+
# Offense count: 46
|
155
|
+
Style/Documentation:
|
156
|
+
Enabled: false
|
157
|
+
|
158
|
+
# Offense count: 23
|
159
|
+
# Cop supports --auto-correct.
|
160
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
161
|
+
Style/DotPosition:
|
162
|
+
Enabled: false
|
163
|
+
|
164
|
+
# Offense count: 1
|
165
|
+
# Cop supports --auto-correct.
|
166
|
+
Style/ElseAlignment:
|
167
|
+
Enabled: false
|
168
|
+
|
169
|
+
# Offense count: 4
|
170
|
+
# Cop supports --auto-correct.
|
171
|
+
# Configuration parameters: AllowAdjacentOneLineDefs.
|
172
|
+
Style/EmptyLineBetweenDefs:
|
173
|
+
Enabled: false
|
174
|
+
|
175
|
+
# Offense count: 9
|
176
|
+
# Cop supports --auto-correct.
|
177
|
+
Style/EmptyLines:
|
178
|
+
Enabled: false
|
179
|
+
|
180
|
+
# Offense count: 1
|
181
|
+
# Cop supports --auto-correct.
|
182
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
183
|
+
Style/EmptyLinesAroundClassBody:
|
184
|
+
Enabled: false
|
185
|
+
|
186
|
+
# Offense count: 2
|
187
|
+
# Cop supports --auto-correct.
|
188
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
189
|
+
Style/EmptyLinesAroundModuleBody:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
# Offense count: 3
|
193
|
+
Style/EvenOdd:
|
194
|
+
Enabled: false
|
195
|
+
|
196
|
+
# Offense count: 1
|
197
|
+
# Configuration parameters: Exclude.
|
198
|
+
Style/FileName:
|
199
|
+
Enabled: false
|
200
|
+
|
201
|
+
# Offense count: 9
|
202
|
+
# Configuration parameters: AllowedVariables.
|
203
|
+
Style/GlobalVars:
|
204
|
+
Enabled: false
|
205
|
+
|
206
|
+
# Offense count: 3
|
207
|
+
# Configuration parameters: MinBodyLength.
|
208
|
+
Style/GuardClause:
|
209
|
+
Enabled: false
|
210
|
+
|
211
|
+
# Offense count: 150
|
212
|
+
# Cop supports --auto-correct.
|
213
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
214
|
+
Style/HashSyntax:
|
215
|
+
Enabled: false
|
216
|
+
|
217
|
+
# Offense count: 8
|
218
|
+
# Configuration parameters: MaxLineLength.
|
219
|
+
Style/IfUnlessModifier:
|
220
|
+
Enabled: false
|
221
|
+
|
222
|
+
# Offense count: 2
|
223
|
+
# Cop supports --auto-correct.
|
224
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
225
|
+
Style/IndentHash:
|
226
|
+
Enabled: false
|
227
|
+
|
228
|
+
# Offense count: 6
|
229
|
+
# Cop supports --auto-correct.
|
230
|
+
# Configuration parameters: Width.
|
231
|
+
Style/IndentationWidth:
|
232
|
+
Enabled: false
|
233
|
+
|
234
|
+
# Offense count: 2
|
235
|
+
# Cop supports --auto-correct.
|
236
|
+
Style/LeadingCommentSpace:
|
237
|
+
Enabled: false
|
238
|
+
|
239
|
+
# Offense count: 21
|
240
|
+
# Cop supports --auto-correct.
|
241
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
242
|
+
Style/MethodDefParentheses:
|
243
|
+
Enabled: false
|
244
|
+
|
245
|
+
# Offense count: 1
|
246
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
247
|
+
Style/MethodName:
|
248
|
+
Enabled: false
|
249
|
+
|
250
|
+
# Offense count: 5
|
251
|
+
# Cop supports --auto-correct.
|
252
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
253
|
+
Style/MultilineOperationIndentation:
|
254
|
+
Enabled: false
|
255
|
+
|
256
|
+
# Offense count: 1
|
257
|
+
Style/MultilineTernaryOperator:
|
258
|
+
Enabled: false
|
259
|
+
|
260
|
+
# Offense count: 1
|
261
|
+
# Cop supports --auto-correct.
|
262
|
+
Style/NegatedIf:
|
263
|
+
Enabled: false
|
264
|
+
|
265
|
+
# Offense count: 1
|
266
|
+
# Cop supports --auto-correct.
|
267
|
+
Style/NegatedWhile:
|
268
|
+
Enabled: false
|
269
|
+
|
270
|
+
# Offense count: 3
|
271
|
+
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
|
272
|
+
Style/Next:
|
273
|
+
Enabled: false
|
274
|
+
|
275
|
+
# Offense count: 1
|
276
|
+
# Cop supports --auto-correct.
|
277
|
+
Style/NilComparison:
|
278
|
+
Enabled: false
|
279
|
+
|
280
|
+
# Offense count: 1
|
281
|
+
# Cop supports --auto-correct.
|
282
|
+
# Configuration parameters: IncludeSemanticChanges.
|
283
|
+
Style/NonNilCheck:
|
284
|
+
Enabled: false
|
285
|
+
|
286
|
+
# Offense count: 1
|
287
|
+
# Cop supports --auto-correct.
|
288
|
+
Style/Not:
|
289
|
+
Enabled: false
|
290
|
+
|
291
|
+
# Offense count: 10
|
292
|
+
# Cop supports --auto-correct.
|
293
|
+
Style/NumericLiterals:
|
294
|
+
MinDigits: 8
|
295
|
+
|
296
|
+
# Offense count: 3
|
297
|
+
Style/OpMethod:
|
298
|
+
Enabled: false
|
299
|
+
|
300
|
+
# Offense count: 6
|
301
|
+
# Cop supports --auto-correct.
|
302
|
+
# Configuration parameters: AllowSafeAssignment.
|
303
|
+
Style/ParenthesesAroundCondition:
|
304
|
+
Enabled: false
|
305
|
+
|
306
|
+
# Offense count: 3
|
307
|
+
# Cop supports --auto-correct.
|
308
|
+
# Configuration parameters: PreferredDelimiters.
|
309
|
+
Style/PercentLiteralDelimiters:
|
310
|
+
Enabled: false
|
311
|
+
|
312
|
+
# Offense count: 11
|
313
|
+
# Cop supports --auto-correct.
|
314
|
+
Style/PerlBackrefs:
|
315
|
+
Enabled: false
|
316
|
+
|
317
|
+
# Offense count: 9
|
318
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
319
|
+
Style/RaiseArgs:
|
320
|
+
Enabled: false
|
321
|
+
|
322
|
+
# Offense count: 1
|
323
|
+
# Cop supports --auto-correct.
|
324
|
+
Style/RedundantBegin:
|
325
|
+
Enabled: false
|
326
|
+
|
327
|
+
# Offense count: 3
|
328
|
+
# Cop supports --auto-correct.
|
329
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
330
|
+
Style/RedundantReturn:
|
331
|
+
Enabled: false
|
332
|
+
|
333
|
+
# Offense count: 7
|
334
|
+
# Cop supports --auto-correct.
|
335
|
+
Style/RedundantSelf:
|
336
|
+
Enabled: false
|
337
|
+
|
338
|
+
# Offense count: 1
|
339
|
+
# Configuration parameters: MaxSlashes.
|
340
|
+
Style/RegexpLiteral:
|
341
|
+
Enabled: false
|
342
|
+
|
343
|
+
# Offense count: 2
|
344
|
+
Style/RescueModifier:
|
345
|
+
Enabled: false
|
346
|
+
|
347
|
+
# Offense count: 7
|
348
|
+
# Cop supports --auto-correct.
|
349
|
+
# Configuration parameters: AllowAsExpressionSeparator.
|
350
|
+
Style/Semicolon:
|
351
|
+
Enabled: false
|
352
|
+
|
353
|
+
# Offense count: 61
|
354
|
+
# Cop supports --auto-correct.
|
355
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
356
|
+
Style/SignalException:
|
357
|
+
Enabled: false
|
358
|
+
|
359
|
+
# Offense count: 2
|
360
|
+
# Configuration parameters: Methods.
|
361
|
+
Style/SingleLineBlockParams:
|
362
|
+
Enabled: false
|
363
|
+
|
364
|
+
# Offense count: 2
|
365
|
+
# Cop supports --auto-correct.
|
366
|
+
Style/SingleSpaceBeforeFirstArg:
|
367
|
+
Enabled: false
|
368
|
+
|
369
|
+
# Offense count: 24
|
370
|
+
# Cop supports --auto-correct.
|
371
|
+
Style/SpaceAfterComma:
|
372
|
+
Enabled: false
|
373
|
+
|
374
|
+
# Offense count: 2
|
375
|
+
# Cop supports --auto-correct.
|
376
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
377
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
378
|
+
Enabled: false
|
379
|
+
|
380
|
+
# Offense count: 8
|
381
|
+
# Cop supports --auto-correct.
|
382
|
+
Style/SpaceAroundOperators:
|
383
|
+
Enabled: false
|
384
|
+
|
385
|
+
# Offense count: 2
|
386
|
+
# Cop supports --auto-correct.
|
387
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
388
|
+
Style/SpaceBeforeBlockBraces:
|
389
|
+
Enabled: false
|
390
|
+
|
391
|
+
# Offense count: 18
|
392
|
+
# Cop supports --auto-correct.
|
393
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
394
|
+
Style/SpaceInsideBlockBraces:
|
395
|
+
Enabled: false
|
396
|
+
|
397
|
+
# Offense count: 37
|
398
|
+
# Cop supports --auto-correct.
|
399
|
+
Style/SpaceInsideBrackets:
|
400
|
+
Enabled: false
|
401
|
+
|
402
|
+
# Offense count: 1
|
403
|
+
# Cop supports --auto-correct.
|
404
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
|
405
|
+
Style/SpaceInsideHashLiteralBraces:
|
406
|
+
Enabled: false
|
407
|
+
|
408
|
+
# Offense count: 20
|
409
|
+
# Cop supports --auto-correct.
|
410
|
+
Style/SpaceInsideParens:
|
411
|
+
Enabled: false
|
412
|
+
|
413
|
+
# Offense count: 5
|
414
|
+
# Cop supports --auto-correct.
|
415
|
+
Style/SpecialGlobalVars:
|
416
|
+
Enabled: false
|
417
|
+
|
418
|
+
# Offense count: 645
|
419
|
+
# Cop supports --auto-correct.
|
420
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
421
|
+
Style/StringLiterals:
|
422
|
+
Enabled: false
|
423
|
+
|
424
|
+
# Offense count: 10
|
425
|
+
# Cop supports --auto-correct.
|
426
|
+
# Configuration parameters: IgnoredMethods.
|
427
|
+
Style/SymbolProc:
|
428
|
+
Enabled: false
|
429
|
+
|
430
|
+
# Offense count: 1
|
431
|
+
# Cop supports --auto-correct.
|
432
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
433
|
+
Style/TrailingBlankLines:
|
434
|
+
Enabled: false
|
435
|
+
|
436
|
+
# Offense count: 9
|
437
|
+
# Cop supports --auto-correct.
|
438
|
+
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
|
439
|
+
Style/TrailingComma:
|
440
|
+
Enabled: false
|
441
|
+
|
442
|
+
# Offense count: 1
|
443
|
+
# Cop supports --auto-correct.
|
444
|
+
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
|
445
|
+
Style/TrivialAccessors:
|
446
|
+
Enabled: false
|
447
|
+
|
448
|
+
# Offense count: 5
|
449
|
+
# Cop supports --auto-correct.
|
450
|
+
Style/UnneededPercentQ:
|
451
|
+
Enabled: false
|
452
|
+
|
453
|
+
# Offense count: 1
|
454
|
+
# Configuration parameters: MaxLineLength.
|
455
|
+
Style/WhileUntilModifier:
|
456
|
+
Enabled: false
|
457
|
+
|
458
|
+
# Offense count: 1
|
459
|
+
# Cop supports --auto-correct.
|
460
|
+
# Configuration parameters: WordRegex.
|
461
|
+
Style/WordArray:
|
462
|
+
MinSize: 2
|
data/.travis.yml
CHANGED
data/Contributors.rdoc
CHANGED
data/History.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== Net::LDAP 0.11
|
2
|
+
* Major enhancements:
|
3
|
+
* #183 Specific errors subclassing Net::LDAP::Error
|
4
|
+
* Bug fixes:
|
5
|
+
* #176 Fix nil tls options
|
6
|
+
* #184 Search guards against nil queued reads. Connection#unescape handles numerics
|
7
|
+
* Code clean-up:
|
8
|
+
* #180 Refactor connection establishment
|
9
|
+
|
1
10
|
=== Net::LDAP 0.10.1
|
2
11
|
* Bug fixes:
|
3
12
|
* Fix Integer BER encoding of signed values
|
data/README.rdoc
CHANGED
@@ -37,12 +37,27 @@ sources.
|
|
37
37
|
|
38
38
|
Simply require either 'net-ldap' or 'net/ldap'.
|
39
39
|
|
40
|
+
== Develop
|
41
|
+
|
42
|
+
This task will run the test suite and the
|
43
|
+
{RuboCop}[https://github.com/bbatsov/rubocop] static code analyzer.
|
44
|
+
|
45
|
+
rake rubotest
|
46
|
+
|
47
|
+
To run the integration tests against an LDAP server:
|
48
|
+
|
49
|
+
cd test/support/vm/openldap
|
50
|
+
vagrant up
|
51
|
+
cd ../../../..
|
52
|
+
INTEGRATION=openldap bundle exec rake rubotest
|
53
|
+
|
40
54
|
== Release
|
41
55
|
|
42
56
|
This section is for gem maintainers to cut a new version of the gem.
|
43
57
|
|
44
58
|
* Update lib/net/ldap/version.rb to next version number X.X.X following {semver}(http://semver.org/).
|
45
59
|
* Update `History.rdoc`. Get latest changes with `git log --oneline vLAST_RELEASE..HEAD | grep Merge`
|
60
|
+
|
46
61
|
* On the master branch, run `script/release`
|
47
62
|
|
48
63
|
:include: Contributors.rdoc
|
data/Rakefile
CHANGED
@@ -3,11 +3,22 @@
|
|
3
3
|
# vim: syntax=ruby
|
4
4
|
|
5
5
|
require 'rake/testtask'
|
6
|
+
require 'rubocop/rake_task'
|
7
|
+
require 'bundler'
|
8
|
+
|
9
|
+
RuboCop::RakeTask.new
|
6
10
|
|
7
11
|
Rake::TestTask.new do |t|
|
8
|
-
t.libs <<
|
12
|
+
t.libs << 'test'
|
9
13
|
t.test_files = FileList['test/**/test_*.rb']
|
10
14
|
t.verbose = true
|
15
|
+
t.description = 'Run tests, set INTEGRATION=openldap to run integration tests, INTEGRATION_HOST and INTEGRATION_PORT are also supported'
|
11
16
|
end
|
12
17
|
|
13
|
-
|
18
|
+
desc 'Run tests and RuboCop (RuboCop runs on mri only)'
|
19
|
+
task ci: [:test]
|
20
|
+
|
21
|
+
desc 'Run tests and RuboCop'
|
22
|
+
task rubotest: [:test, :rubocop]
|
23
|
+
|
24
|
+
task default: Bundler.current_ruby.mri? ? [:test, :rubocop] : [:test]
|
data/lib/net/ldap.rb
CHANGED
@@ -26,6 +26,7 @@ require 'net/ldap/entry'
|
|
26
26
|
require 'net/ldap/instrumentation'
|
27
27
|
require 'net/ldap/connection'
|
28
28
|
require 'net/ldap/version'
|
29
|
+
require 'net/ldap/error'
|
29
30
|
|
30
31
|
# == Quick-start for the Impatient
|
31
32
|
# === Quick Example of a user-authentication against an LDAP directory:
|
@@ -246,8 +247,6 @@ require 'net/ldap/version'
|
|
246
247
|
class Net::LDAP
|
247
248
|
include Net::LDAP::Instrumentation
|
248
249
|
|
249
|
-
class LdapError < StandardError; end
|
250
|
-
|
251
250
|
SearchScope_BaseObject = 0
|
252
251
|
SearchScope_SingleLevel = 1
|
253
252
|
SearchScope_WholeSubtree = 2
|
@@ -666,16 +665,11 @@ class Net::LDAP
|
|
666
665
|
# anything with the bind results. We then pass self to the caller's
|
667
666
|
# block, where he will execute his LDAP operations. Of course they will
|
668
667
|
# all generate auth failures if the bind was unsuccessful.
|
669
|
-
raise Net::LDAP::
|
668
|
+
raise Net::LDAP::AlreadyOpenedError, "Open already in progress" if @open_connection
|
670
669
|
|
671
670
|
instrument "open.net_ldap" do |payload|
|
672
671
|
begin
|
673
|
-
@open_connection =
|
674
|
-
Net::LDAP::Connection.new \
|
675
|
-
:host => @host,
|
676
|
-
:port => @port,
|
677
|
-
:encryption => @encryption,
|
678
|
-
:instrumentation_service => @instrumentation_service
|
672
|
+
@open_connection = new_connection
|
679
673
|
payload[:connection] = @open_connection
|
680
674
|
payload[:bind] = @open_connection.bind(@auth)
|
681
675
|
yield self
|
@@ -745,27 +739,11 @@ class Net::LDAP
|
|
745
739
|
result_set = return_result_set ? [] : nil
|
746
740
|
|
747
741
|
instrument "search.net_ldap", args do |payload|
|
748
|
-
|
749
|
-
|
742
|
+
@result = use_connection(args) do |conn|
|
743
|
+
conn.search(args) { |entry|
|
750
744
|
result_set << entry if result_set
|
751
745
|
yield entry if block_given?
|
752
746
|
}
|
753
|
-
else
|
754
|
-
begin
|
755
|
-
conn = Net::LDAP::Connection.new \
|
756
|
-
:host => @host,
|
757
|
-
:port => @port,
|
758
|
-
:encryption => @encryption,
|
759
|
-
:instrumentation_service => @instrumentation_service
|
760
|
-
if (@result = conn.bind(args[:auth] || @auth)).result_code == Net::LDAP::ResultCodeSuccess
|
761
|
-
@result = conn.search(args) { |entry|
|
762
|
-
result_set << entry if result_set
|
763
|
-
yield entry if block_given?
|
764
|
-
}
|
765
|
-
end
|
766
|
-
ensure
|
767
|
-
conn.close if conn
|
768
|
-
end
|
769
747
|
end
|
770
748
|
|
771
749
|
if return_result_set
|
@@ -844,11 +822,7 @@ class Net::LDAP
|
|
844
822
|
payload[:bind] = @result = @open_connection.bind(auth)
|
845
823
|
else
|
846
824
|
begin
|
847
|
-
conn =
|
848
|
-
:host => @host,
|
849
|
-
:port => @port,
|
850
|
-
:encryption => @encryption,
|
851
|
-
:instrumentation_service => @instrumentation_service
|
825
|
+
conn = new_connection
|
852
826
|
payload[:connection] = conn
|
853
827
|
payload[:bind] = @result = conn.bind(auth)
|
854
828
|
ensure
|
@@ -946,22 +920,8 @@ class Net::LDAP
|
|
946
920
|
# end
|
947
921
|
def add(args)
|
948
922
|
instrument "add.net_ldap", args do |payload|
|
949
|
-
|
950
|
-
|
951
|
-
else
|
952
|
-
@result = 0
|
953
|
-
begin
|
954
|
-
conn = Connection.new \
|
955
|
-
:host => @host,
|
956
|
-
:port => @port,
|
957
|
-
:encryption => @encryption,
|
958
|
-
:instrumentation_service => @instrumentation_service
|
959
|
-
if (@result = conn.bind(args[:auth] || @auth)).result_code == Net::LDAP::ResultCodeSuccess
|
960
|
-
@result = conn.add(args)
|
961
|
-
end
|
962
|
-
ensure
|
963
|
-
conn.close if conn
|
964
|
-
end
|
923
|
+
@result = use_connection(args) do |conn|
|
924
|
+
conn.add(args)
|
965
925
|
end
|
966
926
|
@result.success?
|
967
927
|
end
|
@@ -1050,24 +1010,9 @@ class Net::LDAP
|
|
1050
1010
|
# does _not_ imply transactional atomicity, which LDAP does not provide.
|
1051
1011
|
def modify(args)
|
1052
1012
|
instrument "modify.net_ldap", args do |payload|
|
1053
|
-
|
1054
|
-
|
1055
|
-
else
|
1056
|
-
@result = 0
|
1057
|
-
begin
|
1058
|
-
conn = Connection.new \
|
1059
|
-
:host => @host,
|
1060
|
-
:port => @port,
|
1061
|
-
:encryption => @encryption,
|
1062
|
-
:instrumentation_service => @instrumentation_service
|
1063
|
-
if (@result = conn.bind(args[:auth] || @auth)).result_code == Net::LDAP::ResultCodeSuccess
|
1064
|
-
@result = conn.modify(args)
|
1065
|
-
end
|
1066
|
-
ensure
|
1067
|
-
conn.close if conn
|
1068
|
-
end
|
1013
|
+
@result = use_connection(args) do |conn|
|
1014
|
+
conn.modify(args)
|
1069
1015
|
end
|
1070
|
-
|
1071
1016
|
@result.success?
|
1072
1017
|
end
|
1073
1018
|
end
|
@@ -1127,22 +1072,8 @@ class Net::LDAP
|
|
1127
1072
|
# _Documentation_ _stub_
|
1128
1073
|
def rename(args)
|
1129
1074
|
instrument "rename.net_ldap", args do |payload|
|
1130
|
-
|
1131
|
-
|
1132
|
-
else
|
1133
|
-
@result = 0
|
1134
|
-
begin
|
1135
|
-
conn = Connection.new \
|
1136
|
-
:host => @host,
|
1137
|
-
:port => @port,
|
1138
|
-
:encryption => @encryption,
|
1139
|
-
:instrumentation_service => @instrumentation_service
|
1140
|
-
if (@result = conn.bind(args[:auth] || @auth)).result_code == Net::LDAP::ResultCodeSuccess
|
1141
|
-
@result = conn.rename(args)
|
1142
|
-
end
|
1143
|
-
ensure
|
1144
|
-
conn.close if conn
|
1145
|
-
end
|
1075
|
+
@result = use_connection(args) do |conn|
|
1076
|
+
conn.rename(args)
|
1146
1077
|
end
|
1147
1078
|
@result.success?
|
1148
1079
|
end
|
@@ -1160,22 +1091,8 @@ class Net::LDAP
|
|
1160
1091
|
# ldap.delete :dn => dn
|
1161
1092
|
def delete(args)
|
1162
1093
|
instrument "delete.net_ldap", args do |payload|
|
1163
|
-
|
1164
|
-
|
1165
|
-
else
|
1166
|
-
@result = 0
|
1167
|
-
begin
|
1168
|
-
conn = Connection.new \
|
1169
|
-
:host => @host,
|
1170
|
-
:port => @port,
|
1171
|
-
:encryption => @encryption,
|
1172
|
-
:instrumentation_service => @instrumentation_service
|
1173
|
-
if (@result = conn.bind(args[:auth] || @auth)).result_code == Net::LDAP::ResultCodeSuccess
|
1174
|
-
@result = conn.delete(args)
|
1175
|
-
end
|
1176
|
-
ensure
|
1177
|
-
conn.close
|
1178
|
-
end
|
1094
|
+
@result = use_connection(args) do |conn|
|
1095
|
+
conn.delete(args)
|
1179
1096
|
end
|
1180
1097
|
@result.success?
|
1181
1098
|
end
|
@@ -1277,4 +1194,36 @@ class Net::LDAP
|
|
1277
1194
|
@server_caps ||= search_root_dse
|
1278
1195
|
@server_caps[:supportedcontrol].include?(Net::LDAP::LDAPControls::PAGED_RESULTS)
|
1279
1196
|
end
|
1197
|
+
|
1198
|
+
private
|
1199
|
+
|
1200
|
+
# Yields an open connection if there is one, otherwise establishes a new
|
1201
|
+
# connection, binds, and yields it. If binding fails, it will return the
|
1202
|
+
# result from that, and :use_connection: will not yield at all. If not
|
1203
|
+
# the return value is whatever is returned from the block.
|
1204
|
+
def use_connection(args)
|
1205
|
+
if @open_connection
|
1206
|
+
yield @open_connection
|
1207
|
+
else
|
1208
|
+
begin
|
1209
|
+
conn = new_connection
|
1210
|
+
if (result = conn.bind(args[:auth] || @auth)).result_code == Net::LDAP::ResultCodeSuccess
|
1211
|
+
yield conn
|
1212
|
+
else
|
1213
|
+
return result
|
1214
|
+
end
|
1215
|
+
ensure
|
1216
|
+
conn.close if conn
|
1217
|
+
end
|
1218
|
+
end
|
1219
|
+
end
|
1220
|
+
|
1221
|
+
# Establish a new connection to the LDAP server
|
1222
|
+
def new_connection
|
1223
|
+
Net::LDAP::Connection.new \
|
1224
|
+
:host => @host,
|
1225
|
+
:port => @port,
|
1226
|
+
:encryption => @encryption,
|
1227
|
+
:instrumentation_service => @instrumentation_service
|
1228
|
+
end
|
1280
1229
|
end # class LDAP
|
data/lib/net/ldap/connection.rb
CHANGED
@@ -12,13 +12,13 @@ class Net::LDAP::Connection #:nodoc:
|
|
12
12
|
begin
|
13
13
|
@conn = server[:socket] || TCPSocket.new(server[:host], server[:port])
|
14
14
|
rescue SocketError
|
15
|
-
raise Net::LDAP::
|
15
|
+
raise Net::LDAP::Error, "No such address or other socket error."
|
16
16
|
rescue Errno::ECONNREFUSED
|
17
|
-
raise Net::LDAP::
|
17
|
+
raise Net::LDAP::Error, "Server #{server[:host]} refused connection on port #{server[:port]}."
|
18
18
|
rescue Errno::EHOSTUNREACH => error
|
19
|
-
raise Net::LDAP::
|
19
|
+
raise Net::LDAP::Error, "Host #{server[:host]} was unreachable (#{error.message})"
|
20
20
|
rescue Errno::ETIMEDOUT
|
21
|
-
raise Net::LDAP::
|
21
|
+
raise Net::LDAP::Error, "Connection to #{server[:host]} timed out."
|
22
22
|
end
|
23
23
|
|
24
24
|
if server[:encryption]
|
@@ -42,7 +42,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.wrap_with_ssl(io, tls_options = {})
|
45
|
-
raise Net::LDAP::
|
45
|
+
raise Net::LDAP::NoOpenSSLError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL
|
46
46
|
|
47
47
|
ctx = OpenSSL::SSL::SSLContext.new
|
48
48
|
|
@@ -67,7 +67,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
67
67
|
# successfully-opened @conn instance variable, which is a TCP connection.
|
68
68
|
# Depending on the received arguments, we establish SSL, potentially
|
69
69
|
# replacing the value of @conn accordingly. Don't generate any errors here
|
70
|
-
# if no encryption is requested. DO raise Net::LDAP::
|
70
|
+
# if no encryption is requested. DO raise Net::LDAP::Error objects if encryption
|
71
71
|
# is requested and we have trouble setting it up. That includes if OpenSSL
|
72
72
|
# is not set up on the machine. (Question: how does the Ruby OpenSSL
|
73
73
|
# wrapper react in that case?) DO NOT filter exceptions raised by the
|
@@ -89,6 +89,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
89
89
|
# generously contributing the :start_tls path.
|
90
90
|
#++
|
91
91
|
def setup_encryption(args)
|
92
|
+
args[:tls_options] ||= {}
|
92
93
|
case args[:method]
|
93
94
|
when :simple_tls
|
94
95
|
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options])
|
@@ -104,16 +105,16 @@ class Net::LDAP::Connection #:nodoc:
|
|
104
105
|
pdu = queued_read(message_id)
|
105
106
|
|
106
107
|
if pdu.nil? || pdu.app_tag != Net::LDAP::PDU::ExtendedResponse
|
107
|
-
raise Net::LDAP::
|
108
|
+
raise Net::LDAP::NoStartTLSResultError, "no start_tls result"
|
108
109
|
end
|
109
110
|
|
110
111
|
if pdu.result_code.zero?
|
111
112
|
@conn = self.class.wrap_with_ssl(@conn, args[:tls_options])
|
112
113
|
else
|
113
|
-
raise Net::LDAP::
|
114
|
+
raise Net::LDAP::StartTlSError, "start_tls failed: #{pdu.result_code}"
|
114
115
|
end
|
115
116
|
else
|
116
|
-
raise Net::LDAP::
|
117
|
+
raise Net::LDAP::EncMethodUnsupportedError, "unsupported encryption method #{args[:method]}"
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
@@ -224,7 +225,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
224
225
|
elsif meth == :gss_spnego
|
225
226
|
bind_gss_spnego(auth)
|
226
227
|
else
|
227
|
-
raise Net::LDAP::
|
228
|
+
raise Net::LDAP::AuthMethodUnsupportedError, "Unsupported auth method (#{meth})"
|
228
229
|
end
|
229
230
|
end
|
230
231
|
end
|
@@ -240,7 +241,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
240
241
|
["", ""]
|
241
242
|
end
|
242
243
|
|
243
|
-
raise Net::LDAP::
|
244
|
+
raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless (user && psw)
|
244
245
|
|
245
246
|
message_id = next_msgid
|
246
247
|
request = [
|
@@ -252,7 +253,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
252
253
|
pdu = queued_read(message_id)
|
253
254
|
|
254
255
|
if !pdu || pdu.app_tag != Net::LDAP::PDU::BindResult
|
255
|
-
raise Net::LDAP::
|
256
|
+
raise Net::LDAP::NoBindResultError, "no bind result"
|
256
257
|
end
|
257
258
|
|
258
259
|
pdu
|
@@ -282,7 +283,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
282
283
|
def bind_sasl(auth)
|
283
284
|
mech, cred, chall = auth[:mechanism], auth[:initial_credential],
|
284
285
|
auth[:challenge_response]
|
285
|
-
raise Net::LDAP::
|
286
|
+
raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless (mech && cred && chall)
|
286
287
|
|
287
288
|
message_id = next_msgid
|
288
289
|
|
@@ -297,16 +298,16 @@ class Net::LDAP::Connection #:nodoc:
|
|
297
298
|
pdu = queued_read(message_id)
|
298
299
|
|
299
300
|
if !pdu || pdu.app_tag != Net::LDAP::PDU::BindResult
|
300
|
-
raise Net::LDAP::
|
301
|
+
raise Net::LDAP::NoBindResultError, "no bind result"
|
301
302
|
end
|
302
303
|
|
303
304
|
return pdu unless pdu.result_code == Net::LDAP::ResultCodeSaslBindInProgress
|
304
|
-
raise Net::LDAP::
|
305
|
+
raise Net::LDAP::SASLChallengeOverflowError, "sasl-challenge overflow" if ((n += 1) > MaxSaslChallenges)
|
305
306
|
|
306
307
|
cred = chall.call(pdu.result_server_sasl_creds)
|
307
308
|
}
|
308
309
|
|
309
|
-
raise Net::LDAP::
|
310
|
+
raise Net::LDAP::SASLChallengeOverflowError, "why are we here?"
|
310
311
|
end
|
311
312
|
private :bind_sasl
|
312
313
|
|
@@ -325,7 +326,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
325
326
|
require 'ntlm'
|
326
327
|
|
327
328
|
user, psw = [auth[:username] || auth[:dn], auth[:password]]
|
328
|
-
raise Net::LDAP::
|
329
|
+
raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless (user && psw)
|
329
330
|
|
330
331
|
nego = proc { |challenge|
|
331
332
|
t2_msg = NTLM::Message.parse(challenge)
|
@@ -411,10 +412,10 @@ class Net::LDAP::Connection #:nodoc:
|
|
411
412
|
sort = args.fetch(:sort_controls, false)
|
412
413
|
|
413
414
|
# arg validation
|
414
|
-
raise
|
415
|
-
raise
|
416
|
-
raise
|
417
|
-
raise
|
415
|
+
raise ArgumentError, "search base is required" unless base
|
416
|
+
raise ArgumentError, "invalid search-size" unless size >= 0
|
417
|
+
raise ArgumentError, "invalid search scope" unless Net::LDAP::SearchScopes.include?(scope)
|
418
|
+
raise ArgumentError, "invalid alias dereferencing value" unless Net::LDAP::DerefAliasesArray.include?(deref)
|
418
419
|
|
419
420
|
# arg transforms
|
420
421
|
filter = Net::LDAP::Filter.construct(filter) if filter.is_a?(String)
|
@@ -526,7 +527,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
526
527
|
end
|
527
528
|
break
|
528
529
|
else
|
529
|
-
raise Net::LDAP::
|
530
|
+
raise Net::LDAP::ResponseTypeInvalidError, "invalid response-type in search: #{pdu.app_tag}"
|
530
531
|
end
|
531
532
|
end
|
532
533
|
|
@@ -570,12 +571,13 @@ class Net::LDAP::Connection #:nodoc:
|
|
570
571
|
result_pdu || OpenStruct.new(:status => :failure, :result_code => Net::LDAP::ResultCodeOperationsError, :message => "Invalid search")
|
571
572
|
end # instrument
|
572
573
|
ensure
|
574
|
+
|
573
575
|
# clean up message queue for this search
|
574
576
|
messages = message_queue.delete(message_id)
|
575
577
|
|
576
578
|
# in the exceptional case some messages were *not* consumed from the queue,
|
577
579
|
# instrument the event but do not fail.
|
578
|
-
|
580
|
+
if !messages.nil? && !messages.empty?
|
579
581
|
instrument "search_messages_unread.net_ldap_connection",
|
580
582
|
message_id: message_id, messages: messages
|
581
583
|
end
|
@@ -623,7 +625,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
623
625
|
pdu = queued_read(message_id)
|
624
626
|
|
625
627
|
if !pdu || pdu.app_tag != Net::LDAP::PDU::ModifyResponse
|
626
|
-
raise Net::LDAP::
|
628
|
+
raise Net::LDAP::ResponseMissingOrInvalidError, "response missing or invalid"
|
627
629
|
end
|
628
630
|
|
629
631
|
pdu
|
@@ -637,7 +639,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
637
639
|
# to the error message and the matched-DN returned by the server.
|
638
640
|
#++
|
639
641
|
def add(args)
|
640
|
-
add_dn = args[:dn] or raise Net::LDAP::
|
642
|
+
add_dn = args[:dn] or raise Net::LDAP::EmptyDNError, "Unable to add empty DN"
|
641
643
|
add_attrs = []
|
642
644
|
a = args[:attributes] and a.each { |k, v|
|
643
645
|
add_attrs << [ k.to_s.to_ber, Array(v).map { |m| m.to_ber}.to_ber_set ].to_ber_sequence
|
@@ -650,7 +652,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
650
652
|
pdu = queued_read(message_id)
|
651
653
|
|
652
654
|
if !pdu || pdu.app_tag != Net::LDAP::PDU::AddResponse
|
653
|
-
raise Net::LDAP::
|
655
|
+
raise Net::LDAP::ResponseMissingError, "response missing or invalid"
|
654
656
|
end
|
655
657
|
|
656
658
|
pdu
|
@@ -673,7 +675,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
673
675
|
pdu = queued_read(message_id)
|
674
676
|
|
675
677
|
if !pdu || pdu.app_tag != Net::LDAP::PDU::ModifyRDNResponse
|
676
|
-
raise Net::LDAP::
|
678
|
+
raise Net::LDAP::ResponseMissingOrInvalidError.new "response missing or invalid"
|
677
679
|
end
|
678
680
|
|
679
681
|
pdu
|
@@ -692,7 +694,7 @@ class Net::LDAP::Connection #:nodoc:
|
|
692
694
|
pdu = queued_read(message_id)
|
693
695
|
|
694
696
|
if !pdu || pdu.app_tag != Net::LDAP::PDU::DeleteResponse
|
695
|
-
raise Net::LDAP::
|
697
|
+
raise Net::LDAP::ResponseMissingOrInvalidError, "response missing or invalid"
|
696
698
|
end
|
697
699
|
|
698
700
|
pdu
|
data/lib/net/ldap/entry.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Net::LDAP
|
2
|
+
class LdapError < StandardError
|
3
|
+
def message
|
4
|
+
"Deprecation warning: Net::LDAP::LdapError is no longer used. Use Net::LDAP::Error or rescue one of it's subclasses. \n" + super
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
class AlreadyOpenedError < Error; end
|
11
|
+
class SocketError < Error; end
|
12
|
+
class ConnectionRefusedError < Error; end
|
13
|
+
class NoOpenSSLError < Error; end
|
14
|
+
class NoStartTLSResultError < Error; end
|
15
|
+
class NoSearchBaseError < Error; end
|
16
|
+
class StartTLSError < Error; end
|
17
|
+
class EncryptionUnsupportedError < Error; end
|
18
|
+
class EncMethodUnsupportedError < Error; end
|
19
|
+
class AuthMethodUnsupportedError < Error; end
|
20
|
+
class BindingInformationInvalidError < Error; end
|
21
|
+
class NoBindResultError < Error; end
|
22
|
+
class SASLChallengeOverflowError < Error; end
|
23
|
+
class SearchSizeInvalidError < Error; end
|
24
|
+
class SearchScopeInvalidError < Error; end
|
25
|
+
class ResponseTypeInvalidError < Error; end
|
26
|
+
class ResponseMissingOrInvalidError < Error; end
|
27
|
+
class EmptyDNError < Error; end
|
28
|
+
class HashTypeUnsupportedError < Error; end
|
29
|
+
class OperatorError < Error; end
|
30
|
+
class SubstringFilterError < Error; end
|
31
|
+
class SearchFilterError < Error; end
|
32
|
+
class BERInvalidError < Error; end
|
33
|
+
class SearchFilterTypeUnknownError < Error; end
|
34
|
+
class BadAttributeError < Error; end
|
35
|
+
class FilterTypeUnknownError < Error; end
|
36
|
+
class FilterSyntaxInvalidError < Error; end
|
37
|
+
class EntryOverflowError < Error; end
|
38
|
+
end
|
data/lib/net/ldap/filter.rb
CHANGED
@@ -27,7 +27,7 @@ class Net::LDAP::Filter
|
|
27
27
|
|
28
28
|
def initialize(op, left, right) #:nodoc:
|
29
29
|
unless FilterTypes.include?(op)
|
30
|
-
raise Net::LDAP::
|
30
|
+
raise Net::LDAP::OperatorError, "Invalid or unsupported operator #{op.inspect} in LDAP Filter."
|
31
31
|
end
|
32
32
|
@op = op
|
33
33
|
@left = left
|
@@ -290,7 +290,7 @@ class Net::LDAP::Filter
|
|
290
290
|
ber.last.each { |b|
|
291
291
|
case b.ber_identifier
|
292
292
|
when 0x80 # context-specific primitive 0, SubstringFilter "initial"
|
293
|
-
raise Net::LDAP::
|
293
|
+
raise Net::LDAP::SubstringFilterError, "Unrecognized substring filter; bad initial value." if str.length > 0
|
294
294
|
str += escape(b)
|
295
295
|
when 0x81 # context-specific primitive 0, SubstringFilter "any"
|
296
296
|
str += "*#{escape(b)}"
|
@@ -309,7 +309,7 @@ class Net::LDAP::Filter
|
|
309
309
|
# call to_s to get rid of the BER-identifiedness of the incoming string.
|
310
310
|
present?(ber.to_s)
|
311
311
|
when 0xa9 # context-specific constructed 9, "extensible comparison"
|
312
|
-
raise Net::LDAP::
|
312
|
+
raise Net::LDAP::SearchFilterError, "Invalid extensible search filter, should be at least two elements" if ber.size < 2
|
313
313
|
|
314
314
|
# Reassembles the extensible filter parts
|
315
315
|
# (["sn", "2.4.6.8.10", "Barbara Jones", '1'])
|
@@ -330,7 +330,7 @@ class Net::LDAP::Filter
|
|
330
330
|
|
331
331
|
ex(attribute, value)
|
332
332
|
else
|
333
|
-
raise Net::LDAP::
|
333
|
+
raise Net::LDAP::BERInvalidError, "Invalid BER tag-value (#{ber.ber_identifier}) in search filter."
|
334
334
|
end
|
335
335
|
end
|
336
336
|
|
@@ -357,7 +357,7 @@ class Net::LDAP::Filter
|
|
357
357
|
when 0xa3 # equalityMatch. context-specific constructed 3.
|
358
358
|
eq(obj[0], obj[1])
|
359
359
|
else
|
360
|
-
raise Net::LDAP::
|
360
|
+
raise Net::LDAP::SearchFilterTypeUnknownError, "Unknown LDAP search-filter type: #{obj.ber_identifier}"
|
361
361
|
end
|
362
362
|
end
|
363
363
|
end
|
@@ -532,7 +532,7 @@ class Net::LDAP::Filter
|
|
532
532
|
seq = []
|
533
533
|
|
534
534
|
unless @left =~ /^([-;\w]*)(:dn)?(:(\w+|[.\w]+))?$/
|
535
|
-
raise Net::LDAP::
|
535
|
+
raise Net::LDAP::BadAttributeError, "Bad attribute #{@left}"
|
536
536
|
end
|
537
537
|
type, dn, rule = $1, $2, $4
|
538
538
|
|
@@ -639,15 +639,14 @@ class Net::LDAP::Filter
|
|
639
639
|
l = entry[@left] and l = Array(l) and l.index(@right)
|
640
640
|
end
|
641
641
|
else
|
642
|
-
raise Net::LDAP::
|
642
|
+
raise Net::LDAP::FilterTypeUnknownError, "Unknown filter type in match: #{@op}"
|
643
643
|
end
|
644
644
|
end
|
645
645
|
|
646
646
|
##
|
647
647
|
# Converts escaped characters (e.g., "\\28") to unescaped characters
|
648
|
-
# ("(").
|
649
648
|
def unescape(right)
|
650
|
-
right.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") }
|
649
|
+
right.to_s.gsub(/\\([a-fA-F\d]{2})/) { [$1.hex].pack("U") }
|
651
650
|
end
|
652
651
|
private :unescape
|
653
652
|
|
@@ -672,7 +671,7 @@ class Net::LDAP::Filter
|
|
672
671
|
def initialize(str)
|
673
672
|
require 'strscan' # Don't load strscan until we need it.
|
674
673
|
@filter = parse(StringScanner.new(str))
|
675
|
-
raise Net::LDAP::
|
674
|
+
raise Net::LDAP::FilterSyntaxInvalidError, "Invalid filter syntax." unless @filter
|
676
675
|
end
|
677
676
|
|
678
677
|
##
|
data/lib/net/ldap/password.rb
CHANGED
@@ -23,14 +23,14 @@ class Net::LDAP::Password
|
|
23
23
|
def generate(type, str)
|
24
24
|
case type
|
25
25
|
when :md5
|
26
|
-
|
26
|
+
attribute_value = '{MD5}' + Base64.encode64(Digest::MD5.digest(str)).chomp!
|
27
27
|
when :sha
|
28
|
-
|
28
|
+
attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp!
|
29
29
|
when :ssha
|
30
|
-
|
31
|
-
|
30
|
+
salt = SecureRandom.random_bytes(16)
|
31
|
+
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp!
|
32
32
|
else
|
33
|
-
|
33
|
+
raise Net::LDAP::HashTypeUnsupportedError, "Unsupported password-hash type (#{type})"
|
34
34
|
end
|
35
35
|
return attribute_value
|
36
36
|
end
|
data/lib/net/ldap/version.rb
CHANGED
data/net-ldap.gemspec
CHANGED
data/test/test_filter.rb
CHANGED
@@ -9,11 +9,11 @@ class TestFilter < Test::Unit::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_invalid_filter_string
|
12
|
-
assert_raises(Net::LDAP::
|
12
|
+
assert_raises(Net::LDAP::FilterSyntaxInvalidError) { Filter.from_rfc2254("") }
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_invalid_filter
|
16
|
-
assert_raises(Net::LDAP::
|
16
|
+
assert_raises(Net::LDAP::OperatorError) {
|
17
17
|
# This test exists to prove that our constructor blocks unknown filter
|
18
18
|
# types. All filters must be constructed using helpers.
|
19
19
|
Filter.__send__(:new, :xx, nil, nil)
|
@@ -215,4 +215,9 @@ class TestFilterRSpec < Test::Unit::TestCase
|
|
215
215
|
filter = Net::LDAP::Filter.parse_ber(ber.read_ber(Net::LDAP::AsnSyntax))
|
216
216
|
assert_equal "(objectclass=#{escaped}*#{escaped}*#{escaped})", filter.to_s
|
217
217
|
end
|
218
|
+
|
219
|
+
def test_unescape_fixnums
|
220
|
+
filter = Net::LDAP::Filter.eq("objectclass", 3)
|
221
|
+
assert_equal "\xA3\x10\x04\vobjectclass\x04\x013".b, filter.to_ber
|
222
|
+
end
|
218
223
|
end
|
@@ -2,14 +2,14 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
class TestLDAPConnection < Test::Unit::TestCase
|
4
4
|
def test_unresponsive_host
|
5
|
-
assert_raise Net::LDAP::
|
5
|
+
assert_raise Net::LDAP::Error do
|
6
6
|
Net::LDAP::Connection.new(:host => 'test.mocked.com', :port => 636)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_blocked_port
|
11
11
|
flexmock(TCPSocket).should_receive(:new).and_raise(SocketError)
|
12
|
-
assert_raise Net::LDAP::
|
12
|
+
assert_raise Net::LDAP::Error do
|
13
13
|
Net::LDAP::Connection.new(:host => 'test.mocked.com', :port => 636)
|
14
14
|
end
|
15
15
|
end
|
@@ -202,7 +202,7 @@ class TestLDAPConnectionSocketReads < Test::Unit::TestCase
|
|
202
202
|
and_return(result2)
|
203
203
|
mock.should_receive(:write)
|
204
204
|
conn = Net::LDAP::Connection.new(:socket => mock)
|
205
|
-
flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock,
|
205
|
+
flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}).
|
206
206
|
and_return(mock)
|
207
207
|
|
208
208
|
conn.next_msgid # simulates ongoing query
|
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.11'
|
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:
|
16
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: flexmock
|
@@ -43,6 +43,20 @@ dependencies:
|
|
43
43
|
- - "~>"
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '10.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rubocop
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.28.0
|
53
|
+
type: :development
|
54
|
+
prerelease: false
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.28.0
|
46
60
|
description: |-
|
47
61
|
Net::LDAP for Ruby (also called net-ldap) implements client access for the
|
48
62
|
Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for
|
@@ -71,6 +85,8 @@ extra_rdoc_files:
|
|
71
85
|
- README.rdoc
|
72
86
|
files:
|
73
87
|
- ".gitignore"
|
88
|
+
- ".rubocop.yml"
|
89
|
+
- ".rubocop_todo.yml"
|
74
90
|
- ".travis.yml"
|
75
91
|
- CONTRIBUTING.md
|
76
92
|
- Contributors.rdoc
|
@@ -94,6 +110,7 @@ files:
|
|
94
110
|
- lib/net/ldap/dataset.rb
|
95
111
|
- lib/net/ldap/dn.rb
|
96
112
|
- lib/net/ldap/entry.rb
|
113
|
+
- lib/net/ldap/error.rb
|
97
114
|
- lib/net/ldap/filter.rb
|
98
115
|
- lib/net/ldap/instrumentation.rb
|
99
116
|
- lib/net/ldap/password.rb
|