logstash-filter-SNS 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae67c4bb781e3b90395aa9cce87a3135a11faa14
4
+ data.tar.gz: 96502a471ff8995aeb5797d60c52e8859fbc7b42
5
+ SHA512:
6
+ metadata.gz: 28ca3d9a8df7975150a0cdbb702932d18170f5b300243254014ba2146ceba6012f41130ce50180c78490e6356e5f74abc7357cc3b5ce73b056c8b0d9d47717b2
7
+ data.tar.gz: 7b1709ca2cc703afd09a82570994b98fc72bbb4ee1b2a1cbef75e908935b04b8182d2d95910d1d073bb02a7154cabb030b7c6477bd9001dac7fb055170fe603d
File without changes
@@ -0,0 +1,11 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Aaron Mildenstein (untergeek)
6
+ * Pier-Hugues Pellerin (ph)
7
+
8
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
9
+ Logstash, and you aren't on the list above and want to be, please let us know
10
+ and we'll make sure you're here. Contributions from folks like you are what make
11
+ open source awesome.
@@ -0,0 +1,2 @@
1
+ # logstash-filter-example
2
+ Example filter plugin. This should help bootstrap your effort to write your own filter plugin!
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (c) 2012-2018 Elasticsearch <http://www.elastic.co>
2
+ Copyright (c) 2018 Stormshield <https://www.stormshield.com>
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
@@ -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/).
@@ -0,0 +1,94 @@
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
+ This logstash plugin provides support for Stormshield Network Security logs:
15
+ - Split *CPU* into *CPU_Userland*, *CPU_Kernel* and *CPU_Interrupt* keys
16
+ - Develop _Vulnerability manager_ field _PVM_
17
+ - Handle network interface data
18
+
19
+ ## Need Help?
20
+
21
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
22
+
23
+ ## Developing
24
+
25
+ ### 1. Plugin Developement and Testing
26
+
27
+ #### Code
28
+ - To get started, you'll need JRuby with the Bundler gem installed (cf. [wiki](http://netsec.arkoon.net/bin/view/Product/BuildVla1X#5_Builder_les_filtres_SNS_pour_l)).
29
+ - If you work behind a proxy:
30
+ - add the environment variable `export HTTP_PROXY=http://<hostname>:<port>`
31
+ - add the environment variable `export HTTPS_PROXY=http://<hostname>:<port>`
32
+
33
+ - 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).
34
+
35
+ - Install dependencies
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ #### Test
41
+
42
+ - Update your dependencies
43
+
44
+ ```sh
45
+ bundle install
46
+ ```
47
+
48
+ - Run tests
49
+
50
+ ```sh
51
+ bundle exec rspec
52
+ ```
53
+
54
+ ### 2. Running your unpublished Plugin in Logstash
55
+
56
+ #### 2.1 Run in a local Logstash clone
57
+
58
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
59
+ ```ruby
60
+ gem "logstash-filter-SNS", :path => "/your/local/logstash-filter-SNS"
61
+ ```
62
+ - Install plugin
63
+ ```sh
64
+ bin/plugin install --no-verify
65
+ ```
66
+ - Run Logstash with your plugin
67
+ ```sh
68
+ bin/logstash -e 'filter {SNS {}}'
69
+ ```
70
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
71
+
72
+ #### 2.2 Run in an installed Logstash
73
+
74
+ 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:
75
+
76
+ - Build your plugin gem
77
+ ```sh
78
+ gem build logstash-filter-SNS.gemspec
79
+ ```
80
+ - Install the plugin from the Logstash home
81
+ ```sh
82
+ bin/plugin install /your/local/plugin/logstash-filter-SNS.gem
83
+ ```
84
+ - Start Logstash and proceed to test the plugin
85
+
86
+ ## Contributing
87
+
88
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
89
+
90
+ 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.
91
+
92
+ It is more important to the community that you are able to contribute.
93
+
94
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+
5
+ class LogStash::Filters::SNS < LogStash::Filters::Base
6
+
7
+ # Setting the config_name here is required. This is how you
8
+ # configure this filter from your Logstash config.
9
+ #
10
+ # filter {
11
+ # SNS {}
12
+ # }
13
+ #
14
+ config_name "SNS"
15
+
16
+ public
17
+ def register
18
+ # Add instance variables
19
+ end # def register
20
+
21
+ public
22
+ def filter(event)
23
+ #CPU
24
+ if event.include?('CPU')
25
+ values = event.get('CPU').split(',')
26
+ event.remove('CPU')
27
+ event.set('CPU_Userland', values[0].to_i)
28
+ event.set('CPU_Kernel', values[1].to_i)
29
+ event.set('CPU_Interrupt', values[2].to_i)
30
+ end
31
+
32
+ #PVM
33
+ if event.include?('Pvm')
34
+ values = event.get('Pvm').split(',')
35
+ event.remove('Pvm')
36
+ event.set('[Pvm][vuln_total]', values[0].to_i)
37
+ event.set('[Pvm][vuln_remote]', values[1].to_i)
38
+ event.set('[Pvm][vuln_server]', values[2].to_i)
39
+ event.set('[Pvm][vuln_crit]', values[3].to_i)
40
+ event.set('[Pvm][vuln_minor]', values[4].to_i)
41
+ event.set('[Pvm][vul_major]', values[5].to_i)
42
+ event.set('[Pvm][vuln_with_fix]', values[6].to_i)
43
+ event.set('[Pvm][info_total]', values[7].to_i)
44
+ event.set('[Pvm][info_minor]', values[8].to_i)
45
+ event.set('[Pvm][info_major]', values[9].to_i)
46
+ event.set('[Pvm][info_host]', values[10].to_i)
47
+ end
48
+
49
+ #aggXX, ethernetXX, ipsecXX, qidXX, sslvpnXX, vlanXX, wifiXX, wlanXX, wldevXX
50
+ interfaces = event.to_hash.select { |key| key.to_s.match(/^(agg|ethernet|ipsec|qid|sslvpn|vlan|wifi|wlan|wldev)\d*$/i) }.keys
51
+ interfaces.each do |iface|
52
+ values = event.get(iface).split(',')
53
+ event.remove(iface)
54
+ event.set("[#{iface}][name]", values[0])
55
+ event.set("[#{iface}][ingress]", values[1].to_i)
56
+ event.set("[#{iface}][ingress_max]", values[2].to_i)
57
+ event.set("[#{iface}][egress]", values[3].to_i)
58
+ event.set("[#{iface}][egress_max]", values[4].to_i)
59
+ # For SNS > 3.x, interfaces have 7 values
60
+ if values.size > 5
61
+ event.set("[#{iface}][packet_accept]", values[5].to_i)
62
+ event.set("[#{iface}][packet_block]", values[6].to_i)
63
+ end
64
+ end
65
+
66
+ # filter_matched should go in the last line of our successful code
67
+ filter_matched(event)
68
+ end # def filter
69
+ end # class LogStash::Filters::SNS
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-SNS'
3
+ s.version = '1.1.1'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "This filter transforms l_monitor statistics."
6
+ 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"
7
+ s.authors = ["Stormshield"]
8
+ s.email = 'svc@stormshield.eu'
9
+ s.homepage = "https://www.stormshield.eu"
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" => "filter" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency 'logstash-core-plugin-api', '>= 1.60', '<= 2.99'
22
+ s.add_development_dependency "logstash-devutils", "= 1.3.4"
23
+ end
@@ -0,0 +1,103 @@
1
+ require 'logstash/devutils/rspec/spec_helper'
2
+ require "logstash/filters/SNS"
3
+
4
+ describe LogStash::Filters::SNS do
5
+ describe "SNS log analyser" do
6
+ let(:config) do <<-CONFIG
7
+ filter {
8
+ SNS {
9
+ }
10
+ }
11
+ CONFIG
12
+ end
13
+ sample(
14
+ "CPU" => "10,20,30",
15
+ "Agg0" => "in,963446,40909184,2803352,918612032,148119,102",
16
+ "Ethernet0" => "out,30061363,47621456,898553,1508784,293925,1958",
17
+ "ipsec" => "bench,163446,10909184,1803352,118612032",
18
+ "qid4" => "queue,1234,5678,910,1112131415,1617,18",
19
+ "sslvpn1" => "vpn,100,101,102,103",
20
+ "vlan3" => "vlan,200,201,202,203",
21
+ "wifi1" => "PublicAP,300,301,302,303,300004,300005",
22
+ "wlan" => "wlan2,400,401,402,403,400004,400005",
23
+ "wldev0" => "WifiPhy0,500,501,502,503"
24
+ ) do
25
+ expect(subject.get('CPU_Userland')).to eq(10)
26
+ expect(subject.get('CPU_Kernel')).to eq(20)
27
+ expect(subject.get('CPU_Interrupt')).to eq(30)
28
+ expect(subject.get('CPU')).to be_nil
29
+
30
+ expect(subject.get('[Ethernet0][name]')).to eq('out')
31
+ expect(subject.get('[Ethernet0][ingress]')).to eq(30061363)
32
+ expect(subject.get('[Ethernet0][ingress_max]')).to eq(47621456)
33
+ expect(subject.get('[Ethernet0][egress]')).to eq(898553)
34
+ expect(subject.get('[Ethernet0][egress_max]')).to eq(1508784)
35
+ expect(subject.get('[Ethernet0][packet_accept]')).to eq(293925)
36
+ expect(subject.get('[Ethernet0][packet_block]')).to eq(1958)
37
+
38
+ expect(subject.get('[ipsec][name]')).to eq('bench')
39
+ expect(subject.get('[ipsec][ingress]')).to eq(163446)
40
+ expect(subject.get('[ipsec][ingress_max]')).to eq(10909184)
41
+ expect(subject.get('[ipsec][egress]')).to eq(1803352)
42
+ expect(subject.get('[ipsec][egress_max]')).to eq(118612032)
43
+ expect(subject.get('ipsec')).not_to have_key('packet_accept')
44
+ expect(subject.get('ipsec')).not_to have_key('packet_block')
45
+
46
+ expect(subject.get('[Agg0][name]')).to eq('in')
47
+ expect(subject.get('[Agg0][ingress]')).to eq(963446)
48
+ expect(subject.get('[Agg0][ingress_max]')).to eq(40909184)
49
+ expect(subject.get('[Agg0][egress]')).to eq(2803352)
50
+ expect(subject.get('[Agg0][egress_max]')).to eq(918612032)
51
+ expect(subject.get('[Agg0][packet_accept]')).to eq(148119)
52
+ expect(subject.get('[Agg0][packet_block]')).to eq(102)
53
+
54
+ expect(subject.get('[qid4][name]')).to eq('queue')
55
+ expect(subject.get('[qid4][ingress]')).to eq(1234)
56
+ expect(subject.get('[qid4][ingress_max]')).to eq(5678)
57
+ expect(subject.get('[qid4][egress]')).to eq(910)
58
+ expect(subject.get('[qid4][egress_max]')).to eq(1112131415)
59
+ expect(subject.get('[qid4][packet_accept]')).to eq(1617)
60
+ expect(subject.get('[qid4][packet_block]')).to eq(18)
61
+
62
+ expect(subject.get('[sslvpn1][name]')).to eq('vpn')
63
+ expect(subject.get('[sslvpn1][ingress]')).to eq(100)
64
+ expect(subject.get('[sslvpn1][ingress_max]')).to eq(101)
65
+ expect(subject.get('[sslvpn1][egress]')).to eq(102)
66
+ expect(subject.get('[sslvpn1][egress_max]')).to eq(103)
67
+ expect(subject.get('sslvpn1')).not_to have_key('packet_accept')
68
+ expect(subject.get('sslvpn1')).not_to have_key('packet_block')
69
+
70
+ expect(subject.get('[vlan3][name]')).to eq('vlan')
71
+ expect(subject.get('[vlan3][ingress]')).to eq(200)
72
+ expect(subject.get('[vlan3][ingress_max]')).to eq(201)
73
+ expect(subject.get('[vlan3][egress]')).to eq(202)
74
+ expect(subject.get('[vlan3][egress_max]')).to eq(203)
75
+ expect(subject.get('vlan3')).not_to have_key('packet_accept')
76
+ expect(subject.get('vlan3')).not_to have_key('packet_block')
77
+
78
+ expect(subject.get('[wifi1][name]')).to eq('PublicAP')
79
+ expect(subject.get('[wifi1][ingress]')).to eq(300)
80
+ expect(subject.get('[wifi1][ingress_max]')).to eq(301)
81
+ expect(subject.get('[wifi1][egress]')).to eq(302)
82
+ expect(subject.get('[wifi1][egress_max]')).to eq(303)
83
+ expect(subject.get('[wifi1][packet_accept]')).to eq(300004)
84
+ expect(subject.get('[wifi1][packet_block]')).to eq(300005)
85
+
86
+ expect(subject.get('[wlan][name]')).to eq('wlan2')
87
+ expect(subject.get('[wlan][ingress]')).to eq(400)
88
+ expect(subject.get('[wlan][ingress_max]')).to eq(401)
89
+ expect(subject.get('[wlan][egress]')).to eq(402)
90
+ expect(subject.get('[wlan][egress_max]')).to eq(403)
91
+ expect(subject.get('[wlan][packet_accept]')).to eq(400004)
92
+ expect(subject.get('[wlan][packet_block]')).to eq(400005)
93
+
94
+ expect(subject.get('[wldev0][name]')).to eq('WifiPhy0')
95
+ expect(subject.get('[wldev0][ingress]')).to eq(500)
96
+ expect(subject.get('[wldev0][ingress_max]')).to eq(501)
97
+ expect(subject.get('[wldev0][egress]')).to eq(502)
98
+ expect(subject.get('[wldev0][egress_max]')).to eq(503)
99
+ expect(subject.get('wldev0')).not_to have_key('packet_accept')
100
+ expect(subject.get('wldev0')).not_to have_key('packet_block')
101
+ end
102
+ end
103
+ end
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-SNS
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Stormshield
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-11-20 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: 1.3.4
39
+ name: logstash-devutils
40
+ prerelease: false
41
+ type: :development
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '='
45
+ - !ruby/object:Gem::Version
46
+ version: 1.3.4
47
+ 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
48
+ email: svc@stormshield.eu
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - CHANGELOG.md
54
+ - CONTRIBUTORS
55
+ - DEVELOPER.md
56
+ - Gemfile
57
+ - LICENSE
58
+ - NOTICE.TXT
59
+ - README.md
60
+ - lib/logstash/filters/SNS.rb
61
+ - logstash-filter-SNS.gemspec
62
+ - spec/filters/SNS_spec.rb
63
+ - spec/spec_helper.rb
64
+ homepage: https://www.stormshield.eu
65
+ licenses:
66
+ - Apache License (2.0)
67
+ metadata:
68
+ logstash_plugin: 'true'
69
+ logstash_group: filter
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.4.8
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: This filter transforms l_monitor statistics.
90
+ test_files:
91
+ - spec/filters/SNS_spec.rb
92
+ - spec/spec_helper.rb