logstash-input-netldap 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: be202a873aeba9882eb0d10ba419644304528c3b8be77f07ce3867ad84c5912b
4
+ data.tar.gz: 43b4e9f9209cc1b59be77a9dd18419152fa7311d6ba58067d0699dede2dc18a8
5
+ SHA512:
6
+ metadata.gz: c6a2d2c6e7e2038f6f700608d2ee6cee669d9cba52a9850a402b87e2fdf56494e99cd71b25402e03512e125742fb80150c87a4bad538f4b895b66bf36cfc9774
7
+ data.tar.gz: eaf733f78b3eda3bc7072c25cb38cbb5ed4ea813b0baaa820adebc16628e89f96f416d8128e4c82a72dc0ae486f7e768f027212304db992866d2db61ae9aa775
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 1.0.0
2
+
3
+ * First release of the plugin
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2018 damterroba
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/NOTICE.TXT ADDED
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
data/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # NetLdap Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/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 build documentation for this plugin. We provide a template file, index.asciidoc, where you can add documentation. The contents of this file will be converted into html and then placed with other plugin documentation in a [central location](http://www.elastic.co/guide/en/logstash/current/).
10
+
11
+ * For formatting config examples, you can use the asciidoc `[source,json]` directive
12
+ * For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
+ * Information for this plugin configuration can be found [here](docs/index.asciidoc)
14
+
15
+ ## Developing
16
+
17
+ ### 1. Plugin Developement and Testing
18
+
19
+ #### Code
20
+
21
+ * To get started, you'll need JRuby with the Bundler gem installed.
22
+
23
+ * 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).
24
+
25
+ * Install dependencies
26
+
27
+ ```sh
28
+ bundle install
29
+ ```
30
+
31
+ #### Test
32
+
33
+ * Update your dependencies
34
+
35
+ ```sh
36
+ bundle install
37
+ ```
38
+
39
+ ### 2. Running your unpublished Plugin in Logstash
40
+
41
+ #### 2.1 Run in a local Logstash clone
42
+
43
+ * Edit Logstash `Gemfile` and add the local plugin path, for example:
44
+
45
+ ```ruby
46
+ gem "logstash-input-netldap", :path => "/your/local/logstash-input-netldap"
47
+ ```
48
+
49
+ * Install plugin
50
+
51
+ ```sh
52
+ # Logstash 2.3 and higher
53
+ bin/logstash-plugin install --no-verify
54
+
55
+ # Prior to Logstash 2.3
56
+ bin/plugin install --no-verify
57
+ ```
58
+
59
+ * Run Logstash with your plugin
60
+
61
+ ```sh
62
+ bin/logstash -e 'filter {netldap {[...]}}'
63
+ ```
64
+
65
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
66
+
67
+ #### 2.2 Run in an installed Logstash
68
+
69
+ 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:
70
+
71
+ * Build your plugin gem
72
+
73
+ ```sh
74
+ gem build logstash-input-netldap.gemspec
75
+ ```
76
+
77
+ * Install the plugin from the Logstash home
78
+
79
+ ```sh
80
+ # Logstash 2.3 and higher
81
+ bin/logstash-plugin install --no-verify
82
+
83
+ # Prior to Logstash 2.3
84
+ bin/plugin install --no-verify
85
+ ```
86
+
87
+ * Start Logstash and proceed to test the plugin
88
+
89
+ ## Contributing
90
+
91
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
92
+
93
+ 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.
94
+
95
+ It is more important to the community that you are able to contribute.
96
+
97
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,105 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "stud/interval"
5
+ require "socket" # for Socket.gethostname
6
+ require "base64"
7
+ require "rubygems"
8
+ require "net/ldap"
9
+
10
+ # Performs a LDAP search using net-ldap.
11
+ #
12
+ # Usage :
13
+ #
14
+ # input {
15
+ # ldap{
16
+ # host => "myLdapHost"
17
+ # port => 389
18
+ # dn => "myDn"
19
+ # password => "myPassword"
20
+ # base => "ou=people,dc=gouv,dc=fr"
21
+ # filter => [{field=>"field1" value=>"value1"}, {field=>"field2" value=>"value2"}
22
+ # attrs => ['uid', 'mail', 'sn', 'cn']
23
+ # }
24
+ # }
25
+ #
26
+
27
+ class LogStash::Inputs::NetLdap < LogStash::Inputs::Base
28
+ config_name "netldap"
29
+
30
+ # If undefined, Logstash will complain, even if codec is unused.
31
+ default :codec, "plain"
32
+
33
+ # The ldap host to perform the search
34
+ # Can be ip or hostname
35
+ config :ldap_host, :validate => :string, :required => true
36
+
37
+ # The ldap port to connect on, 389 by default
38
+ config :port, :validate => :number, :default => 389, :required => true
39
+
40
+ # Specifies if the bind is anonymous
41
+ # If not, you'll need to set the user bind DN and password
42
+ config :anonymous, :validate => :boolean, :default => false
43
+
44
+ # User to bind an the ldap server
45
+ config :dn, :validate => :string
46
+
47
+ # Configure the password
48
+ config :password, :validate => :password
49
+
50
+ # LDAP base DN to search in
51
+ config :base, :validate => :string, :required => true
52
+
53
+ # Filters of the ldap search, an array of hashes
54
+ config :filters, :validate => :array, :default => [{ "field" => "objectclass", "value" => "inetorgperson" }]
55
+
56
+ # Specify the attributes you wanna get for each entry
57
+ config :attrs, :validate => :array, :default => ["uid", "mail"]
58
+
59
+ public
60
+ def register
61
+ @host = Socket.gethostname
62
+
63
+ if @anonymous
64
+ auth = { :method => :anonymous}
65
+ else
66
+ auth = {
67
+ :method => :simple,
68
+ :username => @dn,
69
+ :password => @password.value
70
+ }
71
+ end
72
+ @conn = Net::LDAP.new :host => @ldap_host,
73
+ :port => @port,
74
+ :auth => auth
75
+ end
76
+
77
+ def run(queue)
78
+ # Filters def
79
+ finalFilter = "" # need to initialize this outside the each
80
+ @filters.each.with_index do |hashFilter, index|
81
+ tmpFilter = Net::LDAP::Filter.eq(hashFilter['field'], hashFilter['value'])
82
+ case index
83
+ when 0
84
+ finalFilter = tmpFilter
85
+ else
86
+ finalFilter = Net::LDAP::Filter.join(finalFilter, tmpFilter)
87
+ end
88
+ end
89
+
90
+ #filter = Net::LDAP::Filter.eq("objectclass", "inetorgperson")
91
+ @conn.search(:base => @base, :filter => finalFilter, :attributes => @attrs) do |entry|
92
+ # event = LogStash::Event::new
93
+ event = LogStash::Event.new()
94
+ decorate(event)
95
+ entry.each do |attribute, value|
96
+ if value.count() > 1
97
+ event.set("#{attribute}", value)
98
+ else
99
+ event.set("#{attribute}", value.first)
100
+ end
101
+ end
102
+ queue << event
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-input-netldap'
3
+ s.version = '1.0.1'
4
+ s.licenses = ['Apache-2.0']
5
+ s.summary = "Logstash input plugin that performs an LDAP search."
6
+ 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"
7
+ s.authors = ["damterroba"]
8
+ s.email = 'mathieu.terroba@gmail.com'
9
+ s.homepage = "https://github.com/damterroba/logstash-input-netldap/"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
22
+ s.add_runtime_dependency 'logstash-codec-plain'
23
+ s.add_runtime_dependency 'stud', '>= 0.0.22'
24
+ s.add_runtime_dependency 'net-ldap'
25
+ s.add_development_dependency 'logstash-devutils'
26
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/inputs/ldap"
4
+
5
+ describe LogStash::Inputs::NetLdap do
6
+
7
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-netldap
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - damterroba
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '1.60'
19
+ - - "<="
20
+ - !ruby/object:Gem::Version
21
+ version: '2.99'
22
+ name: logstash-core-plugin-api
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.60'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: '2.99'
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: logstash-codec-plain
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.0.22
53
+ name: stud
54
+ prerelease: false
55
+ type: :runtime
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.0.22
61
+ - !ruby/object:Gem::Dependency
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ name: net-ldap
68
+ prerelease: false
69
+ type: :runtime
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ name: logstash-devutils
82
+ prerelease: false
83
+ type: :development
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description: This gem is a Logstash plugin required to be installed on top of the
90
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
91
+ gem is not a stand-alone program
92
+ email: mathieu.terroba@gmail.com
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - CHANGELOG.md
98
+ - Gemfile
99
+ - LICENSE
100
+ - NOTICE.TXT
101
+ - README.md
102
+ - lib/logstash/inputs/netldap.rb
103
+ - logstash-input-netldap.gemspec
104
+ - spec/inputs/netldap_spec.rb
105
+ homepage: https://github.com/damterroba/logstash-input-netldap/
106
+ licenses:
107
+ - Apache-2.0
108
+ metadata:
109
+ logstash_plugin: 'true'
110
+ logstash_group: input
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.6.11
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Logstash input plugin that performs an LDAP search.
131
+ test_files:
132
+ - spec/inputs/netldap_spec.rb