intrigue_api_client 1.0.5 → 1.2.1
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 +48 -54
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3147774f9cc7bca2a2645b1daeeabb4ec01ff203
|
4
|
+
data.tar.gz: af53daf2a1e68616a2527243e0bdb5b79ce7ec52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e223ecfe1d3c04147f0aa31f0c6da6211f75f2de5cee64a205cccc11d79c1077e225572cbadc04cf87c8c90bb5f4ac6f999d715edc39c2ee09937134e3fef743
|
7
|
+
data.tar.gz: 1629e543d8203c531e65894092756437c5fe5c2d5bc5d4760a61ec83f56c39a4dcb6161208d9979ce1eba4cbf5254ba16d830c8302bac53bcf385acc75193c66
|
data/lib/intrigue_api_client.rb
CHANGED
@@ -4,7 +4,7 @@ require 'rest_client'
|
|
4
4
|
|
5
5
|
class IntrigueApi
|
6
6
|
|
7
|
-
def initialize(uri,key="")
|
7
|
+
def initialize(uri="http://127.0.0.1:7777/v1",key="")
|
8
8
|
@intrigue_basedir = File.dirname(__FILE__)
|
9
9
|
@server_uri = uri
|
10
10
|
end
|
@@ -16,50 +16,23 @@ class IntrigueApi
|
|
16
16
|
|
17
17
|
# Show detailed about a task
|
18
18
|
def info(task_name)
|
19
|
-
_get_json_result "
|
19
|
+
_get_json_result "tasks/#{task_name}.json"
|
20
20
|
end
|
21
21
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
# task_name - must exist as a valid task name
|
26
|
-
# entity_hash - symbol-based hash representing an entity: {
|
27
|
-
# :type => "String"
|
28
|
-
# :attributes => { :name => "intrigue.io"}
|
29
|
-
# }
|
30
|
-
# options_list - list of options: [
|
31
|
-
# {:name => "resolver", :value => "8.8.8.8" }
|
32
|
-
# ]
|
33
|
-
def start_and_background(project_name,task_name,entity_hash,options_list=nil,handler_list=nil)
|
34
|
-
|
35
|
-
payload = {
|
36
|
-
"project_name" => project_name,
|
37
|
-
"task" => task_name,
|
38
|
-
"options" => options_list,
|
39
|
-
"handlers" => handler_list,
|
40
|
-
"entity" => entity_hash
|
41
|
-
}
|
42
|
-
|
43
|
-
### Send to the server
|
44
|
-
task_id = RestClient.post "#{@server_uri}/#{project_name}/task_results",
|
45
|
-
payload.to_json, :content_type => "application/json"
|
46
|
-
|
47
|
-
if task_id == "" # technically a nil is returned , but becomes an empty string
|
48
|
-
#puts "[-] Task not started. Unknown Error. Exiting"
|
49
|
-
return nil
|
50
|
-
end
|
51
|
-
|
52
|
-
task_id
|
22
|
+
# create a new project
|
23
|
+
def create_project(project_name)
|
24
|
+
RestClient.post "#{@server_uri}/project", { "project" => project_name }
|
53
25
|
end
|
54
26
|
|
55
27
|
# Start a task and wait for the result
|
56
|
-
def start(project_name,task_name,entity_hash,options_list=nil,handler_list=nil)
|
28
|
+
def start(project_name,task_name,entity_hash,depth=1,options_list=nil,handler_list=nil, strategy_name="disovery")
|
57
29
|
|
58
30
|
# Construct the request
|
59
|
-
task_id =
|
31
|
+
task_id = _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name)
|
60
32
|
|
61
33
|
if task_id == "" # technically a nil is returned , but becomes an empty string
|
62
34
|
#puts "[-] Task not started. Unknown Error. Exiting"
|
35
|
+
#raise "Problem getting result"
|
63
36
|
return nil
|
64
37
|
end
|
65
38
|
|
@@ -68,50 +41,70 @@ class IntrigueApi
|
|
68
41
|
until complete
|
69
42
|
sleep 1
|
70
43
|
begin
|
71
|
-
|
44
|
+
check_uri = "#{@server_uri}/#{project_name}/results/#{task_id}/complete"
|
45
|
+
response = RestClient.get check_uri
|
72
46
|
complete = true if response == "true"
|
47
|
+
|
48
|
+
return nil if response == ""
|
49
|
+
|
73
50
|
rescue URI::InvalidURIError => e
|
74
|
-
puts "[-] Invalid URI: #{
|
75
|
-
return
|
51
|
+
puts "[-] Invalid URI: #{check_uri}"
|
52
|
+
return nil
|
76
53
|
end
|
77
54
|
end
|
78
55
|
|
79
56
|
### Get the response
|
80
|
-
response = _get_json_result "#{project_name}/
|
57
|
+
response = _get_json_result "#{project_name}/results/#{task_id}.json"
|
58
|
+
#puts response
|
81
59
|
|
82
60
|
response
|
83
61
|
end
|
84
62
|
|
85
|
-
|
86
|
-
|
63
|
+
|
64
|
+
private
|
65
|
+
# start_and_background - start and background a task
|
66
|
+
#
|
67
|
+
# project_name - must exist as a valid project_name
|
68
|
+
# task_name - must exist as a valid task name
|
69
|
+
# entity_hash - symbol-based hash representing an entity: {
|
70
|
+
# :type => "String"
|
71
|
+
# :attributes => { :name => "intrigue.io"}
|
72
|
+
# }
|
73
|
+
# options_list - list of options: [
|
74
|
+
# {:name => "resolver", :value => "8.8.8.8" }
|
75
|
+
# ]
|
76
|
+
def _start_and_background(project_name,task_name,entity_hash,depth,options_list,handler_list, strategy_name)
|
87
77
|
|
88
78
|
payload = {
|
89
79
|
"project_name" => project_name,
|
90
|
-
"
|
80
|
+
"task" => task_name,
|
91
81
|
"options" => options_list,
|
82
|
+
"handlers" => handler_list,
|
92
83
|
"entity" => entity_hash,
|
93
|
-
"
|
84
|
+
"depth" => depth,
|
85
|
+
"strategy_name" => strategy_name
|
94
86
|
}
|
95
87
|
|
96
88
|
### Send to the server
|
97
|
-
|
89
|
+
task_id = RestClient.post "#{@server_uri}/#{project_name}/results",
|
98
90
|
payload.to_json, :content_type => "application/json"
|
99
91
|
|
100
|
-
|
101
|
-
|
92
|
+
if task_id == "" # technically a nil is returned , but becomes an empty string
|
93
|
+
#puts "[-] Task not started. Unknown Error. Exiting"
|
94
|
+
#raise "Problem getting result"
|
102
95
|
return nil
|
103
96
|
end
|
104
97
|
|
105
|
-
|
98
|
+
task_id
|
106
99
|
end
|
107
100
|
|
108
|
-
def
|
109
|
-
log = _get_json_result "#{project_name}/
|
101
|
+
def _get_log(task_id)
|
102
|
+
log = _get_json_result "#{project_name}/results/#{task_id}/log"
|
110
103
|
end
|
111
104
|
|
112
|
-
def
|
105
|
+
def _get_result(task_id)
|
113
106
|
begin
|
114
|
-
result = _get_json_result "#{project_name}/
|
107
|
+
result = _get_json_result "#{project_name}/results/#{task_id}.json"
|
115
108
|
rescue JSON::ParserError => e
|
116
109
|
response = nil
|
117
110
|
end
|
@@ -120,12 +113,13 @@ class IntrigueApi
|
|
120
113
|
|
121
114
|
def _get_json_result(path)
|
122
115
|
begin
|
123
|
-
JSON.parse(RestClient.get "#{@server_uri}/#{path}")
|
116
|
+
result = JSON.parse(RestClient.get "#{@server_uri}/#{path}")
|
124
117
|
rescue JSON::ParserError => e
|
125
118
|
puts "Error: #{e}"
|
126
119
|
rescue RestClient::InternalServerError => e
|
127
120
|
puts "Error: #{e}"
|
128
121
|
end
|
122
|
+
result
|
129
123
|
end
|
130
124
|
|
131
125
|
|
@@ -158,7 +152,7 @@ x = Intrigue.new
|
|
158
152
|
|
159
153
|
x.start "example", entity_hash, options_list
|
160
154
|
id = x.start "search_bing", entity_hash, options_list
|
161
|
-
puts x.
|
162
|
-
puts x.
|
155
|
+
puts x._get_log id
|
156
|
+
puts x._get_result id
|
163
157
|
|
164
158
|
=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.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jcran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|