Module: RemoteHostDataService

Includes:
ResponseDataHelper
Included in:
DataServiceAutoLoader
Defined in:
lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb

Constant Summary collapse

HOST_API_PATH =
'/api/v1/hosts'
HOST_SEARCH_PATH =
HOST_API_PATH + "/search"
HOST_MDM_CLASS =
'Mdm::Host'
TAG_MDM_CLASS =
'Mdm::Tag'

Instance Method Summary collapse

Methods included from ResponseDataHelper

#json_to_hash, #json_to_mdm_object, #process_file, #to_ar

Instance Method Details

#add_host_tag(opts) ⇒ Object


42
43
44
45
# File 'lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb', line 42

def add_host_tag(opts)
  path = get_path_select(opts, HOST_API_PATH) + '/tags'
  json_to_mdm_object(self.post_data(path, opts, nil), TAG_MDM_CLASS)
end

#delete_host(opts) ⇒ Object


33
34
35
# File 'lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb', line 33

def delete_host(opts)
  json_to_mdm_object(self.delete_data(HOST_API_PATH, opts), HOST_MDM_CLASS)
end

#delete_host_tag(opts) ⇒ Object


47
48
49
50
# File 'lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb', line 47

def delete_host_tag(opts)
  path = get_path_select(opts, HOST_API_PATH) + '/tags'
  json_to_mdm_object(self.delete_data(path, opts, nil), TAG_MDM_CLASS)
end

#get_host(opts) ⇒ Object


16
17
18
# File 'lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb', line 16

def get_host(opts)
  json_to_mdm_object(self.post_data(HOST_SEARCH_PATH, opts), HOST_MDM_CLASS).first
end

#get_host_tags(opts) ⇒ Object


37
38
39
40
# File 'lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb', line 37

def get_host_tags(opts)
  path = get_path_select(opts, HOST_API_PATH) + '/tags'
  json_to_mdm_object(self.get_data(path, opts, nil), TAG_MDM_CLASS)
end

#hosts(opts) ⇒ Object


11
12
13
14
# File 'lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb', line 11

def hosts(opts)
  path = get_path_select(opts, HOST_API_PATH)
  json_to_mdm_object(self.get_data(path, nil, opts), HOST_MDM_CLASS)
end

#report_host(opts) ⇒ Object


20
21
22
# File 'lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb', line 20

def report_host(opts)
  json_to_mdm_object(self.post_data(HOST_API_PATH, opts), HOST_MDM_CLASS).first
end

#update_host(opts) ⇒ Object


24
25
26
27
28
29
30
31
# File 'lib/metasploit/framework/data_service/remote/http/remote_host_data_service.rb', line 24

def update_host(opts)
  path = HOST_API_PATH
  if opts && opts[:id]
    id = opts.delete(:id)
    path = "#{HOST_API_PATH}/#{id}"
  end
  json_to_mdm_object(self.put_data(path, opts), HOST_MDM_CLASS)
end