deepsecurity 0.0.20 → 0.0.21
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.
- data/CHANGELOG.md +7 -0
- data/Rakefile +15 -0
- data/generate_s3_links.sh +21 -0
- data/lib/deepsecurity/enums.rb +1 -1
- data/lib/deepsecurity/transport_objects/time_filter.rb +18 -7
- data/lib/deepsecurity/version.rb +1 -1
- data/lib/dsc/command.rb +5 -2
- data/lib/savon_helper/dsl.rb +19 -19
- data/lib/savon_helper/type_mappings.rb +76 -11
- data/lib/savon_helper.rb +15 -0
- data/test/test_dsc_command.rb +34 -0
- data/test/test_savon_helper.rb +20 -0
- metadata +14 -3
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
## CHANGELOG (notable new features or fixes)
|
4
4
|
|
5
|
+
### 0.0.21
|
6
|
+
|
7
|
+
* Extended `-fields` to accept a filename to read the fields from
|
8
|
+
* Added warning for unparseable entries
|
9
|
+
|
10
|
+
|
5
11
|
### 0.0.20
|
6
12
|
|
7
13
|
* `dsc` command refactoring
|
@@ -10,6 +16,7 @@
|
|
10
16
|
* Added `--detail_level` flag for `host_detail` command
|
11
17
|
* Added `-time_format` flag to specifiy time format
|
12
18
|
|
19
|
+
|
13
20
|
### 0.0.19
|
14
21
|
|
15
22
|
* Updated documentation
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
|
+
require 'rake/testtask'
|
3
4
|
|
4
5
|
desc "create a new version, create tag and push to github"
|
5
6
|
task :github_and_tag do
|
@@ -15,4 +16,18 @@ task :windows_installer => :build do
|
|
15
16
|
system("./windows-installer/iscc windows-installer/dsc.iss /dgemVersion=\"#{GEM_VERSION}\" /drubyVersion=\"#{RUBY_INSTALLER_VERSION}\"")
|
16
17
|
end
|
17
18
|
|
19
|
+
Rake::TestTask.new do |t|
|
20
|
+
t.libs << 'test'
|
21
|
+
require "bundler/setup"
|
22
|
+
|
23
|
+
gem 'deepsecurity', :path => "~/Documents/Development/deepsecurity"
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Run tests"
|
27
|
+
task :default => :test
|
28
|
+
|
29
|
+
desc "Build index.html for S3 Bucket"
|
30
|
+
task :s3_index do
|
31
|
+
system("./generate_s3_links.sh > index.html")
|
32
|
+
end
|
18
33
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
cat <<EOF
|
4
|
+
<html>
|
5
|
+
<head>
|
6
|
+
<title>DeepSecurity gem downloads</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<ul>
|
10
|
+
EOF
|
11
|
+
|
12
|
+
for path in $( ls pkg/*gem ; ls windows-installer/Output/*exe ); do
|
13
|
+
file=$( basename $path )
|
14
|
+
echo "<li><a href=\"$file\">$file</a></li>"
|
15
|
+
done
|
16
|
+
|
17
|
+
cat <<EOF
|
18
|
+
</ul>
|
19
|
+
</body>
|
20
|
+
</head>
|
21
|
+
EOF
|
data/lib/deepsecurity/enums.rb
CHANGED
@@ -497,7 +497,7 @@ module DeepSecurity
|
|
497
497
|
"LAST_24_HOURS" => :last_24_hours,
|
498
498
|
"LAST_7_DAYS" => :last_7_days,
|
499
499
|
"CUSTOM_RANGE" => :custom_range,
|
500
|
-
"SPECIFIC_TIME" => :
|
500
|
+
"SPECIFIC_TIME" => :specific_time
|
501
501
|
}
|
502
502
|
|
503
503
|
# General filter operator enumeration. Used when filtering retrieved events by event ID that are greater than, less
|
@@ -6,11 +6,14 @@ module DeepSecurity
|
|
6
6
|
class TimeFilter < TransportObject
|
7
7
|
|
8
8
|
attr_datetime_accessor :rangeFrom,
|
9
|
-
"Time range start to filter computers by."
|
9
|
+
"Time range start to filter computers by." ,
|
10
|
+
:range_from
|
10
11
|
attr_datetime_accessor :rangeTo,
|
11
|
-
"Time range end to filter computers by."
|
12
|
+
"Time range end to filter computers by.",
|
13
|
+
:range_to
|
12
14
|
attr_datetime_accessor :specificTime,
|
13
|
-
"Specific time to filter computers by."
|
15
|
+
"Specific time to filter computers by.",
|
16
|
+
:specific_time
|
14
17
|
# attr_integer_accessor :host_group_id
|
15
18
|
# attr_integer_accessor :host_id
|
16
19
|
# attr_integer_accessor :security_profile_id
|
@@ -50,18 +53,26 @@ module DeepSecurity
|
|
50
53
|
def self.custom_range(datetime_range)
|
51
54
|
instance = self.new()
|
52
55
|
instance.type = :custom_range
|
53
|
-
instance.
|
54
|
-
instance.
|
56
|
+
instance.range_from = datetime_range.first
|
57
|
+
instance.range_to = datetime_range.last
|
55
58
|
instance
|
56
59
|
end
|
57
60
|
|
58
61
|
# Return a new instance for the given datetime.
|
62
|
+
# @deprecated Please use {#specific_time} instead
|
59
63
|
# @param datetime [DateTime]
|
60
64
|
# @return [TimeFilter]
|
61
65
|
def self.specificTime(datetime)
|
66
|
+
self.specific_time(datetime)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Return a new instance for the given datetime.
|
70
|
+
# @param datetime [DateTime]
|
71
|
+
# @return [TimeFilter]
|
72
|
+
def self.specific_time(datetime)
|
62
73
|
instance = self.new()
|
63
|
-
instance.type = :
|
64
|
-
instance.
|
74
|
+
instance.type = :specific_time
|
75
|
+
instance.specific_time = datetime
|
65
76
|
instance
|
66
77
|
end
|
67
78
|
|
data/lib/deepsecurity/version.rb
CHANGED
data/lib/dsc/command.rb
CHANGED
@@ -269,11 +269,14 @@ module Dsc
|
|
269
269
|
def parse_fields(fields_string_or_filename_argument)
|
270
270
|
filename = File.absolute_path(fields_string_or_filename_argument)
|
271
271
|
if File.exists?(filename)
|
272
|
-
fields_string =
|
272
|
+
fields_string = ""
|
273
|
+
File.readlines(filename).each do |line|
|
274
|
+
fields_string = fields_string + " " + line.strip_comments
|
275
|
+
end
|
273
276
|
else
|
274
277
|
fields_string = fields_string_or_filename_argument
|
275
278
|
end
|
276
|
-
fields = fields_string.split(
|
279
|
+
fields = fields_string.split(/[\s,]/).map(&:strip).reject(&:blank?)
|
277
280
|
unknown_fields = fields.reject { |each| self.class.transport_class.has_attribute_chain(each) }
|
278
281
|
raise "Unknown filename or field found (#{unknown_fields.join(', ')}) - known fields are: #{self.class.valid_fields.join(', ')}" unless unknown_fields.empty?
|
279
282
|
fields
|
data/lib/savon_helper/dsl.rb
CHANGED
@@ -16,7 +16,7 @@ module SavonHelper
|
|
16
16
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
17
17
|
# @return [void]
|
18
18
|
def attr_boolean_accessor(accessor, description='', alias_accessor=accessor)
|
19
|
-
create_accessor(accessor, alias_accessor, BooleanMapping.new(description))
|
19
|
+
create_accessor(accessor, alias_accessor, BooleanMapping.new(alias_accessor, description))
|
20
20
|
end
|
21
21
|
|
22
22
|
# @macro [attach] array_boolean_accessor
|
@@ -29,7 +29,7 @@ module SavonHelper
|
|
29
29
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
30
30
|
# @return [void]
|
31
31
|
def array_boolean_accessor(accessor, description='', alias_accessor=accessor)
|
32
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(BooleanMapping.new, description))
|
32
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(BooleanMapping.new, alias_accessor, description))
|
33
33
|
end
|
34
34
|
|
35
35
|
# @macro [attach] attr_integer_accessor
|
@@ -42,7 +42,7 @@ module SavonHelper
|
|
42
42
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
43
43
|
# @return [void]
|
44
44
|
def attr_integer_accessor(accessor, description='', alias_accessor=accessor)
|
45
|
-
create_accessor(accessor, alias_accessor, IntegerMapping.new(description))
|
45
|
+
create_accessor(accessor, alias_accessor, IntegerMapping.new(alias_accessor, description))
|
46
46
|
end
|
47
47
|
|
48
48
|
# @macro [attach] array_integer_accessor
|
@@ -55,7 +55,7 @@ module SavonHelper
|
|
55
55
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
56
56
|
# @return [void]
|
57
57
|
def array_integer_accessor(accessor, description='', alias_accessor=accessor)
|
58
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(IntegerMapping.new, description))
|
58
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(IntegerMapping.new(), alias_accessor, description))
|
59
59
|
end
|
60
60
|
|
61
61
|
# @macro [attach] attr_float_accessor
|
@@ -68,7 +68,7 @@ module SavonHelper
|
|
68
68
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
69
69
|
# @return [void]
|
70
70
|
def attr_float_accessor(accessor, description='', alias_accessor=accessor)
|
71
|
-
create_accessor(accessor, alias_accessor, FloatMapping.new(description))
|
71
|
+
create_accessor(accessor, alias_accessor, FloatMapping.new(alias_accessor, description))
|
72
72
|
end
|
73
73
|
|
74
74
|
# @macro [attach] array_float__accessor
|
@@ -81,7 +81,7 @@ module SavonHelper
|
|
81
81
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
82
82
|
# @return [void]
|
83
83
|
def array_float__accessor(accessor, description='', alias_accessor=accessor)
|
84
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(FloatMapping.new, description))
|
84
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(FloatMapping.new(), alias_accessor, description))
|
85
85
|
end
|
86
86
|
|
87
87
|
# @macro [attach] attr_double_accessor
|
@@ -94,7 +94,7 @@ module SavonHelper
|
|
94
94
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
95
95
|
# @return [void]
|
96
96
|
def attr_double_accessor(accessor, description='', alias_accessor=accessor)
|
97
|
-
create_accessor(accessor, alias_accessor, FloatMapping.new(description))
|
97
|
+
create_accessor(accessor, alias_accessor, FloatMapping.new(alias_accessor, description))
|
98
98
|
end
|
99
99
|
|
100
100
|
# @macro [attach] array_double__accessor
|
@@ -107,7 +107,7 @@ module SavonHelper
|
|
107
107
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
108
108
|
# @return [void]
|
109
109
|
def array_double_accessor(accessor, description='', alias_accessor=accessor)
|
110
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(FloatMapping.new, description))
|
110
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(FloatMapping.new(), alias_accessor, description))
|
111
111
|
end
|
112
112
|
|
113
113
|
# @macro [attach] attr_string_accessor
|
@@ -120,7 +120,7 @@ module SavonHelper
|
|
120
120
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
121
121
|
# @return [void]
|
122
122
|
def attr_string_accessor(accessor, description='', alias_accessor=accessor)
|
123
|
-
create_accessor(accessor, alias_accessor, StringMapping.new(description))
|
123
|
+
create_accessor(accessor, alias_accessor, StringMapping.new(alias_accessor, description))
|
124
124
|
end
|
125
125
|
|
126
126
|
# @macro [attach] array_string_accessor
|
@@ -133,7 +133,7 @@ module SavonHelper
|
|
133
133
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
134
134
|
# @return [void]
|
135
135
|
def array_string_accessor(accessor, description='', alias_accessor=accessor)
|
136
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(StringMapping.new, description))
|
136
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(StringMapping.new(), alias_accessor, description))
|
137
137
|
end
|
138
138
|
|
139
139
|
# @macro [attach] attr_ip_address_accessor
|
@@ -146,7 +146,7 @@ module SavonHelper
|
|
146
146
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
147
147
|
# @return [void]
|
148
148
|
def attr_ip_address_accessor(accessor, description='', alias_accessor=accessor)
|
149
|
-
create_accessor(accessor, alias_accessor, IPAddressMapping.new(description))
|
149
|
+
create_accessor(accessor, alias_accessor, IPAddressMapping.new(alias_accessor, description))
|
150
150
|
end
|
151
151
|
|
152
152
|
# @macro [attach] array_ip_address_accessor
|
@@ -159,7 +159,7 @@ module SavonHelper
|
|
159
159
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
160
160
|
# @return [void]
|
161
161
|
def array_ip_address_accessor(accessor, description='', alias_accessor=accessor)
|
162
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(IPAddressMapping.new, description))
|
162
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(IPAddressMapping.new(), alias_accessor, description))
|
163
163
|
end
|
164
164
|
|
165
165
|
# @macro [attach] attr_datetime_accessor
|
@@ -172,7 +172,7 @@ module SavonHelper
|
|
172
172
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
173
173
|
# @return [void]
|
174
174
|
def attr_datetime_accessor(accessor, description='', alias_accessor=accessor)
|
175
|
-
create_accessor(accessor, alias_accessor, DatetimeMapping.new(description))
|
175
|
+
create_accessor(accessor, alias_accessor, DatetimeMapping.new(alias_accessor, description))
|
176
176
|
end
|
177
177
|
|
178
178
|
# @macro [attach] array_datetime_accessor
|
@@ -185,7 +185,7 @@ module SavonHelper
|
|
185
185
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
186
186
|
# @return [void]
|
187
187
|
def array_datetime_accessor(accessor, description='', alias_accessor=accessor)
|
188
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(DatetimeMapping.new, description))
|
188
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(DatetimeMapping.new(), alias_accessor, description))
|
189
189
|
end
|
190
190
|
|
191
191
|
# @macro [attach] attr_enum_accessor
|
@@ -199,7 +199,7 @@ module SavonHelper
|
|
199
199
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
200
200
|
# @return [void]
|
201
201
|
def attr_enum_accessor(accessor, enum, description='', alias_accessor=accessor)
|
202
|
-
create_accessor(accessor, alias_accessor, EnumMapping.new(enum, description))
|
202
|
+
create_accessor(accessor, alias_accessor, EnumMapping.new(enum, alias_accessor, description))
|
203
203
|
end
|
204
204
|
|
205
205
|
# @macro [attach] array_enum_accessor
|
@@ -213,7 +213,7 @@ module SavonHelper
|
|
213
213
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
214
214
|
# @return [void]
|
215
215
|
def array_enum_accessor(accessor, enum, description='', alias_accessor=accessor)
|
216
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(EnumMapping.new(enum), description))
|
216
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(EnumMapping.new(enum), alias_accessor, description))
|
217
217
|
end
|
218
218
|
|
219
219
|
# @macro [attach] hint_object_accessor
|
@@ -226,7 +226,7 @@ module SavonHelper
|
|
226
226
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
227
227
|
# @return [void]
|
228
228
|
def hint_object_accessor(accessor, klass, description='', alias_accessor=accessor)
|
229
|
-
create_accessor(accessor, alias_accessor, HintMapping.new(klass, description))
|
229
|
+
create_accessor(accessor, alias_accessor, HintMapping.new(klass, alias_accessor, description))
|
230
230
|
end
|
231
231
|
|
232
232
|
# @macro [attach] attr_object_accessor
|
@@ -240,7 +240,7 @@ module SavonHelper
|
|
240
240
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
241
241
|
# @return [void]
|
242
242
|
def attr_object_accessor(accessor, klass, description='', alias_accessor=accessor)
|
243
|
-
create_accessor(accessor, alias_accessor, ObjectMapping.new(klass, description))
|
243
|
+
create_accessor(accessor, alias_accessor, ObjectMapping.new(klass, alias_accessor, description))
|
244
244
|
end
|
245
245
|
|
246
246
|
# @macro [attach] array_object_accessor
|
@@ -254,7 +254,7 @@ module SavonHelper
|
|
254
254
|
# @param alias_accessor [Symbol] An Alias for the accessor
|
255
255
|
# @return [void]
|
256
256
|
def array_object_accessor(accessor, klass, description='', alias_accessor=accessor)
|
257
|
-
create_accessor(accessor, alias_accessor, ArrayMapping.new(ObjectMapping.new(klass, description)))
|
257
|
+
create_accessor(accessor, alias_accessor, ArrayMapping.new(ObjectMapping.new(klass, alias_accessor, description)))
|
258
258
|
end
|
259
259
|
|
260
260
|
private
|
@@ -8,7 +8,8 @@ module SavonHelper
|
|
8
8
|
# A new instance of TypeMapping with description
|
9
9
|
# @param description [String] A String describing the mapping.
|
10
10
|
# @return [TypeMapping]
|
11
|
-
def initialize(description='')
|
11
|
+
def initialize(name='', description='')
|
12
|
+
@name = name
|
12
13
|
@description = description
|
13
14
|
end
|
14
15
|
|
@@ -48,6 +49,21 @@ module SavonHelper
|
|
48
49
|
raise "#{self.class}##{__method__}() not implemented!"
|
49
50
|
end
|
50
51
|
|
52
|
+
# @abstract Return the default value the mapping.
|
53
|
+
# @return [Object]
|
54
|
+
def default_value
|
55
|
+
raise "#{self.class}##{__method__}() not implemented!"
|
56
|
+
end
|
57
|
+
|
58
|
+
# Warn about unparsable mapping
|
59
|
+
# @todo Check if mappings can be derived from klass
|
60
|
+
# @param data [Hash, Object] Source Savon data
|
61
|
+
def warn_unparseable_data(data, interface)
|
62
|
+
message = "Can't parse #{type_string} #{@name.inspect}: #{data.inspect}"
|
63
|
+
interface.logger.warn(message)
|
64
|
+
self.default_value()
|
65
|
+
end
|
66
|
+
|
51
67
|
end
|
52
68
|
|
53
69
|
# BooleanMapping maps Savon data to Ruby Booleans.
|
@@ -84,6 +100,12 @@ module SavonHelper
|
|
84
100
|
"bool"
|
85
101
|
end
|
86
102
|
|
103
|
+
# @abstract Return the default value the mapping.
|
104
|
+
# @return [Object]
|
105
|
+
def default_value
|
106
|
+
false
|
107
|
+
end
|
108
|
+
|
87
109
|
end
|
88
110
|
|
89
111
|
# IntegerMapping maps Savon data to Ruby integers.
|
@@ -118,6 +140,13 @@ module SavonHelper
|
|
118
140
|
def type_string
|
119
141
|
"int"
|
120
142
|
end
|
143
|
+
|
144
|
+
# @abstract Return the default value the mapping.
|
145
|
+
# @return [Object]
|
146
|
+
def default_value
|
147
|
+
0
|
148
|
+
end
|
149
|
+
|
121
150
|
end
|
122
151
|
|
123
152
|
# FloatMapping maps Savon data to Ruby floats.
|
@@ -153,6 +182,12 @@ module SavonHelper
|
|
153
182
|
"float"
|
154
183
|
end
|
155
184
|
|
185
|
+
# @abstract Return the default value the mapping.
|
186
|
+
# @return [Object]
|
187
|
+
def default_value
|
188
|
+
0.0
|
189
|
+
end
|
190
|
+
|
156
191
|
end
|
157
192
|
|
158
193
|
# StringMapping maps Savon data to Ruby strings.
|
@@ -189,6 +224,12 @@ module SavonHelper
|
|
189
224
|
"String"
|
190
225
|
end
|
191
226
|
|
227
|
+
# @abstract Return the default value the mapping.
|
228
|
+
# @return [Object]
|
229
|
+
def default_value
|
230
|
+
""
|
231
|
+
end
|
232
|
+
|
192
233
|
end
|
193
234
|
|
194
235
|
# IPAddressMapping maps Savon data to Ruby IP Address String.
|
@@ -201,6 +242,12 @@ module SavonHelper
|
|
201
242
|
"IPAddress"
|
202
243
|
end
|
203
244
|
|
245
|
+
# @abstract Return the default value the mapping.
|
246
|
+
# @return [Object]
|
247
|
+
def default_value
|
248
|
+
"255.255.255.255"
|
249
|
+
end
|
250
|
+
|
204
251
|
end
|
205
252
|
|
206
253
|
# DatetimeMapping maps Savon data to Ruby DateTimes.
|
@@ -236,6 +283,12 @@ module SavonHelper
|
|
236
283
|
"datetime"
|
237
284
|
end
|
238
285
|
|
286
|
+
# @abstract Return the default value the mapping.
|
287
|
+
# @return [Object]
|
288
|
+
def default_value
|
289
|
+
DateTime.now()
|
290
|
+
end
|
291
|
+
|
239
292
|
end
|
240
293
|
|
241
294
|
# EnumMapping maps Savon integers to Ruby symbols.
|
@@ -244,9 +297,9 @@ module SavonHelper
|
|
244
297
|
# A new instance of EnumMapping with description and enum hash enum.
|
245
298
|
# @param enum [Hash{String => Symbol}] Mapping between Savon Strings and Ruby Symbols.
|
246
299
|
# @param description [String]
|
247
|
-
# @return [
|
248
|
-
def initialize(enum, description='')
|
249
|
-
super(description)
|
300
|
+
# @return [EnumMapping]
|
301
|
+
def initialize(enum, name='', description='')
|
302
|
+
super(name, description)
|
250
303
|
@enum = enum
|
251
304
|
end
|
252
305
|
|
@@ -274,6 +327,12 @@ module SavonHelper
|
|
274
327
|
"enum<#{@enum.values.join(', ')}>"
|
275
328
|
end
|
276
329
|
|
330
|
+
# @abstract Return the default value the mapping.
|
331
|
+
# @return [Object]
|
332
|
+
def default_value
|
333
|
+
:none
|
334
|
+
end
|
335
|
+
|
277
336
|
end
|
278
337
|
|
279
338
|
# HintMapping maps Savon data to Ruby objects of type klass (r/o).
|
@@ -283,8 +342,8 @@ module SavonHelper
|
|
283
342
|
# @param klass [Class] A class returned by the hint accessor
|
284
343
|
# @param description [String]
|
285
344
|
# @return [HintMapping]
|
286
|
-
def initialize(klass, description='')
|
287
|
-
super(description)
|
345
|
+
def initialize(klass, name='', description='')
|
346
|
+
super(name, description)
|
288
347
|
@klass = klass
|
289
348
|
end
|
290
349
|
|
@@ -319,8 +378,8 @@ module SavonHelper
|
|
319
378
|
# @param klass [Class, #to_native] A class which can create instances from Savon data and provide Savon data for export.
|
320
379
|
# @param description [String]
|
321
380
|
# @return [ObjectMapping]
|
322
|
-
def initialize(klass, description='')
|
323
|
-
super(klass, description)
|
381
|
+
def initialize(klass, name='', description='')
|
382
|
+
super(klass, name, description)
|
324
383
|
end
|
325
384
|
|
326
385
|
# @!group Converting
|
@@ -358,7 +417,7 @@ module SavonHelper
|
|
358
417
|
result = to_native(element_mapping, item, interface)
|
359
418
|
end
|
360
419
|
else
|
361
|
-
|
420
|
+
result = warn_unparseable_data(data, interface)
|
362
421
|
end
|
363
422
|
result
|
364
423
|
end
|
@@ -367,8 +426,8 @@ module SavonHelper
|
|
367
426
|
# @param element_mapping [TypeMapping] A TypeMapping for elements
|
368
427
|
# @param description [String]
|
369
428
|
# @return [ArrayMapping]
|
370
|
-
def initialize(element_mapping, description='')
|
371
|
-
super(description)
|
429
|
+
def initialize(element_mapping, name='', description='')
|
430
|
+
super(name, description)
|
372
431
|
@element_mapping = element_mapping
|
373
432
|
end
|
374
433
|
|
@@ -395,6 +454,12 @@ module SavonHelper
|
|
395
454
|
"Array<#{@element_mapping.type_string}>"
|
396
455
|
end
|
397
456
|
|
457
|
+
# @abstract Return the default value the mapping.
|
458
|
+
# @return [Object]
|
459
|
+
def default_value
|
460
|
+
[]
|
461
|
+
end
|
462
|
+
|
398
463
|
end
|
399
464
|
|
400
465
|
# MissingMapping maps Savon data to itself (no conversion).
|
data/lib/savon_helper.rb
CHANGED
@@ -17,6 +17,10 @@ unless String.respond_to? :blank
|
|
17
17
|
def blank?
|
18
18
|
empty?()
|
19
19
|
end
|
20
|
+
|
21
|
+
def strip_comments
|
22
|
+
self.match(/^([^#]*)(#.*$)?/).to_a[1]
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
class NilClass
|
@@ -34,3 +38,14 @@ class Object
|
|
34
38
|
end
|
35
39
|
|
36
40
|
end
|
41
|
+
|
42
|
+
module Kernel
|
43
|
+
alias :oldwarn :warn
|
44
|
+
|
45
|
+
def warn (msg = "", fulltrace = false)
|
46
|
+
trace = caller(1)
|
47
|
+
where = trace[0].sub(/:in.*/, '')
|
48
|
+
$stderr.puts "#{where}: Warning: #{msg}"
|
49
|
+
$stderr.puts trace.map { |t| "\tfrom #{t}" } if fulltrace
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'dsc'
|
3
|
+
|
4
|
+
class TestDscCommand < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_timesfilter_last_hour
|
7
|
+
command = Dsc::Command.new()
|
8
|
+
assert_equal DeepSecurity::TimeFilter.last_hour, command.parse_time_filter("last_hour")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_timesfilter_last_24_hours
|
12
|
+
command = Dsc::Command.new()
|
13
|
+
assert_equal DeepSecurity::TimeFilter.last_hour, command.parse_time_filter("last_hour")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_timesfilter_last_7_days
|
17
|
+
command = Dsc::Command.new()
|
18
|
+
assert_equal DeepSecurity::TimeFilter.last_7_days, command.parse_time_filter("last_7_days")
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_timesfilter_last_day
|
22
|
+
command = Dsc::Command.new()
|
23
|
+
assert_equal DeepSecurity::TimeFilter.last_day, command.parse_time_filter("last_day")
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
def test_timesfilter_timestamp
|
28
|
+
command = Dsc::Command.new()
|
29
|
+
time = Time.new(2002, 10, 31, 2, 2, 2, "+02:00")
|
30
|
+
command.parse_time_format("%Y-%m-%d %H:%M-%S %z")
|
31
|
+
assert_equal "2002-10-31 02:02:02 +0200", command.to_display_string(time)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'deepsecurity'
|
3
|
+
|
4
|
+
class TestSavonHelper < Test::Unit::TestCase
|
5
|
+
def test_blank
|
6
|
+
assert_equal false, "abc".blank?
|
7
|
+
assert_equal true, "".blank?
|
8
|
+
assert_equal true, nil.blank?
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_strip_comments
|
12
|
+
assert_equal "test", "test".strip_comments
|
13
|
+
assert_equal "test ", "test #123".strip_comments
|
14
|
+
assert_equal "", "#123".strip_comments
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_name_without_namespace
|
18
|
+
assert_equal "HostDetail", DeepSecurity::HostDetail.name_without_namespace
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deepsecurity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- bin/dsc
|
158
158
|
- deepsecurity.gemspec
|
159
159
|
- dsc.md
|
160
|
+
- generate_s3_links.sh
|
160
161
|
- lib/deepsecurity.rb
|
161
162
|
- lib/deepsecurity/enums.rb
|
162
163
|
- lib/deepsecurity/exceptions/authentication_failed_exception.rb
|
@@ -196,6 +197,8 @@ files:
|
|
196
197
|
- lib/savon_helper/soap_exception.rb
|
197
198
|
- lib/savon_helper/soap_interface.rb
|
198
199
|
- lib/savon_helper/type_mappings.rb
|
200
|
+
- test/test_dsc_command.rb
|
201
|
+
- test/test_savon_helper.rb
|
199
202
|
- windows-installer/WizModernImage-IS.bmp
|
200
203
|
- windows-installer/WizModernImage.bmp
|
201
204
|
- windows-installer/WizModernSmallImage-IS.bmp
|
@@ -216,17 +219,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
219
|
- - ! '>='
|
217
220
|
- !ruby/object:Gem::Version
|
218
221
|
version: '0'
|
222
|
+
segments:
|
223
|
+
- 0
|
224
|
+
hash: 3193197376613847506
|
219
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
226
|
none: false
|
221
227
|
requirements:
|
222
228
|
- - ! '>='
|
223
229
|
- !ruby/object:Gem::Version
|
224
230
|
version: '0'
|
231
|
+
segments:
|
232
|
+
- 0
|
233
|
+
hash: 3193197376613847506
|
225
234
|
requirements: []
|
226
235
|
rubyforge_project:
|
227
236
|
rubygems_version: 1.8.24
|
228
237
|
signing_key:
|
229
238
|
specification_version: 3
|
230
239
|
summary: Trend Micro DeepSecurity Wrapper
|
231
|
-
test_files:
|
240
|
+
test_files:
|
241
|
+
- test/test_dsc_command.rb
|
242
|
+
- test/test_savon_helper.rb
|
232
243
|
has_rdoc:
|