logstash-codec-rsa_encrypt 0.0.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: 3716aec4a977371b20f229c1bcf28908f4a355e8
4
+ data.tar.gz: 233d07b9e872ba1c4a52721d3f11ca52ea65979a
5
+ SHA512:
6
+ metadata.gz: 4d2665c04cd94c36d7af29233dd83120e87e987188c4dc1dc60afe57d02e9059f91cc47a8b5801e090c2b8a3db7618724e17d2c85e836f68dae2f9d15844f382
7
+ data.tar.gz: cc0b94d4ade04d41c465dd890c9c319c4f9e1824ae8c1fdb835189f82e1ab0ab0b6cf8f7b412765640344023b85579846fd28fc171d4f4d466c59195b15ef5cc
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,86 @@
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
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - 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).
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ - Update your dependencies
35
+
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ - Run tests
41
+
42
+ ```sh
43
+ bundle exec rspec
44
+ ```
45
+
46
+ ### 2. Running your unpublished Plugin in Logstash
47
+
48
+ #### 2.1 Run in a local Logstash clone
49
+
50
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
51
+ ```ruby
52
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
+ ```
54
+ - Install plugin
55
+ ```sh
56
+ bin/plugin install --no-verify
57
+ ```
58
+ - Run Logstash with your plugin
59
+ ```sh
60
+ bin/logstash -e 'filter {awesome {}}'
61
+ ```
62
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
+
64
+ #### 2.2 Run in an installed Logstash
65
+
66
+ 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:
67
+
68
+ - Build your plugin gem
69
+ ```sh
70
+ gem build logstash-filter-awesome.gemspec
71
+ ```
72
+ - Install the plugin from the Logstash home
73
+ ```sh
74
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
75
+ ```
76
+ - Start Logstash and proceed to test the plugin
77
+
78
+ ## Contributing
79
+
80
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
+
82
+ 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.
83
+
84
+ It is more important to the community that you are able to contribute.
85
+
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,7 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "logstash/devutils/rake"
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+ require "logstash/codecs/base"
3
+ require "logstash/namespace"
4
+ require "logstash/json"
5
+
6
+ class LogStash::Codecs::RsaEncrypt < LogStash::Codecs::Base
7
+ config_name "rsa_encrypt"
8
+
9
+ # The location of the public key file.
10
+ config :public_key_file, :validate => :path, :required => true
11
+
12
+ public
13
+ def initialize(params={})
14
+ super(params)
15
+ require "openssl"
16
+ require "base64"
17
+ @public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))
18
+ end
19
+
20
+ public
21
+ def encode(event)
22
+
23
+ # Create cipher with a random session key.
24
+ cipher = OpenSSL::Cipher::Cipher.new('aes-128-cbc')
25
+ cipher.encrypt
26
+ cipher.key = session_key = cipher.random_key
27
+ cipher.iv = session_iv = cipher.random_iv
28
+
29
+ # Encrypt the data with the cipher.
30
+ encrypted_data = cipher.update(event.to_json)
31
+ encrypted_data << cipher.final
32
+
33
+ # Encrypt session key with the public key.
34
+ encrypted_key = @public_key.public_encrypt(session_key)
35
+ encrypted_iv = @public_key.public_encrypt(session_iv)
36
+
37
+ # Base64 encode for transmission (might make this optional in the future).
38
+ base64_encrypted_data = Base64.encode64(encrypted_data)
39
+ base64_encrypted_key = Base64.encode64(encrypted_key)
40
+ base64_encrypted_iv = Base64.encode64(encrypted_iv)
41
+
42
+ # Package up the encrypted data and session keys.
43
+ data = {}
44
+ data["encrypted_data"] = base64_encrypted_data
45
+ data["encrypted_key"] = base64_encrypted_key
46
+ data["encrypted_iv"] = base64_encrypted_iv
47
+
48
+ # Convert the payload to json and pass it on.
49
+ data_json = LogStash::Json.dump(data)
50
+ @on_event.call(event, data_json)
51
+
52
+ end # def encode
53
+
54
+ end # class LogStash::Codecs::RsaEncrypt
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-codec-rsa_encrypt'
4
+ s.version = '0.0.1'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "RSA-encrypted ciphertext."
7
+ s.description = "This gem is a logstash plugin 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 = ["Emdeon Enterprise Monitoring"]
9
+ s.email = 'ISSProductionMonitoring-Data@emdeon.com'
10
+ s.homepage = "http://www.emdeon.com/"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = `git ls-files`.split($\)
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" => "codec" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
24
+ s.add_development_dependency 'logstash-devutils'
25
+
26
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+
3
+ require "logstash/devutils/rspec/spec_helper"
4
+ require "logstash/codecs/rsa_encrypt"
5
+ require "logstash/event"
6
+
7
+ describe LogStash::Codecs::RsaEncrypt do
8
+ subject do
9
+ next LogStash::Codecs::RsaEncrypt.new
10
+ end
11
+
12
+ context "#encode" do
13
+ let (:event) {LogStash::Event.new({"message" => "hello world", "host" => "test"})}
14
+
15
+ it "should return a json string" do
16
+ end
17
+
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-codec-rsa_encrypt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Emdeon Enterprise Monitoring
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-11 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: logstash-devutils
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: :development
47
+ description: This gem is a logstash plugin 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: ISSProductionMonitoring-Data@emdeon.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - README.md
56
+ - Rakefile
57
+ - lib/logstash/codecs/rsa_encrypt.rb
58
+ - logstash-codec-rsa_encrypt.gemspec
59
+ - spec/codecs/rsa_encrypt_spec.rb
60
+ homepage: http://www.emdeon.com/
61
+ licenses:
62
+ - Apache License (2.0)
63
+ metadata:
64
+ logstash_plugin: 'true'
65
+ logstash_group: codec
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.5
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: RSA-encrypted ciphertext.
86
+ test_files:
87
+ - spec/codecs/rsa_encrypt_spec.rb