logstash-input-LDAPSearch 0.1.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8806c50a22c8f50e4be0b397f3e4fb3d3c4414fb
4
- data.tar.gz: 30b3b06e3af70d110f5f47d580fa0ee60d88248e
2
+ SHA256:
3
+ metadata.gz: 4535f5574a5e7b80e42a5c0f5349d9d17a41f958ab43da4faffc8413059c0c3e
4
+ data.tar.gz: 6a70d5ebc8fe0a0287189fb79898f85a49adba0e999077059b54656e3b5402aa
5
5
  SHA512:
6
- metadata.gz: 117ea66842f3633c61235d6a0f996a0a3381d692908bcf12a6237bb41108f59148f2db31dbca0052d421f974d8698b8995d4c04b8b8f676c90758dcb65bf32bf
7
- data.tar.gz: ff130a2ec97704dac70aba418c38a8da71b0a45c12d370f2ea37ba26bb43ae4f59fb89faeefcdb8e85a6ad51dfab3a6b8a25943708815f07b6d2526ec5276ab0
6
+ metadata.gz: 6f3f6d58bb509a7509478a7e91255593bf950f325aad4714b4fdc8096f3f761c5d9276fcf260e6a0cf182a31ffdd9de02d5a081f8eb231934f8fd91debd69b17
7
+ data.tar.gz: e0c58e63cb9afcc5d325192a548caa940b1469930e397f0e412f6a9ec5362e63030c02607ed3ea85988157c8ad78a01f714548751ae0e9eb3a63f8d2e12d2fc0
@@ -0,0 +1,3 @@
1
+ ## 0.3.0
2
+ - Few simplifications of the code
3
+ - Add documentation
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
- source 'https://rubygems.org'
2
- gemspec
3
- gem 'jruby-ldap'
4
- #gem 'logstash-devutils', '~> 0.0.10'
1
+ source 'https://rubygems.org' do
2
+ gem 'net-ldap'
3
+ end
data/README.md CHANGED
@@ -1,36 +1,32 @@
1
1
  # Logstash Plugin
2
2
 
3
- This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
4
 
5
5
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
6
 
7
+ # Remarks for version 0.2.x
8
+
9
+ This version was developped by [pilyon3](https://github.com/pilyon3).
10
+
11
+ The main goals of this version is:
12
+ - to replace the use of ruby-ldap library by ruby-net-ldap, which permit natively to override MS ActiveDirectory MaxPageSize limitation of 5000 results by default introduced with Windows Server 2008
13
+ - to make it compatible with Logstash version 5.0 and higher
14
+
7
15
  ## Documentation
8
16
 
9
- Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
17
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
18
 
11
19
  - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
20
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
21
 
14
22
  ## Need Help?
15
23
 
16
- Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
24
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
25
 
18
26
  ## Developing
19
27
 
20
28
  ### 1. Plugin Developement and Testing
21
29
 
22
-
23
- #### To make bundle install work
24
- - I need to install rvm before :
25
- ```sh
26
- # gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
27
- # curl -sSL https://get.rvm.io | bash -s stable --ruby
28
- ```
29
- - then I need to install jruby
30
- ```sh
31
- # sudo rvm install jruby
32
- ```
33
-
34
30
  #### Code
35
31
  - To get started, you'll need JRuby with the Bundler gem installed.
36
32
 
@@ -65,7 +61,7 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
65
61
  ```
66
62
  - Install plugin
67
63
  ```sh
68
- bin/plugin install --no-verify
64
+ bin/logstash-plugin install --no-verify
69
65
  ```
70
66
  - Run Logstash with your plugin
71
67
  ```sh
@@ -83,7 +79,7 @@ gem build logstash-filter-awesome.gemspec
83
79
  ```
84
80
  - Install the plugin from the Logstash home
85
81
  ```sh
86
- bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
82
+ bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
87
83
  ```
88
84
  - Start Logstash and proceed to test the plugin
89
85
 
@@ -95,4 +91,4 @@ Programming is not a required skill. Whatever you've seen about open source and
95
91
 
96
92
  It is more important to the community that you are able to contribute.
97
93
 
98
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
94
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -1,83 +1,87 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/inputs/base"
3
3
  require "logstash/namespace"
4
- require "stud/interval"
5
- require "socket" # for Socket.gethostname
6
-
7
- # Perform an LDAP Search
8
- #
9
- # Example:
10
- #
11
- # input {
12
- # LDAPSearch {
13
- # host => "myLDAPServer"
14
- # dn => "myDN"
15
- # password => "myPassword"
16
- # filter => "myldapfilter"
17
- # base => "ou=people,dc=univ,dc=fr"
18
- # attrs => ['myattrubteslist']
19
- # }
20
- # }
21
4
 
22
5
  class LogStash::Inputs::LDAPSearch < LogStash::Inputs::Base
23
- config_name "LDAPSearch"
6
+ config_name "LDAPSearch"
7
+
8
+ # If undefined, Logstash will complain, even if codec is unused.
9
+ default :codec, "plain"
10
+
11
+ # LDAP parameters
12
+ config :host, :validate => :string, :required => true
13
+ config :dn, :validate => :string, :required => true
14
+ config :password, :validate => :password, :required => true
15
+ config :filter, :validate => :string, :required => true
16
+ config :base, :validate => :string, :required => true
17
+ config :port, :validate => :number, :default => 389
18
+ config :usessl, :validate => :boolean, :default => false
19
+ config :attrs, :validate => :array, :default => ['uid']
20
+
21
+ public
22
+ def register
23
+ require 'net/ldap'
24
+ end # def register
24
25
 
25
- # If undefined, Logstash will complain, even if codec is unused.
26
- default :codec, "plain"
26
+ public
27
+ def run(queue)
28
+ begin
29
+ if @usessl == true
30
+ conn = Net::LDAP.new :host => @host,
31
+ :port => @port,
32
+ :encryption => :simple_tls,
33
+ :base => base,
34
+ :auth => {
35
+ :method => :simple,
36
+ :username => @dn,
37
+ :password => @password.value
38
+ }
39
+ else
40
+ conn = Net::LDAP.new :host => @host,
41
+ :port => @port,
42
+ :base => base,
43
+ :auth => {
44
+ :method => :simple,
45
+ :username => @dn,
46
+ :password => @password.value
47
+ }
48
+ end
27
49
 
28
- # LDAP parameters
29
- config :host, :validate => :string, :required => true
30
- config :dn, :validate => :string, :required => true
31
- config :password, :validate => :password, :required => true
32
- config :filter, :validate => :string, :required => true
33
- config :base, :validate => :string, :required => true
34
- config :port, :validate => :number, :default => 389
35
- config :usessl, :validate => :boolean, :default => false
36
- config :attrs, :validate => :array, :default => ['uid']
50
+ # Handling binding exception
51
+ if ! conn.bind
52
+ puts "Connection failed - code: #{conn.get_operation_result.code}: #{conn.get_operation_result.message}"
53
+ end
37
54
 
38
- public
39
- def register
40
- require 'base64'
41
- require 'rubygems'
42
- require 'ldap'
43
- end # def register
55
+ # Instantiating a LDAP filter
56
+ search_filter = Net::LDAP::Filter.from_rfc2254(filter)
44
57
 
45
- public
46
- def run(queue)
47
-
48
- @host = Socket.gethostbyname(@host).first
49
- #attrs = ['uid', 'sn', 'cn', 'eduPersonPrimaryAffiliation']
50
- scope = LDAP::LDAP_SCOPE_SUBTREE #LDAP::LDAP_SCOPE_ONELEVEL
51
- begin
52
- conn = ( @usessl == true ) ? LDAP::SSLConn.new(@host,@port) : LDAP::Conn.new(@host, @port)
53
- conn.bind(@dn, @password.value)
54
- @logger.debug("Executing LDAP search base='#{@base}' filter='#{@filter}'")
55
- conn.search(base, scope, filter, attrs) { |entry|
56
- # print distinguished name
57
- # p entry.dn
58
- event = LogStash::Event.new
59
- decorate(event)
60
- event["host"] = @host
61
- entry.get_attributes.each do |attr|
62
- #values = entry.get_values(attr).first
63
- values = entry.get_values(attr)
64
- values = values.map { |value|
65
- (/[^[:print:]]/ =~ value).nil? ? value : Base64.strict_encode64(value)
66
- }
67
- event[attr] = values
68
- end
69
- #event["attr"] = entry.attrs
70
- queue << event
71
- }
72
- rescue LDAP::Error => ex
73
- @logger.error("Ldap connect failed: #{ex}\n#{ex.backtrace}")
74
- exit
75
- rescue LDAP::ResultError => ex
76
- @logger.error("LDAP search error: #{ex}\n#{ex.backtrace}")
77
- exit
78
- end
79
- # no finished in 2.1, instead stop method is called
80
- # finished
81
- end # def run
58
+ # Lauching LDAP request
59
+ conn.search( :filter => search_filter, :attributes => attrs ) { |entry|
60
+ event = LogStash::Event.new
61
+ decorate(event)
62
+ entry.attribute_names.each { |attr|
63
+ # Changing attribute variable type returned by attribute_name method from Symbol to String
64
+ attr = attr.to_s
65
+ # Suppressing default dn attribute if not wanted
66
+ next if (/^dn$/ =~ attr)
67
+ values = entry[attr]
68
+ # Formatting sAMAccountName to match classic case
69
+ attr = "sAMAccountName" if attr == "samaccountname"
70
+ values = values.map { |value|
71
+ (/[^[:print:]]/ =~ value).nil? ? value : Base64.strict_encode64(value)
72
+ }
73
+ # Populating event
74
+ event.set(attr,values)
75
+ }
76
+ # Adding event and sending to logstash for processing
77
+ queue << event
78
+ }
79
+ #Managing LDAP exception
80
+ rescue Net::LDAP::Error => le
81
+ puts "Got LDAP error: #{le}"
82
+ exit
83
+ end
84
+ # finished
85
+ end # def run
82
86
 
83
87
  end # class LogStash::Inputs::LDAPSearch
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-LDAPSearch'
4
- s.version = '0.1.4'
5
- s.licenses = ['Apache License (2.0)']
6
- s.summary = "logstash input plugin to perform search into ldap."
7
- s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
8
- s.authors = ["Nicolas CAN"]
9
- s.email = 'nicolas.can@univ-lille1.fr'
10
- s.homepage = "https://github.com/SemmLille/logstash-input-LDAPSearch" #"http://www.elastic.co/guide/en/logstash/current/index.html"
11
- s.require_paths = ["lib"]
4
+ s.version = '0.3.0'
5
+ s.licenses = ['Apache-2.0']
6
+ s.summary = 'logstash input plugin to perform search into ldap.'
7
+ s.description = 'This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program'
8
+ s.authors = ['Guillaume Colson', 'Jean-Albert Vescovo', 'Nicolas.Can@univ-lille.fr']
9
+ s.email = 'guillaume.colson@univ-lorraine.fr'
10
+ s.homepage = 'https://github.com/EsupPortail/logstash-input-LDAPSearch' #'http://www.elastic.co/guide/en/logstash/current/index.html'
11
+ s.require_paths = ['lib']
12
12
 
13
13
  # Files
14
14
  s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
@@ -17,19 +17,12 @@ Gem::Specification.new do |s|
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
18
 
19
19
  # Special flag to let us know this is actually a logstash plugin
20
- s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
20
+ s.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'input' }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", '>= 2.0.0', '< 3.0.0'
23
+ s.add_runtime_dependency 'logstash-core-plugin-api', '>= 1.60', '<= 2.99'
24
+ s.add_runtime_dependency 'net-ldap', '~> 0.16'
25
+ s.add_runtime_dependency 'jruby-ldap', '~> 0'
24
26
 
25
- s.add_runtime_dependency 'jruby-ldap'
26
- #s.add_runtime_dependency 'ruby_base64'
27
-
28
- #s.add_runtime_dependency 'logstash-codec-plain'
29
- #s.add_runtime_dependency 'logstash-codec-line'
30
- #s.add_runtime_dependency 'logstash-codec-json'
31
- #s.add_runtime_dependency 'logstash-codec-json_lines'
32
- #s.add_runtime_dependency 'concurrent-ruby'
33
-
34
- s.add_development_dependency 'logstash-devutils'
27
+ s.add_development_dependency 'logstash-devutils', '~> 0'
35
28
  end
metadata CHANGED
@@ -1,69 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-LDAPSearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Nicolas CAN
8
- autorequire:
7
+ - Guillaume Colson
8
+ - Jean-Albert Vescovo
9
+ - Nicolas.Can@univ-lille.fr
10
+ autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
13
+ date: 2020-01-07 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
- name: logstash-core
16
+ name: logstash-core-plugin-api
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '1.60'
22
+ - - "<="
23
+ - !ruby/object:Gem::Version
24
+ version: '2.99'
25
+ type: :runtime
26
+ prerelease: false
15
27
  version_requirements: !ruby/object:Gem::Requirement
16
28
  requirements:
17
- - - '>='
29
+ - - ">="
18
30
  - !ruby/object:Gem::Version
19
- version: 2.0.0
20
- - - <
31
+ version: '1.60'
32
+ - - "<="
21
33
  - !ruby/object:Gem::Version
22
- version: 3.0.0
34
+ version: '2.99'
35
+ - !ruby/object:Gem::Dependency
36
+ name: net-ldap
23
37
  requirement: !ruby/object:Gem::Requirement
24
38
  requirements:
25
- - - '>='
39
+ - - "~>"
26
40
  - !ruby/object:Gem::Version
27
- version: 2.0.0
28
- - - <
29
- - !ruby/object:Gem::Version
30
- version: 3.0.0
31
- prerelease: false
41
+ version: '0.16'
32
42
  type: :runtime
33
- - !ruby/object:Gem::Dependency
34
- name: jruby-ldap
43
+ prerelease: false
35
44
  version_requirements: !ruby/object:Gem::Requirement
36
45
  requirements:
37
- - - '>='
46
+ - - "~>"
38
47
  - !ruby/object:Gem::Version
39
- version: '0'
48
+ version: '0.16'
49
+ - !ruby/object:Gem::Dependency
50
+ name: jruby-ldap
40
51
  requirement: !ruby/object:Gem::Requirement
41
52
  requirements:
42
- - - '>='
53
+ - - "~>"
43
54
  - !ruby/object:Gem::Version
44
55
  version: '0'
45
- prerelease: false
46
56
  type: :runtime
47
- - !ruby/object:Gem::Dependency
48
- name: logstash-devutils
57
+ prerelease: false
49
58
  version_requirements: !ruby/object:Gem::Requirement
50
59
  requirements:
51
- - - '>='
60
+ - - "~>"
52
61
  - !ruby/object:Gem::Version
53
62
  version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: logstash-devutils
54
65
  requirement: !ruby/object:Gem::Requirement
55
66
  requirements:
56
- - - '>='
67
+ - - "~>"
57
68
  - !ruby/object:Gem::Version
58
69
  version: '0'
59
- prerelease: false
60
70
  type: :development
61
- description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
62
- email: nicolas.can@univ-lille1.fr
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ description: This gem is a logstash plugin required to be installed on top of the
78
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
79
+ gem is not a stand-alone program
80
+ email: guillaume.colson@univ-lorraine.fr
63
81
  executables: []
64
82
  extensions: []
65
83
  extra_rdoc_files: []
66
84
  files:
85
+ - CHANGELOG.md
67
86
  - DEVELOPER.md
68
87
  - Gemfile
69
88
  - LICENSE
@@ -71,30 +90,30 @@ files:
71
90
  - lib/logstash/inputs/LDAPSearch.rb
72
91
  - logstash-input-LDAPSearch.gemspec
73
92
  - spec/inputs/LDAPSearch_spec.rb
74
- homepage: https://github.com/SemmLille/logstash-input-LDAPSearch
93
+ homepage: https://github.com/EsupPortail/logstash-input-LDAPSearch
75
94
  licenses:
76
- - Apache License (2.0)
95
+ - Apache-2.0
77
96
  metadata:
78
97
  logstash_plugin: 'true'
79
98
  logstash_group: input
80
- post_install_message:
99
+ post_install_message:
81
100
  rdoc_options: []
82
101
  require_paths:
83
102
  - lib
84
103
  required_ruby_version: !ruby/object:Gem::Requirement
85
104
  requirements:
86
- - - '>='
105
+ - - ">="
87
106
  - !ruby/object:Gem::Version
88
107
  version: '0'
89
108
  required_rubygems_version: !ruby/object:Gem::Requirement
90
109
  requirements:
91
- - - '>='
110
+ - - ">="
92
111
  - !ruby/object:Gem::Version
93
112
  version: '0'
94
113
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.4.5
97
- signing_key:
114
+ rubyforge_project:
115
+ rubygems_version: 2.7.6
116
+ signing_key:
98
117
  specification_version: 4
99
118
  summary: logstash input plugin to perform search into ldap.
100
119
  test_files: