Module: NoteDataProxy

Included in:
DataProxyAutoLoader
Defined in:
lib/metasploit/framework/data_service/proxy/note_data_proxy.rb

Instance Method Summary collapse

Instance Method Details

#delete_note(opts) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/metasploit/framework/data_service/proxy/note_data_proxy.rb', line 57

def delete_note(opts)
  begin
    self.data_service_operation do |data_service|
      data_service.delete_note(opts)
    end
  rescue => e
    self.log_error(e, "Problem deleting note")
  end
end

#find_or_create_note(opts) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/metasploit/framework/data_service/proxy/note_data_proxy.rb', line 14

def find_or_create_note(opts)
  begin
    # create separate opts for find operation since the report operation uses slightly different keys
    # TODO: standardize option keys used for the find and report operations
    find_opts = opts.clone
    # convert type to ntype
    find_opts[:ntype] = find_opts.delete(:type) if find_opts.key?(:type)
    # convert host to nested hosts address
    find_opts[:hosts] = {address: find_opts.delete(:host)} if find_opts.key?(:host)

    note = notes(find_opts)
    if note.nil? || note.first.nil?
      note = report_note(opts.clone)
    else
      note = note.first
    end
    note
  rescue => e
    self.log_error(e, "Problem finding or creating note")
  end
end

#notes(opts) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/metasploit/framework/data_service/proxy/note_data_proxy.rb', line 3

def notes(opts)
  begin
    self.data_service_operation do |data_service|
      add_opts_workspace(opts)
      data_service.notes(opts)
    end
  rescue => e
    self.log_error(e, "Problem retrieving notes")
  end
end

#report_note(opts) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/metasploit/framework/data_service/proxy/note_data_proxy.rb', line 36

def report_note(opts)
  begin
    self.data_service_operation do |data_service|
      add_opts_workspace(opts)
      data_service.report_note(opts)
    end
  rescue => e
    self.log_error(e, "Problem reporting note")
  end
end

#update_note(opts) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/metasploit/framework/data_service/proxy/note_data_proxy.rb', line 47

def update_note(opts)
  begin
    self.data_service_operation do |data_service|
      data_service.update_note(opts)
    end
  rescue => e
    self.log_error(e, "Problem updating note")
  end
end