tigre-client 0.3.6 → 0.3.7
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/.gitignore +2 -0
- data/Gemfile.lock +5 -3
- data/lib/tigre-client.rb +19 -25
- data/lib/tigre-client/analysis.rb +40 -0
- data/lib/tigre-client/common_params.rb +5 -0
- data/lib/tigre-client/sample.rb +56 -2
- data/lib/tigre-client/scan.rb +5 -0
- data/lib/tigre-client/url.rb +57 -11
- data/lib/tigre-client/version.rb +1 -1
- data/tigre-client.gemspec +1 -0
- metadata +17 -4
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tigre-client (0.3.
|
4
|
+
tigre-client (0.3.6)
|
5
5
|
faraday (~> 0.6.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
addressable (2.2.
|
10
|
+
addressable (2.2.5)
|
11
11
|
diff-lcs (1.1.2)
|
12
|
-
faraday (0.6.
|
12
|
+
faraday (0.6.1)
|
13
13
|
addressable (~> 2.2.4)
|
14
14
|
multipart-post (~> 1.1.0)
|
15
15
|
rack (< 2, >= 1.1.0)
|
16
|
+
json (1.5.1)
|
16
17
|
multipart-post (1.1.0)
|
17
18
|
rack (1.2.2)
|
18
19
|
rspec (2.5.0)
|
@@ -28,5 +29,6 @@ PLATFORMS
|
|
28
29
|
ruby
|
29
30
|
|
30
31
|
DEPENDENCIES
|
32
|
+
json
|
31
33
|
rspec
|
32
34
|
tigre-client!
|
data/lib/tigre-client.rb
CHANGED
@@ -6,6 +6,7 @@ require 'tigre-client/common_params'
|
|
6
6
|
require 'tigre-client/occurrence'
|
7
7
|
require 'tigre-client/sample'
|
8
8
|
require 'tigre-client/url'
|
9
|
+
require 'tigre-client/analysis'
|
9
10
|
|
10
11
|
module Tigre
|
11
12
|
|
@@ -22,18 +23,8 @@ module Tigre
|
|
22
23
|
builder.adapter :net_http
|
23
24
|
end
|
24
25
|
end
|
25
|
-
|
26
|
-
|
27
|
-
# the multipart in the post_put?
|
28
|
-
def build_post_put_connection
|
29
|
-
@conn = Faraday.new(:url => "#{Tigre.server}") do |builder|
|
30
|
-
# builder.request :multipart
|
31
|
-
builder.request :url_encoded
|
32
|
-
builder.adapter :net_http
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def build_file_post_put_connection
|
26
|
+
|
27
|
+
def build_post_connection
|
37
28
|
@conn = Faraday.new(:url => "#{Tigre.server}") do |builder|
|
38
29
|
builder.use Faraday::Request::MultipartWithFile
|
39
30
|
builder.use Faraday::Request::Multipart
|
@@ -49,31 +40,34 @@ module Tigre
|
|
49
40
|
end
|
50
41
|
|
51
42
|
def post_connection(uri_string, data)
|
52
|
-
|
43
|
+
build_post_connection
|
53
44
|
response = Tigre.conn.post do |req|
|
54
45
|
req.url Tigre.endpoint + uri_string
|
55
46
|
req.headers['API-TOKEN'] = Tigre.token
|
56
|
-
req.body
|
47
|
+
req.body = data
|
57
48
|
end
|
58
49
|
[response.status, response.body]
|
59
50
|
end
|
60
51
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
52
|
+
# TODO do we need a post_connection and a post_file_connection?
|
53
|
+
# def post_file_connection(uri_string, data)
|
54
|
+
# build_post_connection
|
55
|
+
#
|
56
|
+
# response = Tigre.conn.post do |req|
|
57
|
+
# req.url Tigre.endpoint + uri_string
|
58
|
+
# req.headers['API-TOKEN'] = Tigre.token
|
59
|
+
# req.body = data
|
60
|
+
# end
|
61
|
+
# [response.status, response.body]
|
62
|
+
# end
|
70
63
|
|
71
64
|
def put_connection(uri_string, data)
|
72
|
-
|
65
|
+
build_post_connection
|
66
|
+
|
73
67
|
response = Tigre.conn.put do |req|
|
74
68
|
req.url Tigre.endpoint + uri_string
|
75
69
|
req.headers['API-TOKEN'] = Tigre.token
|
76
|
-
req.body
|
70
|
+
req.body = data
|
77
71
|
end
|
78
72
|
[response.status, response.body]
|
79
73
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Tigre
|
2
|
+
class Analysis
|
3
|
+
|
4
|
+
# required
|
5
|
+
# analysis_id => String
|
6
|
+
# params_hash => Hash
|
7
|
+
# :dbts => Hash {:key1 => value, :key2 => value} where the key is what the name of the
|
8
|
+
# attribute is and the value should be a boolean
|
9
|
+
# :mutex_name_list => String (comma seperated) => I.E 'foo,bar,baz'
|
10
|
+
# :mutex_name_list => Array => ['foo', 'bar', 'baz']
|
11
|
+
def self.update(analysis_id, params_hash)
|
12
|
+
if analysis_id == '' || params_hash.empty?
|
13
|
+
raise "Missing analysis_id parameter or params_hash is empty"
|
14
|
+
end
|
15
|
+
|
16
|
+
update_data = {}
|
17
|
+
if params_hash[:mutex_name_list]
|
18
|
+
params_hash[:mutex_name_list] = package_array_list(params_hash[:mutex_name_list])
|
19
|
+
end
|
20
|
+
update_data["metadatas"] = params_hash
|
21
|
+
|
22
|
+
Tigre.put_connection("/analysis/#{analysis_id}", update_data)
|
23
|
+
end
|
24
|
+
|
25
|
+
# required
|
26
|
+
# analysis_id => String
|
27
|
+
# file_location => String path to the file
|
28
|
+
# file_type => String, the type of the file
|
29
|
+
def self.add_file(analysis_id, file_location, file_type)
|
30
|
+
if analysis_id == '' || file_location.empty? || file_type.empty?
|
31
|
+
raise "Missing analysis_id, file_location, or file_type parameter"
|
32
|
+
end
|
33
|
+
|
34
|
+
update_data = {:file => File.new(file_location), :file_type => file_type}
|
35
|
+
|
36
|
+
Tigre.put_connection("/analysis/#{analysis_id}/upload", update_data)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/tigre-client/sample.rb
CHANGED
@@ -19,7 +19,7 @@ module Tigre
|
|
19
19
|
options[:tags] = package_array_list(options[:tags]) if options[:tags]
|
20
20
|
|
21
21
|
post_data = {:file => File.new(file_location), :md5 => md5}
|
22
|
-
Tigre.
|
22
|
+
Tigre.post_connection('/samples', post_data.merge(options))
|
23
23
|
end
|
24
24
|
|
25
25
|
# optional params
|
@@ -260,7 +260,61 @@ module Tigre
|
|
260
260
|
hash[:digest] = hash[:digest] || 'md5'
|
261
261
|
hash[:samples] = package_array_list(hash[:samples])
|
262
262
|
hash[:type] = 'compressor'
|
263
|
-
Tigre.
|
263
|
+
Tigre.post_connection('/samples_for_compression', hash)
|
264
|
+
end
|
265
|
+
|
266
|
+
# required
|
267
|
+
# digest_hash => Hash
|
268
|
+
# :digest => String, The digest type
|
269
|
+
# :value => String, The digest value
|
270
|
+
# optional params
|
271
|
+
# params_hash => Hash
|
272
|
+
# :dbts => Hash {:key1 => value, :key2 => value} where the key is what the name of the
|
273
|
+
# attribute is and the value should be a boolean
|
274
|
+
# :mutex_name_list => String (comma seperated) => I.E 'foo,bar,baz'
|
275
|
+
# :mutex_name_list => Array => ['foo', 'bar', 'baz']
|
276
|
+
def self.add_analysis(digest_hash, params_hash={})
|
277
|
+
unless digest_hash[:digest] && digest_hash[:value]
|
278
|
+
raise 'Missing parameter :digest or :value'
|
279
|
+
end
|
280
|
+
|
281
|
+
if params_hash
|
282
|
+
update_data = {}
|
283
|
+
if params_hash[:mutex_name_list]
|
284
|
+
params_hash[:mutex_name_list] = package_array_list(params_hash[:mutex_name_list])
|
285
|
+
end
|
286
|
+
|
287
|
+
update_data["metadatas"] = params_hash
|
288
|
+
end
|
289
|
+
|
290
|
+
Tigre.put_connection("/samples/#{digest_hash[:digest]}/value/#{digest_hash[:value]}/analysis", update_data)
|
291
|
+
end
|
292
|
+
|
293
|
+
# optional params
|
294
|
+
# options => Hash
|
295
|
+
# :after => Ruby DateTime object OR Integer (epoch time)
|
296
|
+
# :before => Ruby DateTime object OR Integer (epoch time)
|
297
|
+
def self.count(options={})
|
298
|
+
common_params(options)
|
299
|
+
Tigre.get_connection("/samples/count?after=#{@after}&before=#{@before}")
|
300
|
+
end
|
301
|
+
|
302
|
+
# required params
|
303
|
+
# tags => String => I.E 'foo'
|
304
|
+
# tags => String (comma seperated) => I.E 'foo,bar,baz'
|
305
|
+
# tags => Array => ['foo', 'bar', 'baz']
|
306
|
+
# optional params
|
307
|
+
# options => Hash
|
308
|
+
# :after => Ruby DateTime object OR Integer (epoch time)
|
309
|
+
# :before => Ruby DateTime object OR Integer (epoch time)
|
310
|
+
def self.tagged_count(tags, options={})
|
311
|
+
if tags == ''
|
312
|
+
raise "Missing tags parameter"
|
313
|
+
end
|
314
|
+
|
315
|
+
tags = package_array_list(tags)
|
316
|
+
common_params(options)
|
317
|
+
Tigre.get_connection("/samples/tagged_with?tags=#{tags}&after=#{@after}&before=#{@before}")
|
264
318
|
end
|
265
319
|
|
266
320
|
end
|
data/lib/tigre-client/url.rb
CHANGED
@@ -125,15 +125,6 @@ module Tigre
|
|
125
125
|
raise ArguementError, "Missing domain parameter"
|
126
126
|
end
|
127
127
|
|
128
|
-
# if options[:after] && options[:after].is_a?(Time)
|
129
|
-
# options[:after] = options[:after].to_i
|
130
|
-
# end
|
131
|
-
# if options[:before] && options[:before].is_a?(Time)
|
132
|
-
# options[:before] = options[:before].to_i
|
133
|
-
# end
|
134
|
-
#
|
135
|
-
# options[:page] ||= 0
|
136
|
-
# options[:per] ||= 50
|
137
128
|
common_params(options)
|
138
129
|
Tigre.get_connection("/urls/domains?domain=#{domain}&after=#{@after}&before=#{@before}&page=#{@page}&per=#{@per}")
|
139
130
|
end
|
@@ -155,7 +146,8 @@ module Tigre
|
|
155
146
|
|
156
147
|
tags = package_array_list(tags)
|
157
148
|
common_params(options)
|
158
|
-
|
149
|
+
logic = get_logic_param(options[:logic])
|
150
|
+
Tigre.get_connection("/urls/tagged_with?tags=#{tags}&logic=#{logic}&after=#{@after}&before=#{@before}&page=#{@page}&per=#{@per}")
|
159
151
|
end
|
160
152
|
|
161
153
|
# required params
|
@@ -170,7 +162,7 @@ module Tigre
|
|
170
162
|
end
|
171
163
|
|
172
164
|
update_data = {"tag_list" => package_array_list(hash[:tag_list])}
|
173
|
-
Tigre.put_connection("/urls/#{hash[:digest]}/value/#{hash[:value]}/remove_tags", update_data)
|
165
|
+
Tigre.put_connection("/urls/#{hash[:digest]}/value/#{hash[:value]}/remove_tags", update_data)
|
174
166
|
end
|
175
167
|
|
176
168
|
# required params
|
@@ -204,6 +196,60 @@ module Tigre
|
|
204
196
|
Tigre.get_connection("/urls/not_tagged?after=#{@after}&before=#{@before}&page=#{@page}&per=#{@per}")
|
205
197
|
end
|
206
198
|
|
199
|
+
# required
|
200
|
+
# digest_hash => Hash
|
201
|
+
# :digest => String, The digest type
|
202
|
+
# :value => String, The digest value
|
203
|
+
# optional params
|
204
|
+
# params_hash => Hash
|
205
|
+
# :dbts => Hash {:key1 => value, :key2 => value} where the key is what the name of the
|
206
|
+
# attribute is and the value should be a boolean
|
207
|
+
# :mutex_name_list => String (comma seperated) => I.E 'foo,bar,baz'
|
208
|
+
# :mutex_name_list => Array => ['foo', 'bar', 'baz']
|
209
|
+
def self.add_analysis(digest_hash, params_hash={})
|
210
|
+
unless digest_hash[:digest] && digest_hash[:value]
|
211
|
+
raise 'Missing parameter :digest or :value'
|
212
|
+
end
|
213
|
+
|
214
|
+
if params_hash
|
215
|
+
update_data = {}
|
216
|
+
if params_hash[:mutex_name_list]
|
217
|
+
params_hash[:mutex_name_list] = package_array_list(params_hash[:mutex_name_list])
|
218
|
+
end
|
219
|
+
|
220
|
+
update_data["metadatas"] = params_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
Tigre.put_connection("/urls/#{digest_hash[:digest]}/value/#{digest_hash[:value]}/analysis", update_data)
|
224
|
+
end
|
225
|
+
|
226
|
+
# optional params
|
227
|
+
# options => Hash
|
228
|
+
# :after => Ruby DateTime object OR Integer (epoch time)
|
229
|
+
# :before => Ruby DateTime object OR Integer (epoch time)
|
230
|
+
def self.count(options={})
|
231
|
+
common_params(options)
|
232
|
+
Tigre.get_connection("/urls/count?after=#{@after}&before=#{@before}")
|
233
|
+
end
|
234
|
+
|
235
|
+
# required params
|
236
|
+
# tags => String => I.E 'foo'
|
237
|
+
# tags => String (comma seperated) => I.E 'foo,bar,baz'
|
238
|
+
# tags => Array => ['foo', 'bar', 'baz']
|
239
|
+
# optional params
|
240
|
+
# options => Hash
|
241
|
+
# :after => Ruby DateTime object OR Integer (epoch time)
|
242
|
+
# :before => Ruby DateTime object OR Integer (epoch time)
|
243
|
+
def self.tagged_count(tags, options={})
|
244
|
+
if tags == ''
|
245
|
+
raise "Missing tags parameter"
|
246
|
+
end
|
247
|
+
|
248
|
+
tags = package_array_list(tags)
|
249
|
+
common_params(options)
|
250
|
+
Tigre.get_connection("/urls/tagged_with?tags=#{tags}&after=#{@after}&before=#{@before}")
|
251
|
+
end
|
252
|
+
|
207
253
|
end
|
208
254
|
|
209
255
|
end
|
data/lib/tigre-client/version.rb
CHANGED
data/tigre-client.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tigre-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Marcio Castilho
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-05-
|
14
|
+
date: 2011-05-04 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -26,16 +26,27 @@ dependencies:
|
|
26
26
|
type: :development
|
27
27
|
version_requirements: *id001
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: json
|
30
30
|
prerelease: false
|
31
31
|
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: "0"
|
37
|
+
type: :development
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: faraday
|
41
|
+
prerelease: false
|
42
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
32
43
|
none: false
|
33
44
|
requirements:
|
34
45
|
- - ~>
|
35
46
|
- !ruby/object:Gem::Version
|
36
47
|
version: 0.6.0
|
37
48
|
type: :runtime
|
38
|
-
version_requirements: *
|
49
|
+
version_requirements: *id003
|
39
50
|
description: Tigre Client API Library
|
40
51
|
email:
|
41
52
|
- marcioc@sunbelt-software.com
|
@@ -53,10 +64,12 @@ files:
|
|
53
64
|
- Gemfile.lock
|
54
65
|
- Rakefile
|
55
66
|
- lib/tigre-client.rb
|
67
|
+
- lib/tigre-client/analysis.rb
|
56
68
|
- lib/tigre-client/common_params.rb
|
57
69
|
- lib/tigre-client/multipart_with_file.rb
|
58
70
|
- lib/tigre-client/occurrence.rb
|
59
71
|
- lib/tigre-client/sample.rb
|
72
|
+
- lib/tigre-client/scan.rb
|
60
73
|
- lib/tigre-client/url.rb
|
61
74
|
- lib/tigre-client/version.rb
|
62
75
|
- tigre-client.gemspec
|