netsnmp 0.6.0 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/netsnmp/client.rb +5 -2
- data/lib/netsnmp/encryption/aes.rb +3 -3
- data/lib/netsnmp/encryption/des.rb +4 -4
- data/lib/netsnmp/errors.rb +9 -4
- data/lib/netsnmp/extensions.rb +12 -1
- data/lib/netsnmp/loggable.rb +1 -2
- data/lib/netsnmp/message.rb +6 -6
- data/lib/netsnmp/mib/parser.rb +39 -39
- data/lib/netsnmp/mib.rb +17 -11
- data/lib/netsnmp/oid.rb +6 -3
- data/lib/netsnmp/pdu.rb +20 -23
- data/lib/netsnmp/scoped_pdu.rb +7 -6
- data/lib/netsnmp/security_parameters.rb +54 -54
- data/lib/netsnmp/session.rb +14 -12
- data/lib/netsnmp/timeticks.rb +1 -0
- data/lib/netsnmp/v3_session.rb +7 -7
- data/lib/netsnmp/varbind.rb +21 -11
- data/lib/netsnmp/version.rb +1 -1
- data/lib/netsnmp.rb +9 -9
- data/sig/client.rbs +8 -2
- data/sig/encryption/aes.rbs +23 -0
- data/sig/encryption/des.rbs +23 -0
- data/sig/errors.rbs +13 -0
- data/sig/extensions.rbs +12 -0
- data/sig/loggable.rbs +4 -7
- data/sig/message.rbs +10 -2
- data/sig/mib.rbs +20 -6
- data/sig/netsnmp.rbs +5 -5
- data/sig/oid.rbs +1 -0
- data/sig/pdu.rbs +14 -15
- data/sig/scoped_pdu.rbs +9 -4
- data/sig/security_parameters.rbs +29 -23
- data/sig/session.rbs +21 -6
- data/sig/timeticks.rbs +19 -0
- data/sig/v3_session.rbs +3 -2
- data/sig/varbind.rbs +13 -2
- data/spec/client_spec.rb +8 -8
- data/spec/pdu_spec.rb +2 -1
- metadata +8 -4
- data/sig/openssl.rbs +0 -20
@@ -10,7 +10,7 @@ module NETSNMP
|
|
10
10
|
using StringExtensions
|
11
11
|
using ASNExtensions
|
12
12
|
|
13
|
-
|
13
|
+
include Loggable
|
14
14
|
|
15
15
|
IPAD = "\x36" * 64
|
16
16
|
OPAD = "\x5c" * 64
|
@@ -22,8 +22,7 @@ module NETSNMP
|
|
22
22
|
# The 150 Seconds is specified in https://www.ietf.org/rfc/rfc2574.txt 2.2.3
|
23
23
|
TIMELINESS_THRESHOLD = 150
|
24
24
|
|
25
|
-
attr_reader :security_level, :username, :auth_protocol
|
26
|
-
attr_reader :engine_id
|
25
|
+
attr_reader :security_level, :username, :auth_protocol, :engine_id
|
27
26
|
|
28
27
|
# @param [String] username the snmp v3 username
|
29
28
|
# @param [String] engine_id the device engine id (initialized to '' for report)
|
@@ -39,24 +38,42 @@ module NETSNMP
|
|
39
38
|
# not explicitly set), and :priv_password becomes mandatory.
|
40
39
|
#
|
41
40
|
def initialize(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
username:,
|
42
|
+
engine_id: "",
|
43
|
+
security_level: nil,
|
44
|
+
auth_protocol: nil,
|
45
|
+
auth_password: nil,
|
46
|
+
priv_protocol: nil,
|
47
|
+
priv_password: nil,
|
48
|
+
**options
|
49
49
|
)
|
50
|
-
@security_level = security_level
|
50
|
+
@security_level = case security_level
|
51
|
+
when /no_?auth/ then 0
|
52
|
+
when /auth_?no_?priv/ then 1
|
53
|
+
when /auth_?priv/ then 3
|
54
|
+
when Integer then security_level
|
55
|
+
else 3 # rubocop:disable Lint/DuplicateBranch
|
56
|
+
end
|
51
57
|
@username = username
|
52
58
|
@engine_id = engine_id
|
53
59
|
@auth_protocol = auth_protocol.to_sym unless auth_protocol.nil?
|
54
60
|
@priv_protocol = priv_protocol.to_sym unless priv_protocol.nil?
|
55
|
-
|
56
|
-
@
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
|
62
|
+
if @security_level.positive?
|
63
|
+
@auth_protocol ||= :md5 # this is the default
|
64
|
+
raise "security level requires an auth password" if auth_password.nil?
|
65
|
+
raise "auth password must have between 8 to 32 characters" unless (8..32).cover?(auth_password.length)
|
66
|
+
end
|
67
|
+
|
68
|
+
if @security_level > 1
|
69
|
+
@priv_protocol ||= :des
|
70
|
+
raise "security level requires a priv password" if priv_password.nil?
|
71
|
+
raise "priv password must have between 8 to 32 characters" unless (8..32).cover?(priv_password.length)
|
72
|
+
end
|
73
|
+
|
74
|
+
@auth_pass_key = passkey(auth_password) if auth_password
|
75
|
+
@priv_pass_key = passkey(priv_password) if priv_password
|
76
|
+
initialize_logger(**options)
|
60
77
|
end
|
61
78
|
|
62
79
|
def engine_id=(id)
|
@@ -72,9 +89,11 @@ module NETSNMP
|
|
72
89
|
# @return [Array] a pair, where the first argument in the asn structure with the encoded pdu,
|
73
90
|
# and the second is the calculated salt (if it has been encrypted)
|
74
91
|
def encode(pdu, salt:, engine_time:, engine_boots:)
|
75
|
-
|
76
|
-
|
77
|
-
|
92
|
+
encryptor = encryption
|
93
|
+
|
94
|
+
if encryptor
|
95
|
+
encrypted_pdu, salt = encryptor.encrypt(pdu.to_der, engine_boots: engine_boots,
|
96
|
+
engine_time: engine_time)
|
78
97
|
[
|
79
98
|
OpenSSL::ASN1::OctetString.new(encrypted_pdu).with_label(:encrypted_pdu),
|
80
99
|
OpenSSL::ASN1::OctetString.new(salt).with_label(:salt)
|
@@ -92,10 +111,11 @@ module NETSNMP
|
|
92
111
|
asn = OpenSSL::ASN1.decode(der)
|
93
112
|
return asn if security_level < 3
|
94
113
|
|
95
|
-
|
114
|
+
encryptor = encryption
|
115
|
+
return asn unless encryptor
|
96
116
|
|
97
117
|
encrypted_pdu = asn.value
|
98
|
-
pdu_der =
|
118
|
+
pdu_der = encryptor.decrypt(encrypted_pdu, salt: salt, engine_time: engine_time, engine_boots: engine_boots)
|
99
119
|
log(level: 2) { "message has been decrypted" }
|
100
120
|
OpenSSL::ASN1.decode(pdu_der)
|
101
121
|
end
|
@@ -116,7 +136,7 @@ module NETSNMP
|
|
116
136
|
|
117
137
|
# MD5 => https://datatracker.ietf.org/doc/html/rfc3414#section-6.3.2
|
118
138
|
# SHA1 => https://datatracker.ietf.org/doc/html/rfc3414#section-7.3.2
|
119
|
-
key << "\x00" * (@auth_protocol == :md5 ? 48 : 44)
|
139
|
+
key << ("\x00" * (@auth_protocol == :md5 ? 48 : 44))
|
120
140
|
k1 = key.xor(IPAD)
|
121
141
|
k2 = key.xor(OPAD)
|
122
142
|
|
@@ -135,15 +155,18 @@ module NETSNMP
|
|
135
155
|
#
|
136
156
|
# @raise [NETSNMP::Error] if the message's integration has been violated
|
137
157
|
def verify(stream, salt, security_level: @security_level)
|
138
|
-
return if security_level < 1
|
158
|
+
return if security_level.nil? || security_level < 1
|
159
|
+
|
139
160
|
verisalt = sign(stream)
|
140
161
|
raise Error, "invalid message authentication salt" unless verisalt == salt
|
162
|
+
|
141
163
|
log(level: 2) { "message has been verified" }
|
142
164
|
end
|
143
165
|
|
144
166
|
def must_revalidate?
|
145
167
|
return @engine_id.empty? unless authorizable?
|
146
168
|
return true if @engine_id.empty? || @timeliness.nil?
|
169
|
+
|
147
170
|
(Process.clock_gettime(Process::CLOCK_MONOTONIC, :second) - @timeliness) >= TIMELINESS_THRESHOLD
|
148
171
|
end
|
149
172
|
|
@@ -157,27 +180,6 @@ module NETSNMP
|
|
157
180
|
@priv_key ||= localize_key(@priv_pass_key)
|
158
181
|
end
|
159
182
|
|
160
|
-
def check_parameters
|
161
|
-
@security_level = case @security_level
|
162
|
-
when Integer then @security_level
|
163
|
-
when /no_?auth/ then 0
|
164
|
-
when /auth_?no_?priv/ then 1
|
165
|
-
when /auth_?priv/, nil then 3
|
166
|
-
else
|
167
|
-
raise Error, "security level not supported: #{@security_level}"
|
168
|
-
end
|
169
|
-
|
170
|
-
if @security_level.positive?
|
171
|
-
@auth_protocol ||= :md5 # this is the default
|
172
|
-
raise "security level requires an auth password" if @auth_password.nil?
|
173
|
-
raise "auth password must have between 8 to 32 characters" unless (8..32).cover?(@auth_password.length)
|
174
|
-
end
|
175
|
-
return unless @security_level > 1
|
176
|
-
@priv_protocol ||= :des
|
177
|
-
raise "security level requires a priv password" if @priv_password.nil?
|
178
|
-
raise "priv password must have between 8 to 32 characters" unless (8..32).cover?(@priv_password.length)
|
179
|
-
end
|
180
|
-
|
181
183
|
def localize_key(key)
|
182
184
|
digest.reset
|
183
185
|
digest << key
|
@@ -195,8 +197,8 @@ module NETSNMP
|
|
195
197
|
password_length = password.length
|
196
198
|
while password_index < 1048576
|
197
199
|
initial = password_index % password_length
|
198
|
-
rotated = password[initial..-1] + password[0, initial]
|
199
|
-
buffer = rotated * (64 / rotated.length) + rotated[0, 64 % rotated.length]
|
200
|
+
rotated = String(password[initial..-1]) + String(password[0, initial])
|
201
|
+
buffer = (rotated * (64 / rotated.length)) + String(rotated[0, 64 % rotated.length])
|
200
202
|
password_index += 64
|
201
203
|
digest << buffer
|
202
204
|
buffer.clear
|
@@ -204,14 +206,14 @@ module NETSNMP
|
|
204
206
|
|
205
207
|
dig = digest.digest
|
206
208
|
dig = dig[0, 16] if @auth_protocol == :md5
|
207
|
-
dig
|
209
|
+
dig || ""
|
208
210
|
end
|
209
211
|
|
210
212
|
def digest
|
211
213
|
@digest ||= case @auth_protocol
|
212
|
-
when :md5 then OpenSSL::Digest
|
213
|
-
when :sha then OpenSSL::Digest
|
214
|
-
when :sha256 then OpenSSL::Digest
|
214
|
+
when :md5 then OpenSSL::Digest.new("MD5")
|
215
|
+
when :sha then OpenSSL::Digest.new("SHA1")
|
216
|
+
when :sha256 then OpenSSL::Digest.new("SHA256")
|
215
217
|
else
|
216
218
|
raise Error, "unsupported auth protocol: #{@auth_protocol}"
|
217
219
|
end
|
@@ -219,10 +221,8 @@ module NETSNMP
|
|
219
221
|
|
220
222
|
def encryption
|
221
223
|
@encryption ||= case @priv_protocol
|
222
|
-
when :des
|
223
|
-
|
224
|
-
when :aes
|
225
|
-
Encryption::AES.new(priv_key)
|
224
|
+
when :des then Encryption::DES.new(priv_key)
|
225
|
+
when :aes then Encryption::AES.new(priv_key)
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
data/lib/netsnmp/session.rb
CHANGED
@@ -4,15 +4,23 @@ module NETSNMP
|
|
4
4
|
# Let's just remind that there is no session in snmp, this is just an abstraction.
|
5
5
|
#
|
6
6
|
class Session
|
7
|
-
|
7
|
+
include Loggable
|
8
8
|
|
9
9
|
TIMEOUT = 2
|
10
10
|
|
11
11
|
# @param [Hash] opts the options set
|
12
12
|
def initialize(version: 1, community: "public", **options)
|
13
|
-
@version
|
13
|
+
@version = case version
|
14
|
+
when Integer then version # assume the use know what he's doing
|
15
|
+
when /v?1/ then 0
|
16
|
+
when /v?2c?/ then 1
|
17
|
+
when /v?3/ then 3
|
18
|
+
else
|
19
|
+
raise "unsupported snmp version (#{version})"
|
20
|
+
end
|
14
21
|
@community = community
|
15
22
|
validate(**options)
|
23
|
+
initialize_logger(**options)
|
16
24
|
end
|
17
25
|
|
18
26
|
# Closes the session
|
@@ -28,7 +36,7 @@ module NETSNMP
|
|
28
36
|
# @return [NETSNMP::PDU] a pdu
|
29
37
|
#
|
30
38
|
def build_pdu(type, *vars)
|
31
|
-
PDU.build(type,
|
39
|
+
PDU.build(type, version: @version, community: @community, varbinds: vars)
|
32
40
|
end
|
33
41
|
|
34
42
|
# send a pdu, receives a pdu
|
@@ -58,16 +66,9 @@ module NETSNMP
|
|
58
66
|
@transport = proxy
|
59
67
|
else
|
60
68
|
raise "you must provide an hostname/ip under :host" unless host
|
69
|
+
|
61
70
|
@transport = Transport.new(host, port.to_i, timeout: timeout)
|
62
71
|
end
|
63
|
-
@version = case @version
|
64
|
-
when Integer then @version # assume the use know what he's doing
|
65
|
-
when /v?1/ then 0
|
66
|
-
when /v?2c?/ then 1
|
67
|
-
when /v?3/ then 3
|
68
|
-
else
|
69
|
-
raise "unsupported snmp version (#{@version})"
|
70
|
-
end
|
71
72
|
end
|
72
73
|
|
73
74
|
class Transport
|
@@ -90,7 +91,7 @@ module NETSNMP
|
|
90
91
|
|
91
92
|
def write(payload)
|
92
93
|
perform_io do
|
93
|
-
@socket.sendmsg(payload, Socket::MSG_DONTWAIT
|
94
|
+
@socket.sendmsg(payload, Socket::MSG_DONTWAIT, @destaddr)
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
@@ -117,6 +118,7 @@ module NETSNMP
|
|
117
118
|
|
118
119
|
def wait(mode)
|
119
120
|
return if @socket.__send__(mode, @timeout)
|
121
|
+
|
120
122
|
raise Timeout::Error, "Timeout after #{@timeout} seconds"
|
121
123
|
end
|
122
124
|
end
|
data/lib/netsnmp/timeticks.rb
CHANGED
data/lib/netsnmp/v3_session.rb
CHANGED
@@ -16,7 +16,7 @@ module NETSNMP
|
|
16
16
|
# @return [NETSNMP::ScopedPDU] a pdu
|
17
17
|
def build_pdu(type, *vars)
|
18
18
|
engine_id = security_parameters.engine_id
|
19
|
-
ScopedPDU.build(type,
|
19
|
+
ScopedPDU.build(type, engine_id: engine_id, context: @context, varbinds: vars)
|
20
20
|
end
|
21
21
|
|
22
22
|
# @see {NETSNMP::Session#send}
|
@@ -42,11 +42,11 @@ module NETSNMP
|
|
42
42
|
end
|
43
43
|
else
|
44
44
|
@security_parameters = SecurityParameters.new(security_level: options[:security_level],
|
45
|
-
username:
|
46
|
-
auth_protocol:
|
47
|
-
priv_protocol:
|
48
|
-
auth_password:
|
49
|
-
priv_password:
|
45
|
+
username: options[:username],
|
46
|
+
auth_protocol: options[:auth_protocol],
|
47
|
+
priv_protocol: options[:priv_protocol],
|
48
|
+
auth_password: options[:auth_password],
|
49
|
+
priv_password: options[:priv_password])
|
50
50
|
|
51
51
|
end
|
52
52
|
end
|
@@ -61,7 +61,7 @@ module NETSNMP
|
|
61
61
|
def probe_for_engine
|
62
62
|
report_sec_params = SecurityParameters.new(security_level: 0,
|
63
63
|
username: @security_parameters.username)
|
64
|
-
pdu = ScopedPDU.build(:get
|
64
|
+
pdu = ScopedPDU.build(:get)
|
65
65
|
log { "sending probe..." }
|
66
66
|
encoded_report_pdu = @message_serializer.encode(pdu, security_parameters: report_sec_params)
|
67
67
|
|
data/lib/netsnmp/varbind.rb
CHANGED
@@ -24,8 +24,10 @@ module NETSNMP
|
|
24
24
|
|
25
25
|
def to_asn
|
26
26
|
asn_oid = OID.to_asn(@oid)
|
27
|
-
|
28
|
-
|
27
|
+
type = @type
|
28
|
+
|
29
|
+
asn_val = if type
|
30
|
+
convert_to_asn(type, @value)
|
29
31
|
else
|
30
32
|
case @value
|
31
33
|
when String
|
@@ -37,8 +39,10 @@ module NETSNMP
|
|
37
39
|
when nil
|
38
40
|
OpenSSL::ASN1::Null.new(nil)
|
39
41
|
when IPAddr
|
42
|
+
# @type ivar @value: IPAddr
|
40
43
|
OpenSSL::ASN1::ASN1Data.new(@value.hton, 0, :APPLICATION)
|
41
44
|
when Timetick
|
45
|
+
# @type ivar @value: Timetick
|
42
46
|
@value.to_asn
|
43
47
|
else
|
44
48
|
raise Error, "#{@value}: unsupported varbind type"
|
@@ -73,41 +77,47 @@ module NETSNMP
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def convert_to_asn(typ, value)
|
76
|
-
asn_type = typ
|
77
80
|
asn_val = value
|
78
|
-
|
79
|
-
|
81
|
+
|
82
|
+
asn_type = if typ.is_a?(Symbol)
|
83
|
+
case typ
|
80
84
|
when :ipaddress then 0
|
81
85
|
when :counter32
|
82
86
|
asn_val = [value].pack("N*")
|
83
|
-
asn_val = asn_val
|
87
|
+
asn_val = asn_val.delete_prefix("\x00") while asn_val[0] == "\x00".b && String(asn_val[1]).unpack1("B") != "1"
|
84
88
|
1
|
85
89
|
when :gauge
|
86
90
|
asn_val = [value].pack("N*")
|
87
|
-
asn_val = asn_val
|
91
|
+
asn_val = asn_val.delete_prefix("\x00") while asn_val[0] == "\x00".b && String(asn_val[1]).unpack1("B") != "1"
|
88
92
|
2
|
89
93
|
when :timetick
|
94
|
+
# @type var value: Integer
|
90
95
|
return Timetick.new(value).to_asn
|
91
96
|
when :opaque then 4
|
92
97
|
when :nsap then 5
|
93
98
|
when :counter64
|
99
|
+
# @type var value: Integer
|
94
100
|
asn_val = [
|
95
101
|
(value >> 96) & 0xFFFFFFFF,
|
96
102
|
(value >> 64) & 0xFFFFFFFF,
|
97
103
|
(value >> 32) & 0xFFFFFFFF,
|
98
104
|
value & 0xFFFFFFFF
|
99
105
|
].pack("NNNN")
|
100
|
-
asn_val = asn_val
|
106
|
+
asn_val = asn_val.delete_prefix("\x00") while asn_val.start_with?("\x00")
|
101
107
|
6
|
102
108
|
when :uinteger then 7
|
103
109
|
else
|
104
110
|
raise Error, "#{typ}: unsupported application type"
|
105
111
|
end
|
106
|
-
|
112
|
+
else
|
113
|
+
typ
|
114
|
+
end
|
107
115
|
OpenSSL::ASN1::ASN1Data.new(asn_val, asn_type, :APPLICATION)
|
108
116
|
end
|
109
117
|
|
110
118
|
def convert_application_asn(asn)
|
119
|
+
raise(OidNotFound, "No Such Instance currently exists at this OID") if asn.value.empty?
|
120
|
+
|
111
121
|
case asn.tag
|
112
122
|
when 0 # IP Address
|
113
123
|
IPAddr.new_ntoh(asn.value)
|
@@ -128,12 +138,12 @@ module NETSNMP
|
|
128
138
|
|
129
139
|
def unpack_32bit_integer(payload)
|
130
140
|
payload.prepend("\x00") until (payload.bytesize % 4).zero?
|
131
|
-
payload.unpack("N*")[-1]
|
141
|
+
payload.unpack("N*")[-1].to_i
|
132
142
|
end
|
133
143
|
|
134
144
|
def unpack_64bit_integer(payload)
|
135
145
|
payload.prepend("\x00") until (payload.bytesize % 16).zero?
|
136
|
-
payload.unpack("NNNN").reduce(0) { |sum, elem| (sum << 32) + elem }
|
146
|
+
payload.unpack("NNNN").reduce(0) { |sum, elem| (sum << 32) + elem.to_i }
|
137
147
|
end
|
138
148
|
end
|
139
149
|
end
|
data/lib/netsnmp/version.rb
CHANGED
data/lib/netsnmp.rb
CHANGED
@@ -8,13 +8,13 @@ require "ipaddr"
|
|
8
8
|
|
9
9
|
# core structures
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
module NETSNMP
|
12
|
+
begin
|
13
|
+
require "xorcist"
|
14
|
+
require "xorcist/refinements"
|
15
|
+
StringExtensions = Xorcist::Refinements
|
16
|
+
rescue LoadError
|
17
|
+
# "no xorcist"
|
18
18
|
module StringExtensions
|
19
19
|
refine String do
|
20
20
|
# Bitwise XOR operator for the String class
|
@@ -24,8 +24,8 @@ rescue LoadError
|
|
24
24
|
|
25
25
|
b2 = other.unpack("C*")
|
26
26
|
longest = [b1.length, b2.length].max
|
27
|
-
b1 = [0] * (longest - b1.length) + b1
|
28
|
-
b2 = [0] * (longest - b2.length) + b2
|
27
|
+
b1 = ([0] * (longest - b1.length)) + b1
|
28
|
+
b2 = ([0] * (longest - b2.length)) + b2
|
29
29
|
b1.zip(b2).map { |a, b| a ^ b }.pack("C*")
|
30
30
|
end
|
31
31
|
end
|
data/sig/client.rbs
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module NETSNMP
|
2
2
|
class Client
|
3
|
+
RETRIES: Integer
|
4
|
+
|
5
|
+
@retries: Integer
|
6
|
+
@session: Session
|
3
7
|
|
4
8
|
def get: (*untyped) -> untyped
|
5
9
|
| (*untyped) { (PDU) -> void } -> untyped
|
@@ -13,12 +17,14 @@ module NETSNMP
|
|
13
17
|
def inform: (*untyped) -> untyped
|
14
18
|
| (*untyped) { (PDU) -> void } -> untyped
|
15
19
|
|
16
|
-
def walk: (oid: oid) -> _Each[oid_type, oid_value]
|
20
|
+
def walk: (oid: oid) -> _Each[[oid_type, oid_value]]
|
17
21
|
|
18
22
|
def close: () -> void
|
19
23
|
|
20
24
|
private
|
21
25
|
|
22
|
-
def initialize: (?version
|
26
|
+
def initialize: (?version: snmp_version, **untyped) ?{ (instance) -> void } -> void
|
27
|
+
|
28
|
+
def handle_retries: [U] { () -> U } -> U
|
23
29
|
end
|
24
30
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module NETSNMP
|
2
|
+
module Encryption
|
3
|
+
class AES
|
4
|
+
|
5
|
+
@priv_key: String
|
6
|
+
@local: Integer
|
7
|
+
|
8
|
+
def encrypt: (String decrypted_data, engine_boots: Integer, engine_time: Integer) -> [String, String]
|
9
|
+
|
10
|
+
def decrypt: (String encrypted_data, salt: String, engine_boots: Integer, engine_time: Integer) -> String
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def initialize: (String priv_key, ?local: Integer) -> untyped
|
15
|
+
|
16
|
+
def generate_encryption_key: (Integer boots, Integer time) -> [String, String]
|
17
|
+
|
18
|
+
def generate_decryption_key: (Integer boots, Integer time, String salt) -> String
|
19
|
+
|
20
|
+
def aes_key: () -> String
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module NETSNMP
|
2
|
+
module Encryption
|
3
|
+
class DES
|
4
|
+
|
5
|
+
@priv_key: String
|
6
|
+
@local: Integer
|
7
|
+
|
8
|
+
def encrypt: (String decrypted_data, engine_boots: Integer, **untyped) -> [String, String]
|
9
|
+
|
10
|
+
def decrypt: (String encrypted_data, salt: String, **untyped) -> String
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def initialize: (String priv_key, ?local: Integer) -> untyped
|
15
|
+
|
16
|
+
def generate_encryption_key: (Integer boots) -> [String, String]
|
17
|
+
|
18
|
+
def generate_decryption_key: (String salt) -> String
|
19
|
+
|
20
|
+
def des_key: () -> String
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/sig/errors.rbs
ADDED
data/sig/extensions.rbs
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module NETSNMP
|
2
|
+
module ASNExtensions
|
3
|
+
ASN_COLORS: Hash[singleton(OpenSSL::ASN1::ASN1Data), Integer]
|
4
|
+
end
|
5
|
+
|
6
|
+
module Hexdump
|
7
|
+
def self?.dump: (String data, ?width: Integer, ?in_groups_of: Integer, ?separator: String) -> String
|
8
|
+
end
|
9
|
+
|
10
|
+
class HexString < String
|
11
|
+
end
|
12
|
+
end
|
data/sig/loggable.rbs
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
module NETSNMP
|
2
2
|
module Loggable
|
3
|
-
interface _Debugger
|
4
|
-
def <<: (string) -> void
|
5
|
-
end
|
6
|
-
|
7
3
|
DEBUG_LEVEL: Integer
|
8
|
-
DEBUG:
|
4
|
+
DEBUG: IO?
|
5
|
+
COLORS: Hash[Symbol, Integer]
|
9
6
|
|
10
|
-
|
7
|
+
def initialize_logger: (?debug: IO, ?debug_level: Integer, **untyped) -> void
|
11
8
|
|
12
|
-
|
9
|
+
private
|
13
10
|
|
14
11
|
def log: (?level: Integer) { () -> String } -> void
|
15
12
|
end
|
data/sig/message.rbs
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
module NETSNMP
|
2
2
|
class Message
|
3
|
-
|
3
|
+
include Loggable
|
4
|
+
|
5
|
+
PRIVNONE: OpenSSL::ASN1::OctetString
|
6
|
+
MSG_MAX_SIZE: OpenSSL::ASN1::Integer
|
7
|
+
MSG_SECURITY_MODEL: OpenSSL::ASN1::Integer
|
8
|
+
MSG_VERSION: OpenSSL::ASN1::Integer
|
9
|
+
MSG_REPORTABLE: Integer
|
4
10
|
|
5
11
|
def verify: (String stream, String auth_param, Integer? security_level, security_parameters: SecurityParameters) -> void
|
6
12
|
|
@@ -10,6 +16,8 @@ module NETSNMP
|
|
10
16
|
|
11
17
|
private
|
12
18
|
|
13
|
-
def
|
19
|
+
def initialize: (**untyped options) -> void
|
20
|
+
|
21
|
+
def authnone: (Symbol?) -> OpenSSL::ASN1::ASN1Data
|
14
22
|
end
|
15
23
|
end
|
data/sig/mib.rbs
CHANGED
@@ -2,20 +2,34 @@ module NETSNMP
|
|
2
2
|
module MIB
|
3
3
|
type import = {ids: Array[{name: string}], name: string} | {ids: {name: string}, name: string}
|
4
4
|
|
5
|
-
|
5
|
+
OIDREGEX: Regexp
|
6
6
|
MIBDIRS: Array[String]
|
7
7
|
PARSER: Parser
|
8
8
|
|
9
|
-
|
9
|
+
TYPES: Array[String]
|
10
|
+
STATIC_MIB_TO_OID: Hash[String, String]
|
11
|
+
|
12
|
+
@parser_mutex: Thread::Mutex
|
10
13
|
@modules_loaded: Array[String]
|
11
14
|
@object_identifiers: Hash[String, String]
|
12
15
|
|
13
|
-
def self?.oid: (
|
14
|
-
| (Array[_ToS] identifier) -> String?
|
16
|
+
def self?.oid: (oid identifier) -> String?
|
15
17
|
|
16
|
-
def self?.load: (String mod) ->
|
18
|
+
def self?.load: (String mod) -> bool
|
19
|
+
|
20
|
+
def self?.load_imports: (Array[import] | import | nil data) -> Hash[String, Array[String]]?
|
17
21
|
|
18
|
-
def self?.load_imports: ((Array[import] | import)? data) -> Hash[String, Array[String]]?
|
19
22
|
def self?.load_defaults: () -> void
|
23
|
+
|
24
|
+
def self?.do_load: (String mod) -> void
|
25
|
+
|
26
|
+
def self?.module_loaded?: (String mod) -> bool
|
27
|
+
|
28
|
+
def self?.store_oid_in_identifiers: (String name, Array[String] value, imports: Hash[String, Array[String]]?, declarations: Hash[String, Array[String]]) -> void
|
29
|
+
|
30
|
+
# workaround
|
31
|
+
class Parser
|
32
|
+
def parse: (String data) -> Hash[:imports | :declarations, untyped?]
|
33
|
+
end
|
20
34
|
end
|
21
35
|
end
|
data/sig/netsnmp.rbs
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module NETSNMP
|
2
|
+
VERSION: String
|
3
|
+
|
2
4
|
interface _Logger
|
3
5
|
def <<: (string) -> void
|
4
6
|
end
|
@@ -9,11 +11,9 @@ module NETSNMP
|
|
9
11
|
def digest: () -> String
|
10
12
|
end
|
11
13
|
|
12
|
-
interface
|
13
|
-
def
|
14
|
-
|
15
|
-
def decrypt: (String payload, salt: String, engine_boots: Integer, engine_time: Integer) -> String
|
14
|
+
interface _ToAsn
|
15
|
+
def to_asn: () -> OpenSSL::ASN1::ASN1Data
|
16
16
|
end
|
17
17
|
|
18
|
-
type snmp_version = 0 | 1 | 3 | :v1 | :v2c | :v3 | nil
|
18
|
+
type snmp_version = 0 | 1 | 3 | :v1 | :v2c | :v3 | String | nil
|
19
19
|
end
|