logstash-input-LDAPSearch 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +3 -0
- data/LICENSE +13 -0
- data/README.md +98 -0
- data/Rakefile +1 -0
- data/lib/logstash/inputs/LDAPSearch.rb +79 -0
- data/logstash-input-LDAPSearch.gemspec +35 -0
- data/spec/inputs/LDAPSearch_spec.rb +1 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db3a194fc8eb70cfc593b9e0886ae8974dbd4754
|
4
|
+
data.tar.gz: cb02f1997099adbb1e9f436b2314b9a0386c5601
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdcfb01dc37200f235569b984ab68ec4ce2f2e16ee3995597cbed9cb59c339f5510aab2bf19a39b0c5752ce7ca9fd645ed1ddcbc635cfd9debfdaca682d43b96
|
7
|
+
data.tar.gz: 7baebc7edf3b43f5c5ca895f9ff90acbe387a049e9650a1a8b88e57b4de7659cbe438b3967d7f0150f918e28314e103d48c9578cf05ea550273fffd7421acbe2
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
|
4
|
+
|
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
|
+
|
7
|
+
## Documentation
|
8
|
+
|
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/).
|
10
|
+
|
11
|
+
- 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
|
13
|
+
|
14
|
+
## Need Help?
|
15
|
+
|
16
|
+
Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
|
17
|
+
|
18
|
+
## Developing
|
19
|
+
|
20
|
+
### 1. Plugin Developement and Testing
|
21
|
+
|
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
|
+
#### Code
|
35
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
36
|
+
|
37
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
38
|
+
|
39
|
+
- Install dependencies
|
40
|
+
```sh
|
41
|
+
bundle install
|
42
|
+
```
|
43
|
+
|
44
|
+
#### Test
|
45
|
+
|
46
|
+
- Update your dependencies
|
47
|
+
|
48
|
+
```sh
|
49
|
+
bundle install
|
50
|
+
```
|
51
|
+
|
52
|
+
- Run tests
|
53
|
+
|
54
|
+
```sh
|
55
|
+
bundle exec rspec
|
56
|
+
```
|
57
|
+
|
58
|
+
### 2. Running your unpublished Plugin in Logstash
|
59
|
+
|
60
|
+
#### 2.1 Run in a local Logstash clone
|
61
|
+
|
62
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
63
|
+
```ruby
|
64
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
65
|
+
```
|
66
|
+
- Install plugin
|
67
|
+
```sh
|
68
|
+
bin/plugin install --no-verify
|
69
|
+
```
|
70
|
+
- Run Logstash with your plugin
|
71
|
+
```sh
|
72
|
+
bin/logstash -e 'filter {awesome {}}'
|
73
|
+
```
|
74
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
75
|
+
|
76
|
+
#### 2.2 Run in an installed Logstash
|
77
|
+
|
78
|
+
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
79
|
+
|
80
|
+
- Build your plugin gem
|
81
|
+
```sh
|
82
|
+
gem build logstash-filter-awesome.gemspec
|
83
|
+
```
|
84
|
+
- Install the plugin from the Logstash home
|
85
|
+
```sh
|
86
|
+
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
|
87
|
+
```
|
88
|
+
- Start Logstash and proceed to test the plugin
|
89
|
+
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
93
|
+
|
94
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
95
|
+
|
96
|
+
It is more important to the community that you are able to contribute.
|
97
|
+
|
98
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rake"
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/inputs/base"
|
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
|
+
|
22
|
+
class LogStash::Inputs::LDAPSearch < LogStash::Inputs::Base
|
23
|
+
config_name "LDAPSearch"
|
24
|
+
|
25
|
+
# If undefined, Logstash will complain, even if codec is unused.
|
26
|
+
default :codec, "plain"
|
27
|
+
|
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 :attrs, :validate => :array, :default => ['uid']
|
36
|
+
|
37
|
+
public
|
38
|
+
def register
|
39
|
+
require 'base64'
|
40
|
+
require 'rubygems'
|
41
|
+
require 'ldap'
|
42
|
+
end # def register
|
43
|
+
|
44
|
+
public
|
45
|
+
def run(queue)
|
46
|
+
|
47
|
+
@host = Socket.gethostbyname(@host).first
|
48
|
+
#attrs = ['uid', 'sn', 'cn', 'eduPersonPrimaryAffiliation']
|
49
|
+
scope = LDAP::LDAP_SCOPE_SUBTREE #LDAP::LDAP_SCOPE_ONELEVEL
|
50
|
+
conn = LDAP::Conn.new(@host, @port)
|
51
|
+
conn.bind(@dn, @password.value)
|
52
|
+
begin
|
53
|
+
@logger.debug("Executing LDAP search base='#{@base}' filter='#{@filter}'")
|
54
|
+
conn.search(base, scope, filter, attrs) { |entry|
|
55
|
+
# print distinguished name
|
56
|
+
# p entry.dn
|
57
|
+
event = LogStash::Event.new
|
58
|
+
decorate(event)
|
59
|
+
event["host"] = @host
|
60
|
+
entry.get_attributes.each do |attr|
|
61
|
+
#values = entry.get_values(attr).first
|
62
|
+
values = entry.get_values(attr)
|
63
|
+
values = values.map { |value|
|
64
|
+
(/[^[:print:]]/ =~ value).nil? ? value : Base64.strict_encode64(value)
|
65
|
+
}
|
66
|
+
event[attr] = values
|
67
|
+
end
|
68
|
+
#event["attr"] = entry.attrs
|
69
|
+
queue << event
|
70
|
+
|
71
|
+
}
|
72
|
+
rescue LDAP::ResultError => ex
|
73
|
+
@logger.error("LDAP search error: #{ex}\n#{ex.backtrace}")
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
finished
|
77
|
+
end # def run
|
78
|
+
|
79
|
+
end # class LogStash::Inputs::LDAPSearch
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
|
3
|
+
s.name = 'logstash-input-LDAPSearch'
|
4
|
+
s.version = '0.1.0'
|
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"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
|
15
|
+
|
16
|
+
# Tests
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
|
19
|
+
# Special flag to let us know this is actually a logstash plugin
|
20
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
|
21
|
+
|
22
|
+
# Gem dependencies
|
23
|
+
s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
|
24
|
+
|
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'
|
35
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-input-LDAPSearch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicolas CAN
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logstash-core
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.4.0
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.0
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.4.0
|
28
|
+
- - <
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.0.0
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: jruby-ldap
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
prerelease: false
|
46
|
+
type: :runtime
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: logstash-devutils
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
prerelease: false
|
60
|
+
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
|
63
|
+
executables: []
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- DEVELOPER.md
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- lib/logstash/inputs/LDAPSearch.rb
|
74
|
+
- logstash-input-LDAPSearch.gemspec
|
75
|
+
- spec/inputs/LDAPSearch_spec.rb
|
76
|
+
homepage: https://github.com/SemmLille/logstash-input-LDAPSearch
|
77
|
+
licenses:
|
78
|
+
- Apache License (2.0)
|
79
|
+
metadata:
|
80
|
+
logstash_plugin: 'true'
|
81
|
+
logstash_group: input
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.4.5
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: logstash input plugin to perform search into ldap.
|
102
|
+
test_files:
|
103
|
+
- spec/inputs/LDAPSearch_spec.rb
|