intrigue_api_client 1.2.1 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/intrigue_api_client.rb +26 -13
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8991b5360d09dddedc617f5bad8045366bf10390
|
4
|
+
data.tar.gz: 9ae6d67e2f361eac8a9a6e70dc78678aafb0de4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc13fb3ad3c4fa38c10634aace5b4260ea10bcb6d11ab56ddaecb5715502776108c9c98a4e2896b697234cec383daa15afe7a433214651b6565afa9d9427e6d
|
7
|
+
data.tar.gz: 988996a44ad909f85b160b3f421f435b0bf14c5dc27c98870badde1b3af542d68ada233b88f2907f9a275301baf7407f940c06e51a69d68abee4ca50bf603847
|
data/lib/intrigue_api_client.rb
CHANGED
@@ -4,6 +4,10 @@ require 'rest_client'
|
|
4
4
|
|
5
5
|
class IntrigueApi
|
6
6
|
|
7
|
+
def self.version
|
8
|
+
"1.2.4"
|
9
|
+
end
|
10
|
+
|
7
11
|
def initialize(uri="http://127.0.0.1:7777/v1",key="")
|
8
12
|
@intrigue_basedir = File.dirname(__FILE__)
|
9
13
|
@server_uri = uri
|
@@ -24,16 +28,24 @@ class IntrigueApi
|
|
24
28
|
RestClient.post "#{@server_uri}/project", { "project" => project_name }
|
25
29
|
end
|
26
30
|
|
31
|
+
def background(project_name,task_name,entity_hash,depth=1,options_list=nil,handler_list=nil, strategy_name=nil, auto_enrich=true)
|
32
|
+
# Construct the request
|
33
|
+
task_id = _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name, auto_enrich)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
27
37
|
# Start a task and wait for the result
|
28
|
-
def start(project_name,task_name,entity_hash,depth=1,options_list=nil,handler_list=nil, strategy_name=
|
38
|
+
def start(project_name,task_name,entity_hash,depth=1,options_list=nil,handler_list=nil, strategy_name=nil, auto_enrich=true)
|
29
39
|
|
30
40
|
# Construct the request
|
31
|
-
task_id = _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name)
|
41
|
+
task_id = _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name, auto_enrich)
|
32
42
|
|
33
43
|
if task_id == "" # technically a nil is returned , but becomes an empty string
|
34
44
|
#puts "[-] Task not started. Unknown Error. Exiting"
|
35
|
-
|
45
|
+
raise "Problem getting result"
|
36
46
|
return nil
|
47
|
+
else
|
48
|
+
#puts "[+] Got Task ID: #{task_id}"
|
37
49
|
end
|
38
50
|
|
39
51
|
### XXX - wait to collect the response
|
@@ -41,21 +53,21 @@ class IntrigueApi
|
|
41
53
|
until complete
|
42
54
|
sleep 1
|
43
55
|
begin
|
56
|
+
|
44
57
|
check_uri = "#{@server_uri}/#{project_name}/results/#{task_id}/complete"
|
58
|
+
#puts "[+] Checking: #{check_uri}"
|
45
59
|
response = RestClient.get check_uri
|
46
60
|
complete = true if response == "true"
|
47
|
-
|
48
|
-
return nil if response == ""
|
61
|
+
#return nil if response == ""
|
49
62
|
|
50
63
|
rescue URI::InvalidURIError => e
|
51
|
-
puts "[-] Invalid URI: #{check_uri}"
|
64
|
+
#puts "[-] Invalid URI: #{check_uri}"
|
52
65
|
return nil
|
53
66
|
end
|
54
67
|
end
|
55
68
|
|
56
69
|
### Get the response
|
57
70
|
response = _get_json_result "#{project_name}/results/#{task_id}.json"
|
58
|
-
#puts response
|
59
71
|
|
60
72
|
response
|
61
73
|
end
|
@@ -73,7 +85,7 @@ class IntrigueApi
|
|
73
85
|
# options_list - list of options: [
|
74
86
|
# {:name => "resolver", :value => "8.8.8.8" }
|
75
87
|
# ]
|
76
|
-
def _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name)
|
88
|
+
def _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name, auto_enrich)
|
77
89
|
|
78
90
|
payload = {
|
79
91
|
"project_name" => project_name,
|
@@ -82,7 +94,8 @@ class IntrigueApi
|
|
82
94
|
"handlers" => handler_list,
|
83
95
|
"entity" => entity_hash,
|
84
96
|
"depth" => depth,
|
85
|
-
"strategy_name" => strategy_name
|
97
|
+
"strategy_name" => strategy_name,
|
98
|
+
"auto_enrich" => auto_enrich
|
86
99
|
}
|
87
100
|
|
88
101
|
### Send to the server
|
@@ -115,9 +128,9 @@ class IntrigueApi
|
|
115
128
|
begin
|
116
129
|
result = JSON.parse(RestClient.get "#{@server_uri}/#{path}")
|
117
130
|
rescue JSON::ParserError => e
|
118
|
-
puts "Error: #{e}"
|
131
|
+
#puts "Error: #{e}"
|
119
132
|
rescue RestClient::InternalServerError => e
|
120
|
-
puts "Error: #{e}"
|
133
|
+
#puts "Error: #{e}"
|
121
134
|
end
|
122
135
|
result
|
123
136
|
end
|
@@ -152,7 +165,7 @@ x = Intrigue.new
|
|
152
165
|
|
153
166
|
x.start "example", entity_hash, options_list
|
154
167
|
id = x.start "search_bing", entity_hash, options_list
|
155
|
-
puts x._get_log id
|
156
|
-
puts x._get_result id
|
168
|
+
#puts x._get_log id
|
169
|
+
#puts x._get_result id
|
157
170
|
|
158
171
|
=end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intrigue_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jcran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.6.8
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: API client for intrigue-core
|