send_nsca 0.4.11 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +5 -22
- data/lib/send_nsca/send_nsca.rb +17 -16
- data/spec/send_nsca_spec.rb +21 -1
- data/spec/spec_helper.rb +3 -3
- metadata +38 -51
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b01bc3a9cda13bfd1d0b620be61efb099687da3
|
4
|
+
data.tar.gz: 7b164273cfee1de17fbd6cd4b5827ec10c9c8e76
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9042f6005188dc538788d8046295b3fa6e848138170810de8f6d269a923019e9bdc9bea53f4c019df0c1e90bbb60c271e3ba3c41d94a2a9dcb81009e19d5e256
|
7
|
+
data.tar.gz: 6f0ee855e4cbecd369250ac61a117104e19654ac15fc07aeb5918179dde561cde8ae627af0544af0841b698e6aa74926131ada274c401a65a67ff3b3df5d4553
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ begin
|
|
7
7
|
gem.name = "send_nsca"
|
8
8
|
gem.summary = %Q{A pure ruby implementation of the send_nsca program for sending passive alerts to Nagios through NSCA.}
|
9
9
|
gem.description = %Q{A pure ruby implementation of the send_nsca program for sending passive alerts to Nagios through NSCA.}
|
10
|
-
gem.email = "kbedell@
|
10
|
+
gem.email = "kbedell@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/kevinzen/send_nsca"
|
12
12
|
gem.authors = ["kevinzen"]
|
13
13
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
@@ -22,29 +22,12 @@ rescue LoadError
|
|
22
22
|
end
|
23
23
|
|
24
24
|
|
25
|
+
require 'rspec/core/rake_task'
|
25
26
|
|
26
|
-
|
27
|
-
Spec::Rake::SpecTask.new(:spec) do |spec|
|
28
|
-
spec.libs << 'lib' << 'spec'
|
29
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
30
|
-
end
|
27
|
+
task :default => [:spec]
|
31
28
|
|
32
|
-
|
33
|
-
|
29
|
+
desc "Run the specs."
|
30
|
+
RSpec::Core::RakeTask.new do |spec|
|
34
31
|
spec.pattern = 'spec/**/*_spec.rb'
|
35
|
-
spec.rcov = true
|
36
32
|
end
|
37
33
|
|
38
|
-
task :spec => :check_dependencies
|
39
|
-
|
40
|
-
task :default => :spec
|
41
|
-
|
42
|
-
require 'rake/rdoctask'
|
43
|
-
Rake::RDocTask.new do |rdoc|
|
44
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
-
|
46
|
-
rdoc.rdoc_dir = 'rdoc'
|
47
|
-
rdoc.title = "send_nsca #{version}"
|
48
|
-
rdoc.rdoc_files.include('README*')
|
49
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
-
end
|
data/lib/send_nsca/send_nsca.rb
CHANGED
@@ -55,6 +55,7 @@ module SendNsca
|
|
55
55
|
@return_code = args[:return_code]
|
56
56
|
@status = args[:status]
|
57
57
|
@connected = false
|
58
|
+
@password = args[:password] || ''
|
58
59
|
|
59
60
|
end
|
60
61
|
|
@@ -69,6 +70,7 @@ module SendNsca
|
|
69
70
|
@connected = false
|
70
71
|
@error = "send_ncsa - error connecting to nsca/nagios: #{$!}"
|
71
72
|
puts @error
|
73
|
+
@tcp_client.try(:close)
|
72
74
|
raise # re-raise same exception
|
73
75
|
end
|
74
76
|
timestamp_for_logging
|
@@ -108,13 +110,13 @@ module SendNsca
|
|
108
110
|
nsca_params = [PACKET_VERSION, @crc, @timestring, @return_code, @hostname, @service, @status ]
|
109
111
|
string_to_send_with_crc = nsca_params.pack(PACK_STRING)
|
110
112
|
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
113
|
+
#puts("DEBUG: PACKET_VERSION = #{PACKET_VERSION},\n @crc = #{@crc},\n @timestring = #{@timestring},\n @timestamp_hex = #{Time.at(timestamp_hex)},\n @return_code #{@return_code},\n @hostname = #{@hostname},\n @service = #{@service},\n @status = #{@status}\n")
|
114
|
+
#puts "string_to_send_with_crc = #{string_to_send_with_crc.length}"
|
115
|
+
#puts "string_to_send_with_crc = #{string_to_send_with_crc.unpack('H*')}"
|
114
116
|
|
115
|
-
|
116
|
-
#
|
117
|
-
#
|
117
|
+
encrypted_string_to_send = SendNsca::NscaConnection.xor(@xor_key, string_to_send_with_crc, @password)
|
118
|
+
#puts "encrypted_string_to_send = #{encrypted_string_to_send.length}"
|
119
|
+
#puts "encrypted_string_to_send = #{encrypted_string_to_send.unpack('H*')}"
|
118
120
|
|
119
121
|
@tcp_client.send(encrypted_string_to_send, 0)
|
120
122
|
@tcp_client.close
|
@@ -131,19 +133,18 @@ module SendNsca
|
|
131
133
|
r ^ 0xFFFFFFFF
|
132
134
|
end
|
133
135
|
|
134
|
-
def self.xor(
|
135
|
-
|
136
|
-
str_a = str.unpack("C*")
|
137
|
-
key_a = xor_key.unpack("C*")
|
136
|
+
def self.xor(iv, str, password='')
|
138
137
|
|
138
|
+
str_a = str.unpack("C*")
|
139
|
+
iv_a = iv.unpack("C*")
|
140
|
+
password_a = password.unpack("C*")
|
139
141
|
result = []
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
result[
|
144
|
-
str_index += 1
|
145
|
-
key_index = key_index == xor_key.length-1 ? 0 : key_index += 1
|
142
|
+
|
143
|
+
str_a.each_with_index do |c, i|
|
144
|
+
result[i] = c ^ iv_a[i % iv_a.size]
|
145
|
+
result[i] ^= password_a[i % password_a.size] unless password_a.empty?
|
146
146
|
end
|
147
|
+
|
147
148
|
ret_val = result.pack("C*")
|
148
149
|
end
|
149
150
|
|
data/spec/send_nsca_spec.rb
CHANGED
@@ -40,12 +40,32 @@ describe "SendNsca" do
|
|
40
40
|
deencrypted_str = SendNsca::NscaConnection.xor(xor_key,encrypted_str)
|
41
41
|
deencrypted_str.should eql str
|
42
42
|
|
43
|
-
str = "\000\000\000\000\
|
43
|
+
str = "\000\000\000\000\x1\x2\x3_abc123&*#"
|
44
44
|
encrypted_str = SendNsca::NscaConnection.xor(xor_key,str)
|
45
45
|
deencrypted_str = SendNsca::NscaConnection.xor(xor_key,encrypted_str)
|
46
46
|
deencrypted_str.should eql str
|
47
47
|
end
|
48
48
|
|
49
|
+
it "should perform valid xor encryption that can be deencrypted and accept a password" do
|
50
|
+
|
51
|
+
xor_key = "\377\376\375"
|
52
|
+
str = "Hello!"
|
53
|
+
encrypted_str = SendNsca::NscaConnection.xor(xor_key,str, "YOURPASSWORD")
|
54
|
+
deencrypted_str = SendNsca::NscaConnection.xor(xor_key,encrypted_str, "YOURPASSWORD")
|
55
|
+
deencrypted_str.should eql str
|
56
|
+
|
57
|
+
xor_key = "adsfkahudsflihasdflkahdsfoaiudfh-3284rqiuy8rtq49087ty 2-\123\666\001\004\377"
|
58
|
+
str = "Hey There This is awesome!!!\000!"
|
59
|
+
encrypted_str = SendNsca::NscaConnection.xor(xor_key,str, "YOURPASSWORD")
|
60
|
+
deencrypted_str = SendNsca::NscaConnection.xor(xor_key,encrypted_str, "YOURPASSWORD")
|
61
|
+
deencrypted_str.should eql str
|
62
|
+
|
63
|
+
str = "\000\000\000\000\x1\x2\x3_abc123&*#"
|
64
|
+
encrypted_str = SendNsca::NscaConnection.xor(xor_key, str, "YOURPASSWORD")
|
65
|
+
deencrypted_str = SendNsca::NscaConnection.xor(xor_key, encrypted_str, "YOURPASSWORD")
|
66
|
+
deencrypted_str.should eql str
|
67
|
+
end
|
68
|
+
|
49
69
|
it "should correctly send a message to the server" do
|
50
70
|
|
51
71
|
args = {
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
require 'send_nsca'
|
4
|
-
require 'spec'
|
5
|
-
require 'spec/autorun'
|
4
|
+
#require 'spec'
|
5
|
+
#require 'spec/autorun'
|
6
6
|
|
7
|
-
|
7
|
+
RSpec.configure do |config|
|
8
8
|
|
9
9
|
end
|
metadata
CHANGED
@@ -1,45 +1,37 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: send_nsca
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 4
|
8
|
-
- 11
|
9
|
-
version: 0.4.11
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- kevinzen
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
21
14
|
name: rspec
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
25
17
|
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 1
|
29
|
-
- 2
|
30
|
-
- 9
|
31
|
-
version: 1.2.9
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
32
20
|
type: :development
|
33
|
-
|
34
|
-
|
35
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
description: A pure ruby implementation of the send_nsca program for sending passive
|
28
|
+
alerts to Nagios through NSCA.
|
29
|
+
email: kbedell@gmail.com
|
36
30
|
executables: []
|
37
|
-
|
38
31
|
extensions: []
|
39
|
-
|
40
|
-
extra_rdoc_files:
|
32
|
+
extra_rdoc_files:
|
41
33
|
- README.rdoc
|
42
|
-
files:
|
34
|
+
files:
|
43
35
|
- README.rdoc
|
44
36
|
- Rakefile
|
45
37
|
- lib/send_nsca.rb
|
@@ -48,37 +40,32 @@ files:
|
|
48
40
|
- spec/send_nsca_spec.rb
|
49
41
|
- spec/spec.opts
|
50
42
|
- spec/spec_helper.rb
|
51
|
-
has_rdoc: true
|
52
43
|
homepage: http://github.com/kevinzen/send_nsca
|
53
44
|
licenses: []
|
54
|
-
|
45
|
+
metadata: {}
|
55
46
|
post_install_message:
|
56
|
-
rdoc_options:
|
57
|
-
- --charset=UTF-8
|
58
|
-
require_paths:
|
47
|
+
rdoc_options:
|
48
|
+
- "--charset=UTF-8"
|
49
|
+
require_paths:
|
59
50
|
- lib
|
60
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
-
requirements:
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
62
53
|
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
-
requirements:
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
69
58
|
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
|
72
|
-
- 0
|
73
|
-
version: "0"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
74
61
|
requirements: []
|
75
|
-
|
76
62
|
rubyforge_project:
|
77
|
-
rubygems_version:
|
63
|
+
rubygems_version: 2.2.2
|
78
64
|
signing_key:
|
79
65
|
specification_version: 3
|
80
|
-
summary: A pure ruby implementation of the send_nsca program for sending passive alerts
|
81
|
-
|
66
|
+
summary: A pure ruby implementation of the send_nsca program for sending passive alerts
|
67
|
+
to Nagios through NSCA.
|
68
|
+
test_files:
|
82
69
|
- spec/send_nsca_spec.rb
|
83
70
|
- spec/spec.opts
|
84
71
|
- spec/spec_helper.rb
|