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 +5 -5
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -4
- data/README.md +15 -19
- data/lib/logstash/inputs/LDAPSearch.rb +76 -72
- data/logstash-input-LDAPSearch.gemspec +13 -20
- metadata +55 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4535f5574a5e7b80e42a5c0f5349d9d17a41f958ab43da4faffc8413059c0c3e
|
4
|
+
data.tar.gz: 6a70d5ebc8fe0a0287189fb79898f85a49adba0e999077059b54656e3b5402aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f3f6d58bb509a7509478a7e91255593bf950f325aad4714b4fdc8096f3f761c5d9276fcf260e6a0cf182a31ffdd9de02d5a081f8eb231934f8fd91debd69b17
|
7
|
+
data.tar.gz: e0c58e63cb9afcc5d325192a548caa940b1469930e397f0e412f6a9ec5362e63030c02607ed3ea85988157c8ad78a01f714548751ae0e9eb3a63f8d2e12d2fc0
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
|
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/
|
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.
|
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/
|
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
|
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/
|
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
|
-
|
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
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
39
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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.
|
5
|
-
s.licenses = ['Apache
|
6
|
-
s.summary =
|
7
|
-
s.description =
|
8
|
-
s.authors = [
|
9
|
-
s.email = '
|
10
|
-
s.homepage =
|
11
|
-
s.require_paths = [
|
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 = {
|
20
|
+
s.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'input' }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency
|
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.
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
|
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:
|
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:
|
20
|
-
- -
|
31
|
+
version: '1.60'
|
32
|
+
- - "<="
|
21
33
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
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:
|
28
|
-
- - <
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: 3.0.0
|
31
|
-
prerelease: false
|
41
|
+
version: '0.16'
|
32
42
|
type: :runtime
|
33
|
-
|
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
|
-
|
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
|
-
|
62
|
-
|
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/
|
93
|
+
homepage: https://github.com/EsupPortail/logstash-input-LDAPSearch
|
75
94
|
licenses:
|
76
|
-
- Apache
|
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.
|
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:
|