logstash-filter-opnsensefilter 1.0.0

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: ddacf084f2d95af3787d44e004cc17cd62466e9e
4
+ data.tar.gz: db7311286a35778233dff4a53f66555d615106a9
5
+ SHA512:
6
+ metadata.gz: 83831bf88377f3bf20eb3e2d1142360749c6464031bd076c69509f72f9eb44d82231e7f5a38b5225c98db3bd8067635fa52da9af8b1f1b6d32a08e1bce8028ba
7
+ data.tar.gz: 6b1aed38c70851ac507231430164c31d9f4c21dc790255ff3c2ae45af5d555d50483e1eea788893bd60a617775d5c9c6a0519c268cf14bbce2de00e0b138daeb
@@ -0,0 +1,5 @@
1
+ The following is a list of people who have contributed code to this plugin.
2
+
3
+ Contributors:
4
+ * Fabian Franz
5
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 2017 Fabian Franz
2
+
3
+ Redistribution and use in source and binary forms, with or without modification,
4
+ are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice,
7
+ this list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
21
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
22
+ OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+
5
+ class LogStash::Filters::Opnsensefilter < LogStash::Filters::Base
6
+
7
+ config_name "opnsensefilter"
8
+
9
+ # Replace the message with this value.
10
+ config :prefix, :validate => :string, :default => ''
11
+ config :field_name, :validate => :string, :default => 'message'
12
+
13
+
14
+ public
15
+ def register
16
+ # Add instance variables
17
+ end # def register
18
+
19
+ public
20
+ def filter(event)
21
+
22
+ if @field_name
23
+ data = event.get(@field_name).split(",")
24
+ # meta
25
+ event.set("#{@prefix}rule", data[0].to_i)
26
+ event.set("#{@prefix}subrule", data[3].to_i)
27
+ event.set("#{@prefix}input_interface", data[4])
28
+ event.set("#{@prefix}reason", data[5])
29
+ event.set("#{@prefix}action", data[6])
30
+ event.set("#{@prefix}direction_of_traffic", data[7])
31
+ event.set("#{@prefix}ip_version", data[8].to_i)
32
+ if data[8].to_i == 4
33
+ # IPv4
34
+ ip_proto = true
35
+ proto_start = 20
36
+ protocol = data[16]
37
+ event.set("#{@prefix}tos", data[9].to_i(16))
38
+ event.set("#{@prefix}ecn", data[10])
39
+ event.set("#{@prefix}hop_limit", data[11].to_i)
40
+ event.set("#{@prefix}aid", data[12].to_i)
41
+ event.set("#{@prefix}myoffset", data[13].to_i)
42
+ event.set("#{@prefix}flags", data[14])
43
+ event.set("#{@prefix}protocol_id", data[15].to_i)
44
+ event.set("#{@prefix}protocol", data[16])
45
+ event.set("#{@prefix}length", data[17].to_i)
46
+ event.set("#{@prefix}source", data[18])
47
+ event.set("#{@prefix}destination", data[19])
48
+ elsif data[8].to_i == 6
49
+ # IPv6
50
+ ip_proto = true
51
+ proto_start = 17
52
+ protocol = data[12]
53
+ event.set("#{@prefix}klass", data[9].to_i(16))
54
+ event.set("#{@prefix}flow_label", data[10].to_i(16))
55
+ event.set("#{@prefix}hop_limit", data[11].to_i)
56
+ event.set("#{@prefix}protocol", data[12])
57
+ event.set("#{@prefix}protocol_id", data[13].to_i)
58
+ event.set("#{@prefix}length", data[14].to_i)
59
+ event.set("#{@prefix}source", data[15])
60
+ event.set("#{@prefix}destination", data[16])
61
+ end
62
+ if ip_proto
63
+ if protocol == "tcp" || protocol == "udp"
64
+ event.set("#{@prefix}spt", data[proto_start].to_i)
65
+ event.set("#{@prefix}dpt", data[proto_start + 1].to_i)
66
+ event.set("#{@prefix}length", data[proto_start + 2].to_i)
67
+ end
68
+ if protocol == "tcp"
69
+ event.set("#{@prefix}tcp_flags", data[proto_start + 3])
70
+ event.set("#{@prefix}sequence_number", data[proto_start + 4])
71
+ event.set("#{@prefix}ack_number", data[proto_start + 5].to_i)
72
+ event.set("#{@prefix}window", data[proto_start + 6].to_i)
73
+ event.set("#{@prefix}urgent_pointer", data[proto_start + 7])
74
+ event.set("#{@prefix}options", data[proto_start + 8])
75
+ entry[:protocol] = proto_data
76
+ end
77
+ end
78
+ end
79
+
80
+ filter_matched(event)
81
+ end # def filter
82
+ end # class LogStash::Filters::Opnsensefilter
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-opnsensefilter'
3
+ s.version = '1.0.0'
4
+ s.licenses = ['BSD 2 Clause']
5
+ s.summary = 'Convert CSV output of the filter of OPNsense to reasonable data.'
6
+ s.homepage = 'https://github.com/fabianfrz'
7
+ s.authors = ['Fabian Franz']
8
+ s.email = 'franz.fabian.94@gmail.com'
9
+ s.require_paths = ['lib']
10
+
11
+ # Files
12
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
13
+ # Tests
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+
16
+ # Special flag to let us know this is actually a logstash plugin
17
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
18
+
19
+ # Gem dependencies
20
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
21
+ s.add_development_dependency 'logstash-devutils'
22
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ require_relative '../spec_helper'
3
+ require "logstash/filters/opnsensefilter"
4
+
5
+ describe LogStash::Filters::Opnsensefilter do
6
+ end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-opnsensefilter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Fabian Franz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: logstash-devutils
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email: franz.fabian.94@gmail.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - CONTRIBUTORS
48
+ - Gemfile
49
+ - LICENSE
50
+ - lib/logstash/filters/opnsensefilter.rb
51
+ - logstash-filter-opnsensefilter.gemspec
52
+ - spec/filters/opnsensefilter_spec.rb
53
+ - spec/spec_helper.rb
54
+ homepage: https://github.com/fabianfrz
55
+ licenses:
56
+ - BSD 2 Clause
57
+ metadata:
58
+ logstash_plugin: 'true'
59
+ logstash_group: filter
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.6.11
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Convert CSV output of the filter of OPNsense to reasonable data.
80
+ test_files:
81
+ - spec/filters/opnsensefilter_spec.rb
82
+ - spec/spec_helper.rb