From af098c54ae177bbb1de1c75dc2a376680cb5adee Mon Sep 17 00:00:00 2001 From: Julian Paul Dasmarinas Date: Tue, 7 Jun 2022 09:07:56 +0800 Subject: [PATCH 01/28] Add support to use SNI --- lib/net/ldap/connection.rb | 12 +++++++----- test/test_ldap_connection.rb | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index 71e2edda..be0db04b 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -33,9 +33,10 @@ def socket_class=(socket_class) def prepare_socket(server, timeout=nil) socket = server[:socket] encryption = server[:encryption] + hostname = server[:host] @conn = socket - setup_encryption(encryption, timeout) if encryption + setup_encryption(encryption, timeout, hostname) if encryption end def open_connection(server) @@ -86,7 +87,7 @@ def close end end - def self.wrap_with_ssl(io, tls_options = {}, timeout=nil) + def self.wrap_with_ssl(io, tls_options = {}, timeout=nil, hostname=nil) raise Net::LDAP::NoOpenSSLError, "OpenSSL is unavailable" unless Net::LDAP::HasOpenSSL ctx = OpenSSL::SSL::SSLContext.new @@ -96,6 +97,7 @@ def self.wrap_with_ssl(io, tls_options = {}, timeout=nil) ctx.set_params(tls_options) unless tls_options.empty? conn = OpenSSL::SSL::SSLSocket.new(io, ctx) + conn.hostname = hostname begin if timeout @@ -148,11 +150,11 @@ def self.wrap_with_ssl(io, tls_options = {}, timeout=nil) # communications, as with simple_tls. Thanks for Kouhei Sutou for # generously contributing the :start_tls path. #++ - def setup_encryption(args, timeout=nil) + def setup_encryption(args, timeout=nil, hostname=nil) args[:tls_options] ||= {} case args[:method] when :simple_tls - @conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout) + @conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout, hostname) # additional branches requiring server validation and peer certs, etc. # go here. when :start_tls @@ -170,7 +172,7 @@ def setup_encryption(args, timeout=nil) raise Net::LDAP::StartTLSError, "start_tls failed: #{pdu.result_code}" unless pdu.result_code.zero? - @conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout) + @conn = self.class.wrap_with_ssl(@conn, args[:tls_options], timeout, hostname) else raise Net::LDAP::EncMethodUnsupportedError, "unsupported encryption method #{args[:method]}" end diff --git a/test/test_ldap_connection.rb b/test/test_ldap_connection.rb index 4c9dffa5..dcb4ce72 100644 --- a/test/test_ldap_connection.rb +++ b/test/test_ldap_connection.rb @@ -288,7 +288,7 @@ def test_queued_read_setup_encryption_with_start_tls .and_return(result2) mock.should_receive(:write) conn = Net::LDAP::Connection.new(:socket => mock) - flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}, nil) + flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}, nil, nil) .and_return(mock) conn.next_msgid # simulates ongoing query From c5a115e8433b19b27a96da8601d95165d5be0c58 Mon Sep 17 00:00:00 2001 From: Brian Graves Date: Fri, 16 Sep 2022 02:09:27 -0700 Subject: [PATCH 02/28] Fix escaping of # and space in attrs --- lib/net/ldap/dn.rb | 16 ++++------------ test/test_dn.rb | 8 ++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/net/ldap/dn.rb b/lib/net/ldap/dn.rb index da0ff7ca..866efde7 100644 --- a/lib/net/ldap/dn.rb +++ b/lib/net/ldap/dn.rb @@ -192,27 +192,19 @@ def to_s # http://tools.ietf.org/html/rfc2253 section 2.4 lists these exceptions # for dn values. All of the following must be escaped in any normal string # using a single backslash ('\') as escape. - ESCAPES = { - ',' => ',', - '+' => '+', - '"' => '"', - '\\' => '\\', - '<' => '<', - '>' => '>', - ';' => ';', - } + ESCAPES = %w[, + " \\ < > ;] - # Compiled character class regexp using the keys from the above hash, and + # Compiled character class regexp using the values from the above list, and # checking for a space or # at the start, or space at the end, of the # string. ESCAPE_RE = Regexp.new("(^ |^#| $|[" + - ESCAPES.keys.map { |e| Regexp.escape(e) }.join + + ESCAPES.map { |e| Regexp.escape(e) }.join + "])") ## # Escape a string for use in a DN value def self.escape(string) - string.gsub(ESCAPE_RE) { |char| "\\" + ESCAPES[char] } + string.gsub(ESCAPE_RE) { |char| "\\" + char } end ## diff --git a/test/test_dn.rb b/test/test_dn.rb index ac5949a8..fa2266f7 100644 --- a/test/test_dn.rb +++ b/test/test_dn.rb @@ -6,6 +6,14 @@ def test_escape assert_equal '\\,\\+\\"\\\\\\<\\>\\;', Net::LDAP::DN.escape(',+"\\<>;') end + def test_escape_pound_sign + assert_equal '\\#test', Net::LDAP::DN.escape('#test') + end + + def test_escape_space + assert_equal '\\ before_after\\ ', Net::LDAP::DN.escape(' before_after ') + end + def test_escape_on_initialize dn = Net::LDAP::DN.new('cn', ',+"\\<>;', 'ou=company') assert_equal 'cn=\\,\\+\\"\\\\\\<\\>\\;,ou=company', dn.to_s From 9c8525c1b852ffc0bd62295195bb711022527d50 Mon Sep 17 00:00:00 2001 From: gwillcox-r7 Date: Tue, 6 Dec 2022 23:03:47 -0600 Subject: [PATCH 03/28] Add in ability for users to specify LDAP controls when conducting searches --- lib/net/ldap/connection.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index be0db04b..48dd7af3 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -425,6 +425,7 @@ def search(args = nil) # this breaks when calling to_ber. (Can't force binary data to UTF-8) # we have to disable paging (even though server supports it) to get around this... + controls_temp = args.fetch(:controls, []) controls = [] controls << [ @@ -434,7 +435,12 @@ def search(args = nil) rfc2696_cookie.map(&:to_ber).to_ber_sequence.to_s.to_ber, ].to_ber_sequence if paged controls << ber_sort if ber_sort - controls = controls.empty? ? nil : controls.to_ber_contextspecific(0) + if controls.empty? + controls = nil + else + controls += controls_temp unless controls_temp.blank? + controls = controls.to_ber_contextspecific(0) + end write(request, controls, message_id) From e896715eee5e2f85be6e7211e6813044ba457d9d Mon Sep 17 00:00:00 2001 From: Grant Willcox Date: Wed, 7 Dec 2022 08:58:53 -0600 Subject: [PATCH 04/28] Fix using blank? since that might not exist, and also allow for adding user controls even if the paged and ber_sort flags weren't set --- lib/net/ldap/connection.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index 48dd7af3..83887e5e 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -425,7 +425,7 @@ def search(args = nil) # this breaks when calling to_ber. (Can't force binary data to UTF-8) # we have to disable paging (even though server supports it) to get around this... - controls_temp = args.fetch(:controls, []) + user_controls = args.fetch(:controls, []) controls = [] controls << [ @@ -435,10 +435,10 @@ def search(args = nil) rfc2696_cookie.map(&:to_ber).to_ber_sequence.to_s.to_ber, ].to_ber_sequence if paged controls << ber_sort if ber_sort - if controls.empty? + if controls.empty? && user_controls.empty? controls = nil else - controls += controls_temp unless controls_temp.blank? + controls += user_controls controls = controls.to_ber_contextspecific(0) end From 005573458081886edb8384ad43a2ae23715a1b42 Mon Sep 17 00:00:00 2001 From: Tom Sellers Date: Thu, 16 Feb 2023 12:22:59 -0600 Subject: [PATCH 05/28] Retain spaces in RDN values in DNs --- lib/net/ldap/dn.rb | 10 +++++----- test/test_dn.rb | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/net/ldap/dn.rb b/lib/net/ldap/dn.rb index 866efde7..9098cdb9 100644 --- a/lib/net/ldap/dn.rb +++ b/lib/net/ldap/dn.rb @@ -81,7 +81,7 @@ def each_pair value << char when ',' then state = :key - yield key.string.strip, value.string.rstrip + yield key.string.strip, value.string key = StringIO.new value = StringIO.new; else @@ -93,7 +93,7 @@ def each_pair when '\\' then state = :value_normal_escape when ',' then state = :key - yield key.string.strip, value.string.rstrip + yield key.string.strip, value.string key = StringIO.new value = StringIO.new; else value << char @@ -142,7 +142,7 @@ def each_pair when ' ' then state = :value_end when ',' then state = :key - yield key.string.strip, value.string.rstrip + yield key.string.strip, value.string key = StringIO.new value = StringIO.new; else raise Net::LDAP::InvalidDNError, "DN badly formed" @@ -159,7 +159,7 @@ def each_pair when ' ' then state = :value_end when ',' then state = :key - yield key.string.strip, value.string.rstrip + yield key.string.strip, value.string key = StringIO.new value = StringIO.new; else raise Net::LDAP::InvalidDNError, "DN badly formed" @@ -172,7 +172,7 @@ def each_pair raise Net::LDAP::InvalidDNError, "DN badly formed" unless [:value, :value_normal, :value_hexstring, :value_end].include? state - yield key.string.strip, value.string.rstrip + yield key.string.strip, value.string end ## diff --git a/test/test_dn.rb b/test/test_dn.rb index fa2266f7..52e87bd7 100644 --- a/test/test_dn.rb +++ b/test/test_dn.rb @@ -14,6 +14,12 @@ def test_escape_space assert_equal '\\ before_after\\ ', Net::LDAP::DN.escape(' before_after ') end + def test_retain_spaces + dn = Net::LDAP::DN.new('CN=Foo.bar.baz, OU=Foo \ ,OU=\ Bar, O=Baz') + assert_equal "CN=Foo.bar.baz, OU=Foo \\ ,OU=\\ Bar, O=Baz", dn.to_s + assert_equal ["CN", "Foo.bar.baz", "OU", "Foo ", "OU", " Bar", "O", "Baz"], dn.to_a + end + def test_escape_on_initialize dn = Net::LDAP::DN.new('cn', ',+"\\<>;', 'ou=company') assert_equal 'cn=\\,\\+\\"\\\\\\<\\>\\;,ou=company', dn.to_s @@ -26,7 +32,7 @@ def test_to_a def test_to_a_parenthesis dn = Net::LDAP::DN.new('cn = \ James , ou = "Comp\28ny" ') - assert_equal ['cn', ' James', 'ou', 'Comp(ny'], dn.to_a + assert_equal ['cn', ' James ', 'ou', 'Comp(ny'], dn.to_a end def test_to_a_hash_symbol From 89647a255b43db17d2499fe1ab779b4b38b66bd6 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Wed, 29 Mar 2023 09:38:57 -0400 Subject: [PATCH 06/28] Prepare release v0.18.0 --- History.rdoc | 4 ++++ lib/net/ldap/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.rdoc b/History.rdoc index 5874a581..14d14ebe 100644 --- a/History.rdoc +++ b/History.rdoc @@ -1,3 +1,7 @@ +=== Net::LDAP 0.18.0 +* Fix escaping of # and space in attrs #408 +* Add support to use SNI #406 + === Net::LDAP 0.17.1 * Fixed shebang of bash #385 * Omit some tests for now until we update our CA cert #386 diff --git a/lib/net/ldap/version.rb b/lib/net/ldap/version.rb index f531db1c..6ca72fca 100644 --- a/lib/net/ldap/version.rb +++ b/lib/net/ldap/version.rb @@ -1,5 +1,5 @@ module Net class LDAP - VERSION = "0.17.1" + VERSION = "0.18.0" end end From 3fe006c9a252728f1f84a3fedaadda08778dc660 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Wed, 29 Mar 2023 09:43:11 -0400 Subject: [PATCH 07/28] Drop Ruby 2.5 and JRuby 9.2 from CI tests --- .github/workflows/test.yml | 4 ++-- History.rdoc | 1 + docker-compose.yml | 48 ++++++++++++++++++++++++++++++-------- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15ea9c83..942822cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,11 +19,11 @@ jobs: strategy: matrix: ruby: - - "2.5" - "2.6" - "2.7" - "3.0" - - "jruby-9.2" + - "jruby-9.3" + - "jruby-9.4" - "truffleruby-21.0.0" steps: - uses: actions/checkout@v2 diff --git a/History.rdoc b/History.rdoc index 14d14ebe..36d55f2c 100644 --- a/History.rdoc +++ b/History.rdoc @@ -1,6 +1,7 @@ === Net::LDAP 0.18.0 * Fix escaping of # and space in attrs #408 * Add support to use SNI #406 +* Drop Ruby 2.5 and JRuby 9.2 from CI tests === Net::LDAP 0.17.1 * Fixed shebang of bash #385 diff --git a/docker-compose.yml b/docker-compose.yml index 88a1cfd9..60f36a8a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,8 +24,8 @@ services: volumes: - ./test/fixtures/ldif:/ldif:ro - ci-2.5: - image: ruby:2.5 + ci-2.6: + image: ruby:2.7 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap @@ -38,7 +38,7 @@ services: - .:/code working_dir: /code - ci-2.6: + ci-2.7: image: ruby:2.7 entrypoint: /code/ci-run.sh environment: @@ -52,8 +52,8 @@ services: - .:/code working_dir: /code - ci-2.7: - image: ruby:2.7 + ci-3.0: + image: ruby:3.0 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap @@ -66,8 +66,8 @@ services: - .:/code working_dir: /code - ci-3.0: - image: ruby:3.0 + ci-3.1: + image: ruby:3.1 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap @@ -79,7 +79,21 @@ services: volumes: - .:/code working_dir: /code - + + ci-3.2: + image: ruby:3.2 + entrypoint: /code/ci-run.sh + environment: + INTEGRATION: openldap + INTEGRATION_HOST: ldap.example.org + depends_on: + - openldap + networks: + integration_test_network: + volumes: + - .:/code + working_dir: /code + ci-truffleruby-21.0.0: image: flavorjones/truffleruby:21.0.0 entrypoint: /code/ci-run.sh @@ -94,8 +108,22 @@ services: - .:/code working_dir: /code - ci-jruby-9.2: - image: jruby:9.2 + ci-jruby-9.3: + image: jruby:9.3 + entrypoint: /code/ci-run.sh + environment: + INTEGRATION: openldap + INTEGRATION_HOST: ldap.example.org + depends_on: + - openldap + networks: + integration_test_network: + volumes: + - .:/code + working_dir: /code + + ci-jruby-9.4: + image: jruby:9.4 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap From cd448565bf8a0fd1b06b5525028eb1489dff2e84 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Wed, 29 Mar 2023 13:15:18 -0400 Subject: [PATCH 08/28] Bump rubocop to 1.48.1 --- .rubocop.yml | 2 +- .rubocop_todo.yml | 638 +++++++++++++++++++++++++++++++--------------- History.rdoc | 1 + net-ldap.gemspec | 2 +- 4 files changed, 442 insertions(+), 201 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9049058b..b2f78bb0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -13,7 +13,7 @@ Lint/AssignmentInCondition: Style/ParallelAssignment: Enabled: false -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: comma Style/TrailingCommaInArguments: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7699e8a6..c1d8b87a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,104 +1,176 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-07-12 00:41:11 -0400 using RuboCop version 0.49.1. +# on 2023-03-29 17:13:45 UTC using RuboCop version 1.48.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 4 -# Cop supports --auto-correct. -Layout/AlignArray: +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'net-ldap.gemspec' + +# Offense count: 1 +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'net-ldap.gemspec' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_element, with_fixed_indentation +Layout/ArrayAlignment: Exclude: - 'lib/net/ldap.rb' - - 'lib/net/ldap/auth_adapter/sasl.rb' - 'lib/net/ldap/connection.rb' # Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. # SupportedStyles: case, end Layout/CaseIndentation: Exclude: - 'lib/net/ldap/filter.rb' +# Offense count: 24 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/net/ber.rb' + - 'lib/net/ber/core_ext/array.rb' + - 'lib/net/ldap.rb' + - 'lib/net/ldap/auth_adapter.rb' + - 'lib/net/ldap/connection.rb' + - 'lib/net/ldap/dataset.rb' + - 'lib/net/ldap/entry.rb' + - 'lib/net/ldap/filter.rb' + - 'lib/net/snmp.rb' + - 'test/integration/test_ber.rb' + # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Layout/EmptyLineAfterMagicComment: Exclude: - 'net-ldap.gemspec' -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: Exclude: - - 'lib/net/ldap.rb' - 'lib/net/ldap/dataset.rb' + - 'lib/net/ldap/error.rb' - 'lib/net/snmp.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: Exclude: - 'lib/net/snmp.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'lib/net/ber.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only Layout/EmptyLinesAroundClassBody: Exclude: - 'lib/net/ldap.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Layout/EmptyLinesAroundExceptionHandlingKeywords: Exclude: - 'lib/net/ldap/connection.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleAlignWith, Severity. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Layout/EndAlignment: + Exclude: + - 'testserver/ldapserver.rb' + # Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: +Layout/FirstArrayElementIndentation: EnforcedStyle: consistent # Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentHash: +Layout/FirstHashElementIndentation: EnforcedStyle: consistent +# Offense count: 124 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'lib/net/ber.rb' + - 'lib/net/ldap.rb' + - 'lib/net/ldap/auth_adapter/gss_spnego.rb' + - 'lib/net/ldap/connection.rb' + - 'lib/net/ldap/filter.rb' + - 'test/ber/test_ber.rb' + - 'test/integration/test_add.rb' + - 'test/integration/test_bind.rb' + - 'test/integration/test_delete.rb' + - 'test/integration/test_open.rb' + - 'test/test_helper.rb' + - 'test/test_ldap_connection.rb' + # Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: Width, IgnoredPatterns. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, AllowedPatterns. Layout/IndentationWidth: Exclude: - 'lib/net/ber.rb' - 'lib/net/ldap/password.rb' - 'lib/net/snmp.rb' -# Offense count: 3 -# Cop supports --auto-correct. +# Offense count: 15 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. Layout/LeadingCommentSpace: Exclude: - 'lib/net/ber/core_ext/array.rb' - 'lib/net/ldap.rb' - 'lib/net/ldap/connection.rb' + - 'lib/net/ldap/entry.rb' + - 'lib/net/ldap/filter.rb' + - 'lib/net/ldap/pdu.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line Layout/MultilineMethodCallBraceLayout: Exclude: - 'lib/net/ldap/filter.rb' -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space Layout/SpaceAroundEqualsInParameterDefault: Exclude: @@ -106,15 +178,16 @@ Layout/SpaceAroundEqualsInParameterDefault: - 'lib/net/snmp.rb' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Layout/SpaceAroundKeyword: Exclude: - 'lib/net/ldap/entry.rb' - 'lib/net/snmp.rb' # Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# SupportedStylesForExponentOperator: space, no_space Layout/SpaceAroundOperators: Exclude: - 'lib/net/ber/ber_parser.rb' @@ -123,8 +196,8 @@ Layout/SpaceAroundOperators: - 'lib/net/ldap/filter.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideBlockBraces: @@ -132,30 +205,27 @@ Layout/SpaceInsideBlockBraces: - 'lib/net/ldap/dataset.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, compact, no_space Layout/SpaceInsideParens: Exclude: - 'lib/net/ldap/entry.rb' - 'lib/net/snmp.rb' # Offense count: 1 -Lint/AmbiguousBlockAssociation: +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowComments. +Lint/EmptyConditionalBody: Exclude: - - 'testserver/ldapserver.rb' + - 'lib/net/ldap/filter.rb' # Offense count: 1 +# Configuration parameters: AllowComments. Lint/EmptyWhen: Exclude: - 'lib/net/ldap/pdu.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Lint/EndAlignment: - Exclude: - - 'testserver/ldapserver.rb' - # Offense count: 30 Lint/ImplicitStringConcatenation: Exclude: @@ -172,7 +242,7 @@ Lint/RescueException: - 'lib/net/ldap/pdu.rb' # Offense count: 9 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: @@ -180,8 +250,8 @@ Lint/UnusedBlockArgument: - 'lib/net/snmp.rb' # Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Exclude: - 'lib/net/ldap/entry.rb' @@ -191,25 +261,27 @@ Lint/UnusedMethodArgument: - 'test/test_search.rb' # Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: Exclude: - 'lib/net/ldap/connection.rb' -# Offense count: 6 +# Offense count: 5 Lint/UselessAssignment: Exclude: - 'test/integration/test_add.rb' - 'test/test_ldap_connection.rb' - 'test/test_search.rb' - - 'test/test_snmp.rb' -# Offense count: 48 +# Offense count: 38 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Max: 116 + Max: 120 -# Offense count: 4 -# Configuration parameters: CountComments, ExcludedMethods. +# Offense count: 3 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +# AllowedMethods: refine Metrics/BlockLength: Max: 119 @@ -219,42 +291,98 @@ Metrics/BlockNesting: Max: 4 # Offense count: 11 -# Configuration parameters: CountComments. +# Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 445 + Max: 443 -# Offense count: 23 +# Offense count: 20 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: - Max: 41 - -# Offense count: 216 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 360 + Max: 44 # Offense count: 74 -# Configuration parameters: CountComments. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 128 # Offense count: 1 -# Configuration parameters: CountComments. +# Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: Max: 103 -# Offense count: 15 +# Offense count: 12 +# Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: - Max: 38 + Max: 44 # Offense count: 1 -Style/AccessorMethodName: +Naming/AccessorMethodName: Exclude: - 'lib/net/ldap.rb' +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Naming/BinaryOperatorParameterName: + Exclude: + - 'lib/net/ldap/filter.rb' + +# Offense count: 1 +# Configuration parameters: AllowedNames. +# AllowedNames: module_parent +Naming/ClassAndModuleCamelCase: + Exclude: + - 'lib/net/ldap/auth_adapter/gss_spnego.rb' + +# Offense count: 87 +Naming/ConstantName: + Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/connection.rb' + - 'lib/net/ldap/filter.rb' + - 'lib/net/ldap/pdu.rb' + - 'lib/net/snmp.rb' + - 'test/test_ldif.rb' + - 'testserver/ldapserver.rb' + +# Offense count: 1 +# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# CheckDefinitionPathHierarchyRoots: lib, spec, test, src +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS +Naming/FileName: + Exclude: + - 'lib/net-ldap.rb' + +# Offense count: 11 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/entry.rb' + - 'lib/net/ldap/filter.rb' + - 'lib/net/snmp.rb' + - 'test/test_snmp.rb' + - 'testserver/ldapserver.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'lib/net/ldap/pdu.rb' + +# Offense count: 9 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: separated, grouped +Style/AccessorGrouping: + Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/pdu.rb' + # Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: prefer_alias, prefer_alias_method Style/Alias: Exclude: @@ -264,13 +392,12 @@ Style/Alias: - 'lib/net/ldap/filter.rb' - 'lib/net/ldap/pdu.rb' -# Offense count: 33 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Offense count: 12 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. # SupportedStyles: always, conditionals Style/AndOr: Exclude: - - 'lib/net/ber/ber_parser.rb' - 'lib/net/ldap.rb' - 'lib/net/ldap/connection.rb' - 'lib/net/ldap/dataset.rb' @@ -278,88 +405,80 @@ Style/AndOr: - 'lib/net/ldap/pdu.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: percent_q, bare_percent Style/BarePercentLiterals: Exclude: - 'test/test_entry.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/BlockComments: Exclude: - 'test/test_rename.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: MinBranchesCount. +Style/CaseLikeIf: Exclude: - - 'lib/net/ldap/auth_adapter/gss_spnego.rb' - - 'lib/net/snmp.rb' + - 'lib/net/ber/ber_parser.rb' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/CharacterLiteral: Exclude: - 'lib/net/ldap/dataset.rb' - 'lib/net/ldap/entry.rb' -# Offense count: 1 -Style/ClassAndModuleCamelCase: - Exclude: - - 'lib/net/ldap/auth_adapter/gss_spnego.rb' - # Offense count: 23 -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Enabled: false -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: is_a?, kind_of? Style/ClassCheck: Exclude: - 'lib/net/ber/core_ext/array.rb' - - 'lib/net/ldap/error.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: Keywords. -# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Keywords, RequireColon. +# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE Style/CommentAnnotation: Exclude: - 'lib/net/ber.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions. -# SupportedStyles: assign_to_condition, assign_inside_condition -Style/ConditionalAssignment: - Exclude: - - 'lib/net/ldap/dn.rb' - -# Offense count: 87 -Style/ConstantName: +# Offense count: 8 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/CommentedKeyword: Exclude: - 'lib/net/ldap.rb' - 'lib/net/ldap/connection.rb' + - 'lib/net/ldap/entry.rb' - 'lib/net/ldap/filter.rb' - 'lib/net/ldap/pdu.rb' - - 'lib/net/snmp.rb' - - 'test/test_ldif.rb' - - 'testserver/ldapserver.rb' -# Offense count: 17 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'lib/net/ldap/dn.rb' + +# Offense count: 12 +# Configuration parameters: AllowedConstants. Style/Documentation: Exclude: - 'spec/**/*' - 'test/**/*' - - 'lib/net/ber/core_ext.rb' - 'lib/net/ldap.rb' - 'lib/net/ldap/auth_adapter.rb' - 'lib/net/ldap/auth_adapter/sasl.rb' @@ -373,25 +492,45 @@ Style/Documentation: - 'testserver/ldapserver.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: compact, expanded Style/EmptyMethod: Exclude: - 'test/test_auth_adapter.rb' +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/Encoding: + Exclude: + - 'net-ldap.gemspec' + - 'test/test_filter_parser.rb' + # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/EvenOdd: Exclude: - 'lib/net/ldap/dn.rb' # Offense count: 1 -# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. -# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS -Style/FileName: +# This cop supports safe autocorrection (--autocorrect). +Style/ExpandPathArguments: Exclude: - - 'lib/net-ldap.rb' + - 'net-ldap.gemspec' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/ExplicitBlockArgument: + Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/dataset.rb' + +# Offense count: 54 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false # Offense count: 9 # Configuration parameters: AllowedVariables. @@ -399,16 +538,18 @@ Style/GlobalVars: Exclude: - 'testserver/ldapserver.rb' -# Offense count: 2 -# Configuration parameters: MinBodyLength. +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: Exclude: - 'lib/net/ldap/filter.rb' # Offense count: 159 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent Style/HashSyntax: Exclude: - 'lib/net/ber.rb' @@ -426,24 +567,31 @@ Style/HashSyntax: - 'testserver/ldapserver.rb' # Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowIfModifier. Style/IfInsideElse: Exclude: - 'lib/net/ldap/instrumentation.rb' -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. +# Offense count: 25 +# This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: - 'lib/net/ber.rb' - 'lib/net/ber/core_ext/integer.rb' - 'lib/net/ldap.rb' + - 'lib/net/ldap/auth_adapter.rb' + - 'lib/net/ldap/auth_adapter/sasl.rb' + - 'lib/net/ldap/auth_adapter/simple.rb' + - 'lib/net/ldap/connection.rb' - 'lib/net/ldap/filter.rb' - 'lib/net/snmp.rb' + - 'test/integration/test_delete.rb' + - 'test/integration/test_password_modify.rb' # Offense count: 21 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline Style/MethodDefParentheses: Exclude: @@ -453,19 +601,27 @@ Style/MethodDefParentheses: - 'testserver/ldapserver.rb' # Offense count: 2 -Style/MethodMissing: +Style/MissingRespondToMissing: Exclude: - 'lib/net/ldap/dn.rb' - 'lib/net/ldap/entry.rb' # Offense count: 2 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/MultilineIfModifier: Exclude: - 'lib/net/ldap/connection.rb' +# Offense count: 26 +# This cop supports safe autocorrection (--autocorrect). +Style/MultilineWhenThen: + Exclude: + - 'lib/net/ldap/dn.rb' + # Offense count: 25 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict Style/MutableConstant: Exclude: - 'lib/net/ber.rb' @@ -479,22 +635,22 @@ Style/MutableConstant: - 'testserver/ldapserver.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. # SupportedStyles: both, prefix, postfix Style/NegatedIf: Exclude: - 'test/test_helper.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/NegatedWhile: Exclude: - 'lib/net/ldap/filter.rb' # Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, MinBodyLength. # SupportedStyles: skip_modifier_ifs, always Style/Next: Exclude: @@ -502,49 +658,55 @@ Style/Next: - 'testserver/ldapserver.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: predicate, comparison Style/NilComparison: Exclude: - 'lib/net/ldap/connection.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IncludeSemanticChanges. Style/NonNilCheck: Exclude: - 'lib/net/ber/ber_parser.rb' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/Not: Exclude: - 'lib/net/ldap/filter.rb' # Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: Strict. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. Style/NumericLiterals: MinDigits: 8 -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. +# Offense count: 14 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - 'spec/**/*' - 'lib/net/ber/core_ext/integer.rb' + - 'lib/net/ldap/connection.rb' - 'lib/net/ldap/dn.rb' + - 'lib/net/ldap/filter.rb' - 'testserver/ldapserver.rb' -# Offense count: 3 -Style/OpMethod: +# Offense count: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: Exclude: - - 'lib/net/ldap/filter.rb' + - 'lib/net/ldap/entry.rb' # Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: AllowSafeAssignment. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. Style/ParenthesesAroundCondition: Exclude: - 'lib/net/ldap.rb' @@ -552,8 +714,8 @@ Style/ParenthesesAroundCondition: - 'lib/net/ldap/auth_adapter/sasl.rb' - 'lib/net/ldap/auth_adapter/simple.rb' -# Offense count: 11 -# Cop supports --auto-correct. +# Offense count: 13 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Exclude: @@ -565,17 +727,18 @@ Style/PercentLiteralDelimiters: - 'test/test_entry.rb' - 'test/test_helper.rb' -# Offense count: 11 -# Cop supports --auto-correct. +# Offense count: 20 +# This cop supports safe autocorrection (--autocorrect). Style/PerlBackrefs: Exclude: - 'lib/net/ldap/dataset.rb' - 'lib/net/ldap/filter.rb' + - 'test/test_ldif.rb' - 'testserver/ldapserver.rb' # Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowedCompactTypes. # SupportedStyles: compact, exploded Style/RaiseArgs: Exclude: @@ -583,21 +746,46 @@ Style/RaiseArgs: - 'lib/net/ldap/pdu.rb' - 'lib/net/snmp.rb' -# Offense count: 1 -# Cop supports --auto-correct. +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). Style/RedundantBegin: Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/connection.rb' - 'lib/net/snmp.rb' # Offense count: 4 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RedundantParentheses: Exclude: - 'lib/net/ldap/filter.rb' - 'test/test_filter.rb' +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantPercentQ: + Exclude: + - 'net-ldap.gemspec' + - 'test/test_entry.rb' + +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpCharacterClass: + Exclude: + - 'lib/net/ber/core_ext/integer.rb' + - 'lib/net/ldap/dataset.rb' + - 'lib/net/ldap/filter.rb' + - 'testserver/ldapserver.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpEscape: + Exclude: + - 'lib/net/ldap/dataset.rb' + - 'lib/net/ldap/filter.rb' + # Offense count: 3 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Exclude: @@ -606,7 +794,7 @@ Style/RedundantReturn: - 'lib/net/ldap/entry.rb' # Offense count: 8 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RedundantSelf: Exclude: - 'lib/net/ber/core_ext/array.rb' @@ -615,8 +803,8 @@ Style/RedundantSelf: - 'lib/net/ldap/filter.rb' # Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: Exclude: @@ -624,52 +812,91 @@ Style/RegexpLiteral: - 'net-ldap.gemspec' # Offense count: 1 -# Cop supports --auto-correct. +# This cop supports safe autocorrection (--autocorrect). Style/RescueModifier: Exclude: - 'test/ber/core_ext/test_string.rb' -# Offense count: 8 -# Cop supports --auto-correct. +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'lib/net/snmp.rb' + - 'testserver/ldapserver.rb' + +# Offense count: 13 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/connection.rb' + - 'lib/net/ldap/dataset.rb' + - 'lib/net/ldap/pdu.rb' + +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: Exclude: - 'lib/net/ldap/dn.rb' - - 'lib/net/ldap/error.rb' - 'testserver/ldapserver.rb' -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: use_perl_names, use_english_names +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/connection.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: RequireEnglish, EnforcedStyle. +# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names Style/SpecialGlobalVars: Exclude: - 'lib/net/snmp.rb' - - 'net-ldap.gemspec' - 'testserver/ldapserver.rb' -# Offense count: 656 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. +# Offense count: 15 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/net/ldap/dn.rb' + - 'lib/net/ldap/filter.rb' + - 'lib/net/ldap/password.rb' + - 'test/ber/test_ber.rb' + - 'test/test_ldif.rb' + - 'test/test_snmp.rb' + +# Offense count: 683 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: Enabled: false # Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). Style/StructInheritance: Exclude: - 'test/test_ldap.rb' # Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: MinSize, SupportedStyles. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinSize. # SupportedStyles: percent, brackets Style/SymbolArray: EnforcedStyle: brackets # Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowSafeAssignment. # SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex Style/TernaryParentheses: Exclude: @@ -677,47 +904,60 @@ Style/TernaryParentheses: - 'lib/net/ldap/connection.rb' - 'lib/net/ldap/dataset.rb' +# Offense count: 38 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Enabled: false + # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. -# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. +# AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym Style/TrivialAccessors: Exclude: - 'lib/net/ldap/connection.rb' -# Offense count: 5 -# Cop supports --auto-correct. -Style/UnneededPercentQ: +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/UnpackFirst: Exclude: - - 'net-ldap.gemspec' - - 'test/test_entry.rb' + - 'lib/net/ber/ber_parser.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. +# This cop supports safe autocorrection (--autocorrect). Style/WhileUntilModifier: Exclude: - 'lib/net/ldap/filter.rb' # Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, WordRegex. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: WordRegex. # SupportedStyles: percent, brackets Style/WordArray: EnforcedStyle: percent MinSize: 3 -# Offense count: 2 -# Cop supports --auto-correct. +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: forbid_for_all_comparison_operators, forbid_for_equality_operators_only, require_for_all_comparison_operators, require_for_equality_operators_only Style/YodaCondition: Exclude: - 'lib/net/ber/ber_parser.rb' - - 'testserver/ldapserver.rb' # Offense count: 6 -# Cop supports --auto-correct. +# This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: Exclude: - 'lib/net/ldap/connection.rb' - 'lib/net/ldap/filter.rb' - 'testserver/ldapserver.rb' + +# Offense count: 24 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 360 diff --git a/History.rdoc b/History.rdoc index 36d55f2c..bb771c83 100644 --- a/History.rdoc +++ b/History.rdoc @@ -2,6 +2,7 @@ * Fix escaping of # and space in attrs #408 * Add support to use SNI #406 * Drop Ruby 2.5 and JRuby 9.2 from CI tests +* Bump rubocop to 1.48.1 === Net::LDAP 0.17.1 * Fixed shebang of bash #385 diff --git a/net-ldap.gemspec b/net-ldap.gemspec index 3669545b..a5e53b88 100644 --- a/net-ldap.gemspec +++ b/net-ldap.gemspec @@ -31,7 +31,7 @@ the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).} s.add_development_dependency("flexmock", "~> 1.3") s.add_development_dependency("rake", "~> 12.3.3") - s.add_development_dependency("rubocop", "~> 0.49.0") + s.add_development_dependency("rubocop", "~> 1.48") s.add_development_dependency("test-unit", "~> 3.3") s.add_development_dependency("byebug", "~> 9.0.6") unless RUBY_PLATFORM == "java" end From 96b7e7510cecf4466a3f86f080abdfad1958583a Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Wed, 29 Mar 2023 13:19:38 -0400 Subject: [PATCH 09/28] Update tests for Ruby 3.1 and 3.2 --- .github/workflows/test.yml | 2 ++ test/test_ssl_ber.rb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 942822cd..f0ad168b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,8 @@ jobs: - "2.6" - "2.7" - "3.0" + - "3.1" + - "3.2" - "jruby-9.3" - "jruby-9.4" - "truffleruby-21.0.0" diff --git a/test/test_ssl_ber.rb b/test/test_ssl_ber.rb index 5677ea0d..cbcf1127 100644 --- a/test/test_ssl_ber.rb +++ b/test/test_ssl_ber.rb @@ -31,12 +31,14 @@ def setup def test_transmit_strings omit_if RUBY_PLATFORM == "java", "JRuby throws an error without a real socket" + omit_if RUBY_VERSION >= "3.1", "Ruby complains about connection not being open" assert_equal "foo", transmit("foo") end def test_transmit_ber_encoded_numbers omit_if RUBY_PLATFORM == "java", "JRuby throws an error without a real socket" + omit_if RUBY_VERSION >= "3.1", "Ruby complains about connection not being open" @to.write 1234.to_ber assert_equal 1234, @from.read_ber From cbb2dfc9ed5f1c13710a7b5596193318ef23c67c Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Wed, 29 Mar 2023 13:33:39 -0400 Subject: [PATCH 10/28] Update CI for TruffleRuby 22 --- .github/workflows/test.yml | 2 +- History.rdoc | 1 + docker-compose.yml | 5 +++-- test/test_ssl_ber.rb | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f0ad168b..b035e809 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: - "3.2" - "jruby-9.3" - "jruby-9.4" - - "truffleruby-21.0.0" + - "truffleruby-22" steps: - uses: actions/checkout@v2 - name: Run tests with Ruby ${{ matrix.ruby }} diff --git a/History.rdoc b/History.rdoc index bb771c83..db63cbf6 100644 --- a/History.rdoc +++ b/History.rdoc @@ -3,6 +3,7 @@ * Add support to use SNI #406 * Drop Ruby 2.5 and JRuby 9.2 from CI tests * Bump rubocop to 1.48.1 +* Update CI for TruffleRuby 22 === Net::LDAP 0.17.1 * Fixed shebang of bash #385 diff --git a/docker-compose.yml b/docker-compose.yml index 60f36a8a..6ada67bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -94,8 +94,9 @@ services: - .:/code working_dir: /code - ci-truffleruby-21.0.0: - image: flavorjones/truffleruby:21.0.0 + # https://github.com/flavorjones/truffleruby/pkgs/container/truffleruby + ci-truffleruby-22: + image: ghcr.io/flavorjones/truffleruby:22.3.1 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap diff --git a/test/test_ssl_ber.rb b/test/test_ssl_ber.rb index cbcf1127..766c8b84 100644 --- a/test/test_ssl_ber.rb +++ b/test/test_ssl_ber.rb @@ -31,14 +31,14 @@ def setup def test_transmit_strings omit_if RUBY_PLATFORM == "java", "JRuby throws an error without a real socket" - omit_if RUBY_VERSION >= "3.1", "Ruby complains about connection not being open" + omit_if (RUBY_VERSION >= "3.1" || RUBY_ENGINE == "truffleruby"), "Ruby complains about connection not being open" assert_equal "foo", transmit("foo") end def test_transmit_ber_encoded_numbers omit_if RUBY_PLATFORM == "java", "JRuby throws an error without a real socket" - omit_if RUBY_VERSION >= "3.1", "Ruby complains about connection not being open" + omit_if (RUBY_VERSION >= "3.1" || RUBY_ENGINE == "truffleruby"), "Ruby complains about connection not being open" @to.write 1234.to_ber assert_equal 1234, @from.read_ber From e7896d830f01a1984f0b4b21fea20a012092d52d Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Thu, 25 May 2023 11:29:29 +0100 Subject: [PATCH 11/28] Document `connect_timeout` in Constructor Details Previously, this was only documented in the `Overview` section and missing from https://www.rubydoc.info/github/ruby-ldap/ruby-net-ldap/Net%2FLDAP:initialize --- lib/net/ldap.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index 1547597f..af01dd1d 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -480,6 +480,8 @@ def self.result2string(code) #:nodoc: # server says it supports them. This is a fix for MS Active Directory # * :instrumentation_service => An object responsible for instrumenting # operations, compatible with ActiveSupport::Notifications' public API. + # * :connect_timeout => The TCP socket timeout (in seconds) to use when + # connecting to the LDAP server (default 5 seconds). # * :encryption => specifies the encryption to be used in communicating # with the LDAP server. The value must be a Hash containing additional # parameters, which consists of two keys: From d2d500b12b25b9bf8714c683b253fc57bbfaddd8 Mon Sep 17 00:00:00 2001 From: Grant Willcox Date: Mon, 5 Jun 2023 09:54:52 -0500 Subject: [PATCH 12/28] Add in tests --- test/test_ldap_connection.rb | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/test_ldap_connection.rb b/test/test_ldap_connection.rb index dcb4ce72..74de115c 100644 --- a/test/test_ldap_connection.rb +++ b/test/test_ldap_connection.rb @@ -501,4 +501,43 @@ def test_search_net_ldap_connection_event # ensure no unread assert unread.empty?, "should not have any leftover unread messages" end + + def test_search_with_controls + # search data + search_data_ber = Net::BER::BerIdentifiedArray.new([1, [ + "uid=user1,ou=People,dc=rubyldap,dc=com", + [["uid", ["user1"]]], + ]]) + search_data_ber.ber_identifier = Net::LDAP::PDU::SearchReturnedData + search_data = [1, search_data_ber] + # search result (end of results) + search_result_ber = Net::BER::BerIdentifiedArray.new([Net::LDAP::ResultCodeSuccess, "", ""]) + search_result_ber.ber_identifier = Net::LDAP::PDU::SearchResult + search_result = [1, search_result_ber] + @tcp_socket.should_receive(:read_ber).and_return(search_data) + .and_return(search_result) + + events = @service.subscribe "search.net_ldap_connection" + unread = @service.subscribe "search_messages_unread.net_ldap_connection" + + all_but_sacl_flag = 0x1 | 0x2 | 0x4 # OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION + control_values = [all_but_sacl_flag].map(&:to_ber).to_ber_sequence.to_s.to_ber + controls = [] + # LDAP_SERVER_SD_FLAGS constant definition, taken from https://ldapwiki.com/wiki/LDAP_SERVER_SD_FLAGS_OID + ldap_server_sd_flags = '1.2.840.113556.1.4.801'.freeze + controls << [ldap_server_sd_flags.to_ber, true.to_ber, control_values].to_ber_sequence + + result = @connection.search(filter: "(uid=user1)", base: "ou=People,dc=rubyldap,dc=com", controls: controls) + assert result.success?, "should be success" + + # a search event + payload, result = events.pop + assert payload.key?(:result) + assert payload.key?(:filter) + assert_equal "(uid=user1)", payload[:filter].to_s + assert result + + # ensure no unread + assert unread.empty?, "should not have any leftover unread messages" + end end From 06acd16a09d5edbdfe8876de1e12503c571a4381 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Tue, 6 Jun 2023 00:21:07 -0400 Subject: [PATCH 13/28] Update rubocop todo --- .rubocop_todo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c1d8b87a..ed69b335 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -277,7 +277,7 @@ Lint/UselessAssignment: # Offense count: 38 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: - Max: 120 + Max: 124 # Offense count: 3 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. @@ -298,12 +298,12 @@ Metrics/ClassLength: # Offense count: 20 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: - Max: 44 + Max: 45 # Offense count: 74 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 128 + Max: 130 # Offense count: 1 # Configuration parameters: CountComments, CountAsOne. @@ -313,7 +313,7 @@ Metrics/ModuleLength: # Offense count: 12 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: - Max: 44 + Max: 46 # Offense count: 1 Naming/AccessorMethodName: From 84bfc385cfad73c3e24ee36b014f2e81dc10ea81 Mon Sep 17 00:00:00 2001 From: Julian Paul Dasmarinas Date: Tue, 27 Jun 2023 09:58:45 +0800 Subject: [PATCH 14/28] Fix openssl error when using multiple hosts --- lib/net/ldap/connection.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index 83887e5e..f51b7b7e 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -30,10 +30,9 @@ def socket_class=(socket_class) @socket_class = socket_class end - def prepare_socket(server, timeout=nil) + def prepare_socket(server, timeout=nil, hostname='127.0.0.1') socket = server[:socket] encryption = server[:encryption] - hostname = server[:host] @conn = socket setup_encryption(encryption, timeout, hostname) if encryption @@ -51,7 +50,7 @@ def open_connection(server) errors = [] hosts.each do |host, port| begin - prepare_socket(server.merge(socket: @socket_class.new(host, port, socket_opts)), timeout) + prepare_socket(server.merge(socket: @socket_class.new(host, port, socket_opts)), timeout, host) if encryption if encryption[:tls_options] && encryption[:tls_options][:verify_mode] && From a40d20363d34df7032182ee3e58323d93a43c316 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Wed, 3 Jan 2024 12:06:46 -0500 Subject: [PATCH 15/28] Prepare 0.19.0 --- History.rdoc | 6 ++++++ lib/net/ldap/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/History.rdoc b/History.rdoc index db63cbf6..3f6248ee 100644 --- a/History.rdoc +++ b/History.rdoc @@ -1,3 +1,9 @@ +=== Net::LDAP 0.19.0 +* Net::LDAP::DN - Retain trailing spaces in RDN values in DNs #412 +* Add in ability for users to specify LDAP controls when conducting searches #411 +* Document connect_timeout in Constructor Details #415 +* Fix openssl error when using multiple hosts #417 + === Net::LDAP 0.18.0 * Fix escaping of # and space in attrs #408 * Add support to use SNI #406 diff --git a/lib/net/ldap/version.rb b/lib/net/ldap/version.rb index 6ca72fca..536b2f89 100644 --- a/lib/net/ldap/version.rb +++ b/lib/net/ldap/version.rb @@ -1,5 +1,5 @@ module Net class LDAP - VERSION = "0.18.0" + VERSION = "0.19.0" end end From 7f060e1f3a02592b35c350082297f17d7eac73f1 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Wed, 3 Jan 2024 12:13:05 -0500 Subject: [PATCH 16/28] Rubocop autocorrect --- lib/net/ldap.rb | 4 ++-- lib/net/ldap/auth_adapter/gss_spnego.rb | 2 +- lib/net/ldap/auth_adapter/sasl.rb | 2 +- lib/net/ldap/auth_adapter/simple.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index af01dd1d..bf9dcc83 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -1257,10 +1257,10 @@ def search_subschema_entry rs = search(:ignore_server_caps => true, :base => "", :scope => SearchScope_BaseObject, :attributes => [:subschemaSubentry]) - return Net::LDAP::Entry.new unless (rs and rs.first) + return Net::LDAP::Entry.new unless rs and rs.first subschema_name = rs.first.subschemasubentry - return Net::LDAP::Entry.new unless (subschema_name and subschema_name.first) + return Net::LDAP::Entry.new unless subschema_name and subschema_name.first rs = search(:ignore_server_caps => true, :base => subschema_name.first, :scope => SearchScope_BaseObject, diff --git a/lib/net/ldap/auth_adapter/gss_spnego.rb b/lib/net/ldap/auth_adapter/gss_spnego.rb index 4a451ffb..b4c3e519 100644 --- a/lib/net/ldap/auth_adapter/gss_spnego.rb +++ b/lib/net/ldap/auth_adapter/gss_spnego.rb @@ -20,7 +20,7 @@ def bind(auth) require 'ntlm' user, psw = [auth[:username] || auth[:dn], auth[:password]] - raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless (user && psw) + raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless user && psw nego = proc do |challenge| t2_msg = NTLM::Message.parse(challenge) diff --git a/lib/net/ldap/auth_adapter/sasl.rb b/lib/net/ldap/auth_adapter/sasl.rb index 4489bda4..bfebfc94 100644 --- a/lib/net/ldap/auth_adapter/sasl.rb +++ b/lib/net/ldap/auth_adapter/sasl.rb @@ -30,7 +30,7 @@ class Sasl < Net::LDAP::AuthAdapter def bind(auth) mech, cred, chall = auth[:mechanism], auth[:initial_credential], auth[:challenge_response] - raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless (mech && cred && chall) + raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless mech && cred && chall message_id = @connection.next_msgid diff --git a/lib/net/ldap/auth_adapter/simple.rb b/lib/net/ldap/auth_adapter/simple.rb index d8e61c7b..8a753ea6 100644 --- a/lib/net/ldap/auth_adapter/simple.rb +++ b/lib/net/ldap/auth_adapter/simple.rb @@ -11,7 +11,7 @@ def bind(auth) ["", ""] end - raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless (user && psw) + raise Net::LDAP::BindingInformationInvalidError, "Invalid binding information" unless user && psw message_id = @connection.next_msgid request = [ From 7557c6f4e1e4709f39737a97e8fa29b2a9c0e8aa Mon Sep 17 00:00:00 2001 From: Anton-Ivanov Date: Sat, 26 Oct 2024 17:38:17 +0300 Subject: [PATCH 17/28] #431, Add `ostruct` as a dependency to the gemspec This commit adds `ostruct` as an explicit dependency in the net-ldap gemspec. With the release of Ruby 3.3.5 and later versions, users of net-ldap may encounter warnings related to the use of `ostruct` if it is not declared as a dependency. By including `ostruct`, we aim to enhance clarity regarding the gem's requirements and prevent any runtime issues related to missing dependencies. --- net-ldap.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/net-ldap.gemspec b/net-ldap.gemspec index a5e53b88..1b72a753 100644 --- a/net-ldap.gemspec +++ b/net-ldap.gemspec @@ -29,6 +29,7 @@ the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).} s.required_ruby_version = ">= 2.0.0" s.summary = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing distributed directory services} + s.add_dependency("ostruct") s.add_development_dependency("flexmock", "~> 1.3") s.add_development_dependency("rake", "~> 12.3.3") s.add_development_dependency("rubocop", "~> 1.48") From 5eec272b76bfa7c396d54dc38d2ec6e5ee2512a2 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Mon, 28 Oct 2024 21:39:46 -0400 Subject: [PATCH 18/28] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b035e809..0cacf25b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,4 +30,4 @@ jobs: steps: - uses: actions/checkout@v2 - name: Run tests with Ruby ${{ matrix.ruby }} - run: docker-compose run ci-${{ matrix.ruby }} + run: docker compose run ci-${{ matrix.ruby }} From 60f2bc35dbc58b7b1ab0e6bdde14b02c300f3e34 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Mon, 28 Oct 2024 21:43:43 -0400 Subject: [PATCH 19/28] Update docker-compose --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6ada67bf..46ef00cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.8" - networks: integration_test_network: From 16ebec42a8c99777ae3e1adf9016ac90109d1c9f Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Mon, 28 Oct 2024 21:46:20 -0400 Subject: [PATCH 20/28] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0cacf25b..945d1787 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: - "3.2" - "jruby-9.3" - "jruby-9.4" - - "truffleruby-22" + - "truffleruby-24" steps: - uses: actions/checkout@v2 - name: Run tests with Ruby ${{ matrix.ruby }} From 8a737ce0fdefaeba97c171f1ced021766607fea5 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Mon, 28 Oct 2024 21:49:37 -0400 Subject: [PATCH 21/28] Update test.yml --- .github/workflows/test.yml | 2 +- docker-compose.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 945d1787..6f335bc0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: - "3.2" - "jruby-9.3" - "jruby-9.4" - - "truffleruby-24" + - "truffleruby" steps: - uses: actions/checkout@v2 - name: Run tests with Ruby ${{ matrix.ruby }} diff --git a/docker-compose.yml b/docker-compose.yml index 46ef00cf..ea9d5865 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -93,8 +93,8 @@ services: working_dir: /code # https://github.com/flavorjones/truffleruby/pkgs/container/truffleruby - ci-truffleruby-22: - image: ghcr.io/flavorjones/truffleruby:22.3.1 + ci-truffleruby: + image: ghcr.io/flavorjones/truffleruby:stable entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap From ed83108ea1bb549a76bab1e8e48995ae8306614b Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Mon, 28 Oct 2024 21:53:02 -0400 Subject: [PATCH 22/28] Update test.yml --- .github/workflows/test.yml | 3 +-- docker-compose.yml | 30 ++++++++---------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f335bc0..3a405a39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,11 +19,10 @@ jobs: strategy: matrix: ruby: - - "2.6" - - "2.7" - "3.0" - "3.1" - "3.2" + - "3.3" - "jruby-9.3" - "jruby-9.4" - "truffleruby" diff --git a/docker-compose.yml b/docker-compose.yml index ea9d5865..11f93ba2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,22 +22,8 @@ services: volumes: - ./test/fixtures/ldif:/ldif:ro - ci-2.6: - image: ruby:2.7 - entrypoint: /code/ci-run.sh - environment: - INTEGRATION: openldap - INTEGRATION_HOST: ldap.example.org - depends_on: - - openldap - networks: - integration_test_network: - volumes: - - .:/code - working_dir: /code - - ci-2.7: - image: ruby:2.7 + ci-3.0: + image: ruby:3.0 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap @@ -50,8 +36,8 @@ services: - .:/code working_dir: /code - ci-3.0: - image: ruby:3.0 + ci-3.1: + image: ruby:3.1 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap @@ -64,8 +50,8 @@ services: - .:/code working_dir: /code - ci-3.1: - image: ruby:3.1 + ci-3.2: + image: ruby:3.2 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap @@ -78,8 +64,8 @@ services: - .:/code working_dir: /code - ci-3.2: - image: ruby:3.2 + ci-3.3: + image: ruby:3.3 entrypoint: /code/ci-run.sh environment: INTEGRATION: openldap From 2605a02920a87b1abaa32f12c2bed658b3e7b6ba Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Mon, 28 Oct 2024 22:04:52 -0400 Subject: [PATCH 23/28] Require Ruby >= 3.0 (#435) * Require Ruby >= 3.0.0 * Update test.yml --- .github/workflows/test.yml | 1 - net-ldap.gemspec | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a405a39..7cc5019d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,6 @@ jobs: - "3.1" - "3.2" - "3.3" - - "jruby-9.3" - "jruby-9.4" - "truffleruby" steps: diff --git a/net-ldap.gemspec b/net-ldap.gemspec index 1b72a753..3def4c20 100644 --- a/net-ldap.gemspec +++ b/net-ldap.gemspec @@ -26,7 +26,7 @@ the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).} s.homepage = %q{http://github.com/ruby-ldap/ruby-net-ldap} s.rdoc_options = ["--main", "README.rdoc"] s.require_paths = ["lib"] - s.required_ruby_version = ">= 2.0.0" + s.required_ruby_version = ">= 3.0.0" s.summary = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing distributed directory services} s.add_dependency("ostruct") From a515dadd24d2ff49ce0c62f5cb49629740a0edd8 Mon Sep 17 00:00:00 2001 From: Sebb Date: Tue, 29 Oct 2024 02:09:53 +0000 Subject: [PATCH 24/28] Link to usage examples (#428) * Link to usage doc * Better link --------- Co-authored-by: Kevin McCormack --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 6daafda6..88bdba61 100644 --- a/README.rdoc +++ b/README.rdoc @@ -23,7 +23,7 @@ the most recent LDAP RFCs (4510–4519, plus portions of 4520–4532). == Synopsis -See {Net::LDAP on rubydoc.info}[https://www.rubydoc.info/github/ruby-ldap/ruby-net-ldap] for documentation and usage samples. +See {Net::LDAP on rubydoc.info}[https://www.rubydoc.info/github/ruby-ldap/ruby-net-ldap/Net/LDAP] for documentation and usage samples. == Requirements From 75c0bcbda4b91f981fb6b88896346d3259de20a1 Mon Sep 17 00:00:00 2001 From: Spencer McIntyre Date: Mon, 28 Oct 2024 22:12:31 -0400 Subject: [PATCH 25/28] Add controls for modify and add operations (#426) * Allow controls for add and modify * Add tests for add and modify --------- Co-authored-by: Kevin McCormack --- lib/net/ldap/connection.rb | 14 ++++++++++++-- test/test_ldap_connection.rb | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index f51b7b7e..65fa5330 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -569,7 +569,12 @@ def modify(args) ops.to_ber_sequence, ].to_ber_appsequence(Net::LDAP::PDU::ModifyRequest) - write(request, nil, message_id) + controls = args.fetch(:controls, nil) + unless controls.nil? + controls = controls.to_ber_contextspecific(0) + end + + write(request, controls, message_id) pdu = queued_read(message_id) if !pdu || pdu.app_tag != Net::LDAP::PDU::ModifyResponse @@ -641,7 +646,12 @@ def add(args) message_id = next_msgid request = [add_dn.to_ber, add_attrs.to_ber_sequence].to_ber_appsequence(Net::LDAP::PDU::AddRequest) - write(request, nil, message_id) + controls = args.fetch(:controls, nil) + unless controls.nil? + controls = controls.to_ber_contextspecific(0) + end + + write(request, controls, message_id) pdu = queued_read(message_id) if !pdu || pdu.app_tag != Net::LDAP::PDU::AddResponse diff --git a/test/test_ldap_connection.rb b/test/test_ldap_connection.rb index 74de115c..ca9bcb0b 100644 --- a/test/test_ldap_connection.rb +++ b/test/test_ldap_connection.rb @@ -502,6 +502,40 @@ def test_search_net_ldap_connection_event assert unread.empty?, "should not have any leftover unread messages" end + def test_add_with_controls + dacl_flag = 0x4 # DACL_SECURITY_INFORMATION + control_values = [dacl_flag].map(&:to_ber).to_ber_sequence.to_s.to_ber + controls = [] + # LDAP_SERVER_SD_FLAGS constant definition, taken from https://ldapwiki.com/wiki/LDAP_SERVER_SD_FLAGS_OID + ldap_server_sd_flags = '1.2.840.113556.1.4.801'.freeze + controls << [ldap_server_sd_flags.to_ber, true.to_ber, control_values].to_ber_sequence + + ber = Net::BER::BerIdentifiedArray.new([Net::LDAP::ResultCodeSuccess, "", ""]) + ber.ber_identifier = Net::LDAP::PDU::AddResponse + @tcp_socket.should_receive(:read_ber).and_return([1, ber]) + + result = @connection.add(:dn => "uid=added-user1,ou=People,dc=rubyldap,dc=com", :controls => controls) + assert result.success?, "should be success" + assert_equal "", result.error_message + end + + def test_modify_with_controls + dacl_flag = 0x4 # DACL_SECURITY_INFORMATION + control_values = [dacl_flag].map(&:to_ber).to_ber_sequence.to_s.to_ber + controls = [] + # LDAP_SERVER_SD_FLAGS constant definition, taken from https://ldapwiki.com/wiki/LDAP_SERVER_SD_FLAGS_OID + ldap_server_sd_flags = '1.2.840.113556.1.4.801'.freeze + controls << [ldap_server_sd_flags.to_ber, true.to_ber, control_values].to_ber_sequence + + ber = Net::BER::BerIdentifiedArray.new([Net::LDAP::ResultCodeSuccess, "", ""]) + ber.ber_identifier = Net::LDAP::PDU::ModifyResponse + @tcp_socket.should_receive(:read_ber).and_return([1, ber]) + + result = @connection.modify(:dn => "1", :operations => [[:replace, "mail", "something@sothsdkf.com"]], :controls => controls) + assert result.success?, "should be success" + assert_equal "", result.error_message + end + def test_search_with_controls # search data search_data_ber = Net::BER::BerIdentifiedArray.new([1, [ From a56279079b0a6125a336c931c0dcf520c7d7d27e Mon Sep 17 00:00:00 2001 From: Spencer McIntyre Date: Sun, 24 Nov 2024 08:58:34 -0500 Subject: [PATCH 26/28] Add support for ldapwhoami (RFC4532) (now with tests) (#425) * Add support for ldapwhoami (RFC4532) * Do not break Net::LDAP#modify_password * Return the extended response data * Add test for connection.ldapwhoami * Fix processing password modify responses Per RFC4511 section 4.12, the responseValue field of an ExtendedResponse object is an optional string. Per RFC3062 section 2, the response to a passsword modify request is a sequence. This means the extended response must be parsed. --------- Co-authored-by: a7b81a9086 <> Co-authored-by: Kevin McCormack --- .rubocop_todo.yml | 2 +- lib/net/ldap.rb | 22 ++++++++++++++++++++-- lib/net/ldap/connection.rb | 16 ++++++++++++++++ lib/net/ldap/pdu.rb | 4 ++-- test/integration/test_password_modify.rb | 24 +++++++++++++++++++++--- test/test_ldap_connection.rb | 11 +++++++++++ 6 files changed, 71 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ed69b335..426a2aed 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -293,7 +293,7 @@ Metrics/BlockNesting: # Offense count: 11 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 443 + Max: 451 # Offense count: 20 # Configuration parameters: AllowedMethods, AllowedPatterns. diff --git a/lib/net/ldap.rb b/lib/net/ldap.rb index bf9dcc83..8dca73c0 100644 --- a/lib/net/ldap.rb +++ b/lib/net/ldap.rb @@ -311,7 +311,7 @@ class Net::LDAP 0 => :array, # RFC-2251 Control and Filter-AND 1 => :array, # SearchFilter-OR 2 => :array, # SearchFilter-NOT - 3 => :array, # Seach referral + 3 => :array, # Search referral 4 => :array, # unknown use in Microsoft Outlook 5 => :array, # SearchFilter-GE 6 => :array, # SearchFilter-LE @@ -325,7 +325,7 @@ class Net::LDAP universal = { constructed: { - 107 => :array, #ExtendedResponse (PasswdModifyResponseValue) + 107 => :string, # ExtendedResponse }, } @@ -341,6 +341,7 @@ class Net::LDAP StartTlsOid = '1.3.6.1.4.1.1466.20037' PasswdModifyOid = '1.3.6.1.4.1.4203.1.11.1' + WhoamiOid = '1.3.6.1.4.1.4203.1.11.3' # https://tools.ietf.org/html/rfc4511#section-4.1.9 # https://tools.ietf.org/html/rfc4511#appendix-A @@ -1200,6 +1201,23 @@ def delete_tree(args) end end + # Return the authorization identity of the client that issues the + # ldapwhoami request. The method does not support any arguments. + # + # Returns True or False to indicate whether the request was successfull. + # The result is available in the extended status information when calling + # #get_operation_result. + # + # ldap.ldapwhoami + # puts ldap.get_operation_result.extended_response + def ldapwhoami(args = {}) + instrument "ldapwhoami.net_ldap", args do |payload| + @result = use_connection(args, &:ldapwhoami) + @result.success? ? @result.extended_response : nil + end + end + alias_method :whoami, :ldapwhoami + # This method is experimental and subject to change. Return the rootDSE # record from the LDAP server as a Net::LDAP::Entry, or an empty Entry if # the server doesn't return the record. diff --git a/lib/net/ldap/connection.rb b/lib/net/ldap/connection.rb index 65fa5330..f1a70b18 100644 --- a/lib/net/ldap/connection.rb +++ b/lib/net/ldap/connection.rb @@ -703,6 +703,22 @@ def delete(args) pdu end + def ldapwhoami + ext_seq = [Net::LDAP::WhoamiOid.to_ber_contextspecific(0)] + request = ext_seq.to_ber_appsequence(Net::LDAP::PDU::ExtendedRequest) + + message_id = next_msgid + + write(request, nil, message_id) + pdu = queued_read(message_id) + + if !pdu || pdu.app_tag != Net::LDAP::PDU::ExtendedResponse + raise Net::LDAP::ResponseMissingOrInvalidError, "response missing or invalid" + end + + pdu + end + # Internal: Returns a Socket like object used internally to communicate with # LDAP server. # diff --git a/lib/net/ldap/pdu.rb b/lib/net/ldap/pdu.rb index 564a23cc..83a609b7 100644 --- a/lib/net/ldap/pdu.rb +++ b/lib/net/ldap/pdu.rb @@ -194,13 +194,13 @@ def parse_ldap_result(sequence) # requestValue [1] OCTET STRING OPTIONAL } def parse_extended_response(sequence) - sequence.length >= 3 or raise Net::LDAP::PDU::Error, "Invalid LDAP result length." + sequence.length.between?(3, 5) or raise Net::LDAP::PDU::Error, "Invalid LDAP result length." @ldap_result = { :resultCode => sequence[0], :matchedDN => sequence[1], :errorMessage => sequence[2], } - @extended_response = sequence[3] + @extended_response = sequence.length == 3 ? nil : sequence.last end private :parse_extended_response diff --git a/test/integration/test_password_modify.rb b/test/integration/test_password_modify.rb index 65507c80..e7d8d670 100644 --- a/test/integration/test_password_modify.rb +++ b/test/integration/test_password_modify.rb @@ -1,6 +1,13 @@ require_relative '../test_helper' class TestPasswordModifyIntegration < LDAPIntegrationTestCase + # see: https://www.rfc-editor.org/rfc/rfc3062#section-2 + PASSWORD_MODIFY_SYNTAX = Net::BER.compile_syntax( + application: {}, + universal: {}, + context_specific: { primitive: { 0 => :string } }, + ) + def setup super @admin_account = { dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple } @@ -49,7 +56,13 @@ def test_password_modify_generate auth: @auth, old_password: 'admin') - generated_password = @ldap.get_operation_result.extended_response[0][0] + passwd_modify_response_value = @ldap.get_operation_result.extended_response + seq = Net::BER::BerIdentifiedArray.new + sio = StringIO.new(passwd_modify_response_value) + until (e = sio.read_ber(PASSWORD_MODIFY_SYNTAX)).nil? + seq << e + end + generated_password = seq[0][0] assert generated_password, 'Should have generated a password' @@ -64,8 +77,13 @@ def test_password_modify_generate_no_old_password assert @ldap.password_modify(dn: @dn, auth: @auth) - generated_password = @ldap.get_operation_result.extended_response[0][0] - + passwd_modify_response_value = @ldap.get_operation_result.extended_response + seq = Net::BER::BerIdentifiedArray.new + sio = StringIO.new(passwd_modify_response_value) + until (e = sio.read_ber(PASSWORD_MODIFY_SYNTAX)).nil? + seq << e + end + generated_password = seq[0][0] assert generated_password, 'Should have generated a password' refute @ldap.bind(username: @dn, password: 'admin', method: :simple), diff --git a/test/test_ldap_connection.rb b/test/test_ldap_connection.rb index ca9bcb0b..fdfa418c 100644 --- a/test/test_ldap_connection.rb +++ b/test/test_ldap_connection.rb @@ -574,4 +574,15 @@ def test_search_with_controls # ensure no unread assert unread.empty?, "should not have any leftover unread messages" end + + def test_ldapwhoami + ber = Net::BER::BerIdentifiedArray.new([Net::LDAP::ResultCodeSuccess, '', '', 0, 'dn:uid=zerosteiner,ou=users,dc=example,dc=org']) + ber.ber_identifier = Net::LDAP::PDU::ExtendedResponse + response = [1, ber] + + @tcp_socket.should_receive(:read_ber).and_return(response) + + result = @connection.ldapwhoami + assert result.extended_response == 'dn:uid=zerosteiner,ou=users,dc=example,dc=org' + end end From 16d76259566c0bf840dfc5c0009e92129bed5093 Mon Sep 17 00:00:00 2001 From: Kevin McCormack Date: Sat, 31 May 2025 16:43:44 -0400 Subject: [PATCH 27/28] Update for ruby 3.4 (#439) * Update for ruby 3.4 * Update gemfile * Update test workflow * Update ci --- .github/workflows/test.yml | 3 +- .rubocop_todo.yml | 105 ++++++++++++++++++------------------- Gemfile | 6 +++ ci-run.sh | 1 + docker-compose.yml | 14 ++--- net-ldap.gemspec | 6 +-- 6 files changed, 68 insertions(+), 67 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7cc5019d..605b66e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,7 @@ jobs: test: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: ruby: - "3.0" @@ -26,6 +27,6 @@ jobs: - "jruby-9.4" - "truffleruby" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Run tests with Ruby ${{ matrix.ruby }} run: docker compose run ci-${{ matrix.ruby }} diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 426a2aed..50901661 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,26 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-03-29 17:13:45 UTC using RuboCop version 1.48.1. +# on 2025-05-31 20:03:27 UTC using RuboCop version 1.75.8. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. -# Include: **/*.gemspec -Gemspec/OrderedDependencies: - Exclude: - - 'net-ldap.gemspec' - -# Offense count: 1 -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec -Gemspec/RequiredRubyVersion: - Exclude: - - 'net-ldap.gemspec' - # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -61,7 +46,7 @@ Layout/EmptyLineAfterMagicComment: # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: Exclude: - 'lib/net/ldap/dataset.rb' @@ -104,7 +89,7 @@ Layout/EndAlignment: Exclude: - 'testserver/ldapserver.rb' -# Offense count: 2 +# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets @@ -148,9 +133,9 @@ Layout/IndentationWidth: - 'lib/net/ldap/password.rb' - 'lib/net/snmp.rb' -# Offense count: 15 +# Offense count: 14 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. +# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation. Layout/LeadingCommentSpace: Exclude: - 'lib/net/ber/core_ext/array.rb' @@ -168,7 +153,7 @@ Layout/MultilineMethodCallBraceLayout: Exclude: - 'lib/net/ldap/filter.rb' -# Offense count: 7 +# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -186,8 +171,9 @@ Layout/SpaceAroundKeyword: # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. # SupportedStylesForExponentOperator: space, no_space +# SupportedStylesForRationalLiterals: space, no_space Layout/SpaceAroundOperators: Exclude: - 'lib/net/ber/ber_parser.rb' @@ -214,8 +200,8 @@ Layout/SpaceInsideParens: - 'lib/net/snmp.rb' # Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowComments. +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, AllowComments. Lint/EmptyConditionalBody: Exclude: - 'lib/net/ldap/filter.rb' @@ -227,6 +213,7 @@ Lint/EmptyWhen: - 'lib/net/ldap/pdu.rb' # Offense count: 30 +# This cop supports safe autocorrection (--autocorrect). Lint/ImplicitStringConcatenation: Exclude: - 'test/test_filter.rb' @@ -241,9 +228,9 @@ Lint/RescueException: Exclude: - 'lib/net/ldap/pdu.rb' -# Offense count: 9 +# Offense count: 10 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: - 'lib/net/ldap.rb' @@ -251,7 +238,8 @@ Lint/UnusedBlockArgument: # Offense count: 7 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. +# NotImplementedExceptions: NotImplementedError Lint/UnusedMethodArgument: Exclude: - 'lib/net/ldap/entry.rb' @@ -262,19 +250,21 @@ Lint/UnusedMethodArgument: # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. +# Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: Exclude: - 'lib/net/ldap/connection.rb' # Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. Lint/UselessAssignment: Exclude: - 'test/integration/test_add.rb' - 'test/test_ldap_connection.rb' - 'test/test_search.rb' -# Offense count: 38 +# Offense count: 42 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 124 @@ -285,22 +275,22 @@ Metrics/AbcSize: Metrics/BlockLength: Max: 119 -# Offense count: 11 -# Configuration parameters: CountBlocks. +# Offense count: 6 +# Configuration parameters: CountBlocks, CountModifierForms. Metrics/BlockNesting: Max: 4 -# Offense count: 11 +# Offense count: 12 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: Max: 451 -# Offense count: 20 +# Offense count: 21 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 45 -# Offense count: 74 +# Offense count: 79 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 130 @@ -333,7 +323,7 @@ Naming/ClassAndModuleCamelCase: Exclude: - 'lib/net/ldap/auth_adapter/gss_spnego.rb' -# Offense count: 87 +# Offense count: 88 Naming/ConstantName: Exclude: - 'lib/net/ldap.rb' @@ -350,6 +340,7 @@ Naming/ConstantName: # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: Exclude: + - 'Rakefile.rb' - 'lib/net-ldap.rb' # Offense count: 11 @@ -380,7 +371,7 @@ Style/AccessorGrouping: - 'lib/net/ldap.rb' - 'lib/net/ldap/pdu.rb' -# Offense count: 10 +# Offense count: 11 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: prefer_alias, prefer_alias_method @@ -434,8 +425,10 @@ Style/CharacterLiteral: # Offense count: 23 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. +# Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules. # SupportedStyles: nested, compact +# SupportedStylesForClasses: ~, nested, compact +# SupportedStylesForModules: ~, nested, compact Style/ClassAndModuleChildren: Enabled: false @@ -493,7 +486,7 @@ Style/Documentation: # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. +# Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: compact, expanded Style/EmptyMethod: Exclude: @@ -525,7 +518,7 @@ Style/ExplicitBlockArgument: - 'lib/net/ldap.rb' - 'lib/net/ldap/dataset.rb' -# Offense count: 54 +# Offense count: 57 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -545,11 +538,11 @@ Style/GuardClause: Exclude: - 'lib/net/ldap/filter.rb' -# Offense count: 159 +# Offense count: 164 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent +# SupportedShorthandSyntax: always, never, either, consistent, either_consistent Style/HashSyntax: Exclude: - 'lib/net/ber.rb' @@ -573,7 +566,7 @@ Style/IfInsideElse: Exclude: - 'lib/net/ldap/instrumentation.rb' -# Offense count: 25 +# Offense count: 28 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: @@ -618,7 +611,14 @@ Style/MultilineWhenThen: Exclude: - 'lib/net/ldap/dn.rb' -# Offense count: 25 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMethodComparison, ComparisonsThreshold. +Style/MultipleComparison: + Exclude: + - 'lib/net/ldap/dataset.rb' + +# Offense count: 26 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: literals, strict @@ -650,7 +650,7 @@ Style/NegatedWhile: # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, MinBodyLength. +# Configuration parameters: EnforcedStyle, MinBodyLength, AllowConsecutiveConditionals. # SupportedStyles: skip_modifier_ifs, always Style/Next: Exclude: @@ -678,7 +678,7 @@ Style/Not: Exclude: - 'lib/net/ldap/filter.rb' -# Offense count: 11 +# Offense count: 13 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. Style/NumericLiterals: @@ -704,15 +704,12 @@ Style/OptionalBooleanParameter: Exclude: - 'lib/net/ldap/entry.rb' -# Offense count: 6 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. Style/ParenthesesAroundCondition: Exclude: - - 'lib/net/ldap.rb' - - 'lib/net/ldap/auth_adapter/gss_spnego.rb' - 'lib/net/ldap/auth_adapter/sasl.rb' - - 'lib/net/ldap/auth_adapter/simple.rb' # Offense count: 13 # This cop supports safe autocorrection (--autocorrect). @@ -737,7 +734,7 @@ Style/PerlBackrefs: - 'testserver/ldapserver.rb' # Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedCompactTypes. # SupportedStyles: compact, exploded Style/RaiseArgs: @@ -874,7 +871,7 @@ Style/StringConcatenation: - 'test/test_ldif.rb' - 'test/test_snmp.rb' -# Offense count: 683 +# Offense count: 728 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -907,7 +904,7 @@ Style/TernaryParentheses: # Offense count: 38 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma +# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma Style/TrailingCommaInHashLiteral: Enabled: false @@ -955,9 +952,9 @@ Style/ZeroLengthPredicate: - 'lib/net/ldap/filter.rb' - 'testserver/ldapserver.rb' -# Offense count: 24 +# Offense count: 27 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https Layout/LineLength: Max: 360 diff --git a/Gemfile b/Gemfile index 851fabc2..10d2031f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,8 @@ source 'https://rubygems.org' gemspec + +gem "debug", platform: :mri +gem "flexmock", "~> 1.3" +gem "rake", "~> 12.3.3" +gem "rubocop", "~> 1.48" +gem "test-unit" diff --git a/ci-run.sh b/ci-run.sh index 27024a77..cef309c0 100755 --- a/ci-run.sh +++ b/ci-run.sh @@ -3,5 +3,6 @@ set -e gem install bundler +ruby -v | grep jruby && apt update && apt install -y gcc bundle check || bundle install bundle exec rake ci diff --git a/docker-compose.yml b/docker-compose.yml index 11f93ba2..cf715da5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,7 +24,7 @@ services: ci-3.0: image: ruby:3.0 - entrypoint: /code/ci-run.sh + command: /code/ci-run.sh environment: INTEGRATION: openldap INTEGRATION_HOST: ldap.example.org @@ -38,7 +38,7 @@ services: ci-3.1: image: ruby:3.1 - entrypoint: /code/ci-run.sh + command: /code/ci-run.sh environment: INTEGRATION: openldap INTEGRATION_HOST: ldap.example.org @@ -52,7 +52,7 @@ services: ci-3.2: image: ruby:3.2 - entrypoint: /code/ci-run.sh + command: /code/ci-run.sh environment: INTEGRATION: openldap INTEGRATION_HOST: ldap.example.org @@ -66,7 +66,7 @@ services: ci-3.3: image: ruby:3.3 - entrypoint: /code/ci-run.sh + command: /code/ci-run.sh environment: INTEGRATION: openldap INTEGRATION_HOST: ldap.example.org @@ -81,7 +81,7 @@ services: # https://github.com/flavorjones/truffleruby/pkgs/container/truffleruby ci-truffleruby: image: ghcr.io/flavorjones/truffleruby:stable - entrypoint: /code/ci-run.sh + command: /code/ci-run.sh environment: INTEGRATION: openldap INTEGRATION_HOST: ldap.example.org @@ -95,7 +95,7 @@ services: ci-jruby-9.3: image: jruby:9.3 - entrypoint: /code/ci-run.sh + command: /code/ci-run.sh environment: INTEGRATION: openldap INTEGRATION_HOST: ldap.example.org @@ -109,7 +109,7 @@ services: ci-jruby-9.4: image: jruby:9.4 - entrypoint: /code/ci-run.sh + command: /code/ci-run.sh environment: INTEGRATION: openldap INTEGRATION_HOST: ldap.example.org diff --git a/net-ldap.gemspec b/net-ldap.gemspec index 3def4c20..077077f2 100644 --- a/net-ldap.gemspec +++ b/net-ldap.gemspec @@ -29,10 +29,6 @@ the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).} s.required_ruby_version = ">= 3.0.0" s.summary = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing distributed directory services} + s.add_dependency("base64") s.add_dependency("ostruct") - s.add_development_dependency("flexmock", "~> 1.3") - s.add_development_dependency("rake", "~> 12.3.3") - s.add_development_dependency("rubocop", "~> 1.48") - s.add_development_dependency("test-unit", "~> 3.3") - s.add_development_dependency("byebug", "~> 9.0.6") unless RUBY_PLATFORM == "java" end From 990a666f654cca34afa6858abcd6fc70974dd6bd Mon Sep 17 00:00:00 2001 From: Hakeem <94065808+hakeem0114@users.noreply.github.com> Date: Sat, 31 May 2025 16:46:15 -0400 Subject: [PATCH 28/28] Add ruby 3.4 to CI (#438) * Add ruby 3.4 to CI * Add ruby 3.4 to docker-compose.yml --------- Co-authored-by: Kevin McCormack --- .github/workflows/test.yml | 1 + docker-compose.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 605b66e6..a1ce7996 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,7 @@ jobs: - "3.1" - "3.2" - "3.3" + - "3.4" - "jruby-9.4" - "truffleruby" steps: diff --git a/docker-compose.yml b/docker-compose.yml index cf715da5..4fbfbec8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -78,6 +78,20 @@ services: - .:/code working_dir: /code + ci-3.4: + image: ruby:3.4 + entrypoint: /code/ci-run.sh + environment: + INTEGRATION: openldap + INTEGRATION_HOST: ldap.example.org + depends_on: + - openldap + networks: + integration_test_network: + volumes: + - .:/code + working_dir: /code + # https://github.com/flavorjones/truffleruby/pkgs/container/truffleruby ci-truffleruby: image: ghcr.io/flavorjones/truffleruby:stable pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy