Class: DeepSecurity::SOAPInterface

Inherits:
SavonHelper::SOAPInterface show all
Defined in:
lib/deepsecurity/manager.rb,
lib/deepsecurity/soap_interface.rb,
lib/deepsecurity/transport_objects/host.rb,
lib/deepsecurity/transport_objects/host_group.rb,
lib/deepsecurity/transport_objects/host_detail.rb,
lib/deepsecurity/transport_objects/anti_malware_event.rb

Instance Attribute Summary collapse

Low-Level SOAP Wrapper collapse

Request Helper collapse

Instance Method Summary collapse

Methods inherited from SavonHelper::SOAPInterface

#logger, #request_array, #request_object, #retryable, #send_soap

Constructor Details

#initialize(hostname, port = 4119, logger, log_level) ⇒ SOAPInterface

Obtain a new wrapper around the DeepSecurity Manager SOAP API.



10
11
12
13
14
15
16
17
18
19
# File 'lib/deepsecurity/soap_interface.rb', line 10

def initialize(hostname, port=4119, logger, log_level)
  @hostname = hostname
  @port = port
  super("https://#{hostname}:#{port}/webservice/Manager?WSDL",
        logger,
        log_level,
        {:convert_request_keys_to => :none, # or one of [:lower_camelcase, :upcase, :none]
         :ssl_verify_mode => :none})

end

Instance Attribute Details

#managerObject

Returns the value of attribute manager.



7
8
9
# File 'lib/deepsecurity/soap_interface.rb', line 7

def manager
  @manager
end

Instance Method Details

#antiMalwareEventRetrieve(timeFilter, hostFilter, eventIdFilter, sID = manager.sID) ⇒ Object

Retrieves the AntiMalware events specified by the time and host filter.

SYNTAX public AntiMalwareEventListTransport antiMalwareEventRetrieve(TimeFilterTransport timeFilter HostFilterTransport hostFilter, IDFilterTransport eventIdFilter, String sID)

PARAMETERS timeFilter Restricts the retrieved events by time. hostFilter Restricts the retrieved events by host, group, or security profile. eventIdFilter Restricts the retrieved events by event id. sID Authentication session identifier ID.

RETURNS AntiMalwareEventListTransport object.



103
104
105
106
107
108
109
# File 'lib/deepsecurity/transport_objects/anti_malware_event.rb', line 103

def antiMalwareEventRetrieve(timeFilter, hostFilter, eventIdFilter, sID = manager.sID)
  request_array(:anti_malware_event_retrieve, AntiMalwareEvent, :anti_malware_events,
                :timeFilter => timeFilter.to_savon,
                :hostFilter => hostFilter.to_savon,
                :eventIdFilter => eventIdFilter.to_savon,
                :sID => sID)
end

#authenticate(username, password) ⇒ Object

Authenticates a user for and returns a session ID for use when calling other Web Service methods.

SYNTAX String authenticate(String username, String password)

PARAMETERS username Account username. password Account password.

RETURNS Authenticated user session ID.



119
120
121
# File 'lib/deepsecurity/manager.rb', line 119

def authenticate(username, password)
  send_soap(:authenticate, {:username => username, :password => password})
end

#authenticateTenant(tenantName, username, password) ⇒ Object

Authenticates a user within the given tenant, and returns a session ID for use when calling other methods of Manager. When no longer required, the session should be terminated by calling endSession.

SYNTAX String authenticateTenant(String tenantName, String username, String password)

PARAMETERS tenantName Tenant Name. username Account username. password Account password.

RETURNS Authenticated user session ID.



135
136
137
# File 'lib/deepsecurity/manager.rb', line 135

def authenticateTenant(tenantName, username, password)
  send_soap(:authenticate_tenant, {:tenantName => tenantName, :username => username, :password => password})
end

#endSession(sID = manager.sID) ⇒ Object

Ends an authenticated user session. The Web Service client should end the authentication session in all exit cases.

SYNTAX void endSession(String sID)

PARAMETERS sID Authentication session identifier ID. RETURNS



147
148
149
# File 'lib/deepsecurity/manager.rb', line 147

def endSession(sID = manager.sID)
  send_soap(:end_session, :sID => sID)
end

#getApiVersionObject

Retrieves the Manager Web Service API version. Not the same as the Manager version.

SYNTAX int getApiVersion()

PARAMETERS

RETURNS The Web Service API version.



91
92
93
# File 'lib/deepsecurity/manager.rb', line 91

def getApiVersion
  send_soap(:get_api_version)
end

#getManagerTimeObject

Retrieve the Manager Web Service API version. Not the same as the Manager version.

SYNTAX getManagerTime()

PARAMETERS

RETURNS Manager time as a language localized object. For example, a Java client would return a Calendar object, and a C# client would return a DataTime object.



104
105
106
# File 'lib/deepsecurity/manager.rb', line 104

def getManagerTime
  send_soap(:get_manager_time)
end

#hostDetailRetrieve(hostFilter, hostDetailLevel, sID = manager.sID) ⇒ Object

Retrieves the detail information of hosts.

SYNTAX public HostDetailTransport[] hostDetailRetrieve(HostFilterTransport hostFilter, EnumHostDetailLevel hostDetailLevel, String sID)

PARAMETERS hostFilter Restricts the retrieved hosts by host, group, or security profile hostDetailLevel The detail level sID Authentication session identifier ID.

RETURNS HostDetailTransport object array.



138
139
140
141
142
143
# File 'lib/deepsecurity/transport_objects/host_detail.rb', line 138

def hostDetailRetrieve(hostFilter, hostDetailLevel, sID = manager.sID)
  request_array(:host_detail_retrieve, HostDetail, nil,
                :hostFilter => hostFilter.to_savon,
                :hostDetailLevel => EnumHostDetailLevel.key(hostDetailLevel),
                :sID => sID)
end

#hostGroupRetrieve(id, sID = manager.sID) ⇒ Object

Retrieves a Host Group by ID.

SYNTAX HostGroupTransport hostGroupRetrieve(int ID, String sID)

PARAMETERS ID Identifying Host Group ID. sID Authentication session identifier ID.

RETURNS HostGroupTransport object.



100
101
102
103
104
# File 'lib/deepsecurity/transport_objects/host_group.rb', line 100

def hostGroupRetrieve(id, sID = manager.sID)
  request_object(:host_group_retrieve, HostGroup,
                 :id => id,
                 :sID => sID)
end

#hostGroupRetrieveAll(sID = manager.sID) ⇒ Object

Retrieves all Host Groups.

SYNTAX HostGroupTransport[] hostGroupRetrieveAll(String sID)

PARAMETERS sID Authentication session identifier ID.

RETURNS HostGroupTransport object array.



84
85
86
87
# File 'lib/deepsecurity/transport_objects/host_group.rb', line 84

def hostGroupRetrieveAll(sID = manager.sID)
  request_array(:host_group_retrieve_all, HostGroup, nil,
                :sID => sID)
end

#hostGroupRetrieveByName(name, sID = manager.sID) ⇒ Object

Retrieves a Host Group by name.

SYNTAX HostGroupTransport hostGroupRetrieveByName(String Name, String sID)

PARAMETERS Name Identifying Host Group name. sID Authentication session identifier ID.

RETURNS HostGroupTransport object.



118
119
120
121
122
# File 'lib/deepsecurity/transport_objects/host_group.rb', line 118

def hostGroupRetrieveByName(name, sID = manager.sID)
  request_object(:host_group_retrieve_by_name, HostGroup,
                 :name => name,
                 :sID => sID)
end

#hostRetrieve(id, sID = manager.sID) ⇒ Object

Retrieves a Host by ID.

SYNTAX HostTransport hostRetrieve(int ID, String sID)

PARAMETERS ID Host ID. sID Authentication session identifier ID.

RETURNS HostTransport object.



165
166
167
# File 'lib/deepsecurity/transport_objects/host.rb', line 165

def hostRetrieve(id, sID = manager.sID)
  request_object(:host_retrieve, Host, :id => id, :sID => sID)
end

#hostRetrieveAll(sID = manager.sID) ⇒ Object

Retrieves Hosts.

SYNTAX HostTransport[] hostRetrieveAll(String sID)

PARAMETERS sID Authentication session identifier ID.

RETURNS HostTransport object array.



149
150
151
152
# File 'lib/deepsecurity/transport_objects/host.rb', line 149

def hostRetrieveAll(sID = manager.sID)
  request_array(:host_retrieve_all, Host, nil,
                :sID => sID)
end

#hostRetrieveByName(hostname, sID = manager.sID) ⇒ Object

Retrieves a Host by name.

SYNTAX HostTransport hostRetrieveByName(String hostname, String sID)

PARAMETERS hostname Host name. sID Authentication session identifier ID.

RETURNS HostTransport object.



180
181
182
# File 'lib/deepsecurity/transport_objects/host.rb', line 180

def hostRetrieveByName(hostname, sID = manager.sID)
  request_object(:host_retrieve_by_name, Host, :hostname => hostname, :sID => sID)
end

#send_authenticated_http_get(path, sID) ⇒ Object

Send an authenticated WebUI Request to the Server for URL +url and return the response body



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/deepsecurity/soap_interface.rb', line 24

def send_authenticated_http_get(path, sID)
  logger.debug { "#{self.class}\##{__method__}(#{path.inspect})" }
  url = "https://#{@hostname}:#{@port}#{path}"
  request = HTTPI::Request.new(url)
  request.auth.ssl.verify_mode = :none
  request.headers = {
      "Cookie" => "sID=#{sID}"
  }
  request.gzip
  response = HTTPI.get request
  response.body
end

#send_authenticated_http_post(path, body, sID) ⇒ Object

Send an authenticated WebUI Request to the Server for URL +url and return the response body



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/deepsecurity/soap_interface.rb', line 38

def send_authenticated_http_post(path, body, sID)
  logger.debug { "#{self.class}\##{__method__}(#{path.inspect})" }
  url = "https://#{@hostname}:#{@port}#{path}"
  request = HTTPI::Request.new(url)
  request.auth.ssl.verify_mode = :none
  request.headers = {
      "Cookie" => "sID=#{sID}",
      "Content-Type" => "application/x-www-form-urlencoded"
  }
  request.gzip
  request.body = body
  response = HTTPI.post request
  response.body
end