logstash-filter-virustotalthree 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 26b5bfd160fad4298cf95b057ef15b677cb3d3ef32c42c7d3dd5eccc4eca0220
4
+ data.tar.gz: 50ad467bd9c993e30b3c5d813ccc1cc76fd07ce60fb52d037b9e15a2a503618b
5
+ SHA512:
6
+ metadata.gz: ad6db58efa5a54b3ac9f97c7112aa1420c5a4523db5499ac6f6d85da4a1a4c0c63910700cbadfd5e4993a540d00cb6ea9e5328fc5fd2207abc9fe2e4706b581b
7
+ data.tar.gz: b8c345eda08b1fec46dfe4519195895ab5786d7a94da285d20873a51ff4da4797d744a44a5874a5718e125fbeceef1d708cba30b6f6e837491c20037ae995ebf
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.1.0
2
+ - Plugin created with the logstash plugin generator
data/CONTRIBUTORS ADDED
@@ -0,0 +1,10 @@
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
+ * -
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
data/DEVELOPER.md ADDED
@@ -0,0 +1,2 @@
1
+ # logstash-filter-virustotalthree
2
+ Example filter plugin. This should help bootstrap your effort to write your own filter plugin!
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ gem 'virustotalx', '1.2.0'
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # Usage
2
+
3
+ * [Youtube Video](https://www.youtube.com/watch?v=PWsU4yaxuCA)
4
+
5
+ # Logstash Plugin
6
+
7
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
8
+
9
+ 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.
10
+
11
+ ## Documentation
12
+
13
+ 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/).
14
+
15
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
16
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
17
+
18
+ ## Need Help?
19
+
20
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
21
+
22
+ ## Developing
23
+
24
+ ### 1. Plugin Developement and Testing
25
+
26
+ #### Code
27
+ - To get started, you'll need JRuby with the Bundler gem installed.
28
+
29
+ - 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).
30
+
31
+ - Install dependencies
32
+ ```sh
33
+ bundle install
34
+ ```
35
+
36
+ #### Test
37
+
38
+ - Update your dependencies
39
+
40
+ ```sh
41
+ bundle install
42
+ ```
43
+
44
+ - Run tests
45
+
46
+ ```sh
47
+ bundle exec rspec
48
+ ```
49
+
50
+ ### 2. Running your unpublished Plugin in Logstash
51
+
52
+ #### 2.1 Run in a local Logstash clone
53
+
54
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
55
+ ```ruby
56
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
57
+ ```
58
+ - Install plugin
59
+ ```sh
60
+ bin/logstash-plugin install --no-verify
61
+ ```
62
+ - Run Logstash with your plugin
63
+ ```sh
64
+ bin/logstash -e 'filter {awesome {}}'
65
+ ```
66
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
67
+
68
+ #### 2.2 Run in an installed Logstash
69
+
70
+ 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:
71
+
72
+ - Build your plugin gem
73
+ ```sh
74
+ gem build logstash-filter-awesome.gemspec
75
+ ```
76
+ - Install the plugin from the Logstash home
77
+ ```sh
78
+ bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
79
+ ```
80
+ - Start Logstash and proceed to test the plugin
81
+
82
+ ## Contributing
83
+
84
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
85
+
86
+ 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.
87
+
88
+ It is more important to the community that you are able to contribute.
89
+
90
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "virustotalx"
4
+
5
+ # This filter will replace the contents of the default
6
+ # message field with whatever you specify in the configuration.
7
+ #
8
+ # It is only intended to be used as an .
9
+ class LogStash::Filters::Virustotalthree < LogStash::Filters::Base
10
+
11
+ # Setting the config_name here is required. This is how you
12
+ # configure this filter from your Logstash config.
13
+ #
14
+ # filter {
15
+ # {
16
+ # message => "My message..."
17
+ # }
18
+ # }
19
+ #
20
+ config_name "virustotalthree"
21
+
22
+ # Your VirusTotal API Key
23
+ config :apikey, :validate => :string, :required => true
24
+
25
+ # For filed containing the item to lookup. This can point to a field ontaining a File Hash or URL
26
+ config :field, :validate => :string, :required => true
27
+
28
+ # Lookup type
29
+ config :lookup_type, :validate => :string, :required => true
30
+
31
+ # Where you want the data to be placed
32
+ config :target, :validate => :string, :default => "virustotalthree"
33
+
34
+ public
35
+ def register
36
+ # Add instance variables
37
+ end # def register
38
+
39
+ public
40
+ def filter(event)
41
+ begin
42
+ @logger.warn("LSFVTL: ", :apikey => @apikey)
43
+ # when given nothing, it tries to load your API key from ENV["VIRUSTOTAL_API_KEY"]
44
+ api = VirusTotal::API.new(key: @apikey)
45
+ if @lookup_type == "hash"
46
+ vt_report = api.file.get(event.get(@field))
47
+ elsif @lookup_type == "domain"
48
+ vt_report = api.domain.get(event.get(@field))
49
+ elsif @lookup_type == "url"
50
+ vt_report = api.url.get(event.get(@field))
51
+ elsif @lookup_type == "ip"
52
+ vt_report = api.ip_address.get(event.get(@field))
53
+ end
54
+ event.set(@target, vt_report)
55
+ # filter_matched should go in the last line of our successful code
56
+ filter_matched(event)
57
+ rescue => e
58
+ @logger.warn("Error getting virus total lookup", :field => event.get(@field), :exception => e)
59
+ end
60
+ end # def filter
61
+ end # class LogStash::Filters::Virustotalthree
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ require_relative '../spec_helper'
3
+ require "logstash/filters/virustotalthree"
4
+
5
+ describe LogStash::Filters::Virustotalthree do
6
+ describe "Set to Hello World" do
7
+ let(:config) do <<-CONFIG
8
+ filter {
9
+ virustotalthree {
10
+ message => "Hello World"
11
+ }
12
+ }
13
+ CONFIG
14
+ end
15
+
16
+ sample("message" => "some text") do
17
+ expect(subject).to include("message")
18
+ expect(subject.get('message')).to eq('Hello World')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ require "logstash/devutils/rspec/spec_helper"
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-virustotalthree'
3
+ s.version = '0.1.2'
4
+ s.licenses = ['Apache-2.0']
5
+ s.summary = 'This filter queries the Virustotal API v3'
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.homepage = 'https://github.com/a93h/logstash-filter-virustotalthree'
8
+ s.authors = ["gh-flo-vall","CoolAcid","a93h"]
9
+ s.email = ''
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", "~> 2.0"
22
+ s.add_runtime_dependency 'virustotalx', '1.2.0'
23
+ s.add_development_dependency 'logstash-devutils'
24
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-virustotalthree
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - gh-flo-vall
8
+ - CoolAcid
9
+ - a93h
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2021-10-19 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.0'
21
+ name: logstash-core-plugin-api
22
+ prerelease: false
23
+ type: :runtime
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.0'
29
+ - !ruby/object:Gem::Dependency
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '='
33
+ - !ruby/object:Gem::Version
34
+ version: 1.2.0
35
+ name: virustotalx
36
+ prerelease: false
37
+ type: :runtime
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '='
41
+ - !ruby/object:Gem::Version
42
+ version: 1.2.0
43
+ - !ruby/object:Gem::Dependency
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ name: logstash-devutils
50
+ prerelease: false
51
+ type: :development
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ description: This gem is a logstash plugin required to be installed on top of the
58
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
59
+ gem is not a stand-alone program
60
+ email: ''
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - CHANGELOG.md
66
+ - CONTRIBUTORS
67
+ - DEVELOPER.md
68
+ - Gemfile
69
+ - LICENSE
70
+ - README.md
71
+ - lib/logstash/filters/virustotalthree.rb
72
+ - spec/filters/virustotalthree_spec.rb
73
+ - spec/spec_helper.rb
74
+ - virustotalthree.gemspec
75
+ homepage: https://github.com/a93h/logstash-filter-virustotalthree
76
+ licenses:
77
+ - Apache-2.0
78
+ metadata:
79
+ logstash_plugin: 'true'
80
+ logstash_group: filter
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 3.2.29
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: This filter queries the Virustotal API v3
100
+ test_files:
101
+ - spec/filters/virustotalthree_spec.rb
102
+ - spec/spec_helper.rb