class Eso::IntegrationOptionsManager
This class is a manager for the integration options api. Integration options match epo/dxl/etc steps (ie discover-epo-assets) to nexpose steps (ie import-external-assets).
Public Class Methods
# File lib/eso/integration_options_manager.rb, line 155 def self.build_export_risk_scores_option(name:, discovery_conn_id:) step1 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::RISK_SCORE_UPDATED) step2 = Step.new(service_name: ServiceNames::EPO, type_name: StepNames::PUSH_RISK_SCORE, previous_type_name: step1.type_name) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) IntegrationOption.new(name: name, steps: [step1, step2]) end
# File lib/eso/integration_options_manager.rb, line 162 def self.build_find_vuln_details_option(name:, discovery_conn_id:) step1 = Step.new(service_name: ServiceNames::DXL, type_name: StepNames::VULN_DETAILS_REQUEST) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::VULN_DETAILS, previous_type_name: step1.type_name) step3 = Step.new(service_name: ServiceNames::DXL, type_name: StepNames::VULN_DETAILS_REQUEST, previous_type_name: step2.type_name) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) IntegrationOption.new(name: name, steps: [step1, step2, step3]) end
# File lib/eso/integration_options_manager.rb, line 87 def self.build_import_ad_assets_option(name:, discovery_conn_id:, site_id: nil) step1 = Step.new(service_name: ServiceNames::ACTIVE_DIRECTORY, type_name: StepNames::DISCOVER_ACTIVE_DIRECTORY) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::IMPORT_EXTERNAL, previous_type_name: step1.type_name) #This isn't always known immediately, which is why we have IntegrationOption.site_id= step2.add_property(StepConfiguration::ConfigParamProperties::SITE_ID, site_id) if site_id IntegrationOption.new(name: name, steps: [step1, step2]) end
TODO: These build_* methods must die.
# File lib/eso/integration_options_manager.rb, line 77 def self.build_import_epo_assets_option(name:, discovery_conn_id:, site_id: nil) step1 = Step.new(service_name: ServiceNames::EPO, type_name: StepNames::DISCOVER_EPO) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::IMPORT_EXTERNAL, previous_type_name: step1.type_name) #This isn't always known immediately, which is why we have IntegrationOption.site_id= step2.add_property(StepConfiguration::ConfigParamProperties::SITE_ID, site_id) if site_id IntegrationOption.new(name: name, steps: [step1, step2]) end
# File lib/eso/integration_options_manager.rb, line 171 def self.build_publish_vulnerabilities_option(name:, discovery_conn_id:) step1 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::NEW_ASSET_VULN) step2 = Step.new(service_name: ServiceNames::DXL, type_name: StepNames::PUBLISH_VULN_INT_TYPE, previous_type_name: step1.type_name) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) IntegrationOption.new(name: name, steps: [step1, step2]) end
# File lib/eso/integration_options_manager.rb, line 97 def self.build_sync_aws_assets_option(name:, discovery_conn_id:, site_id: nil) step1 = Step.new(service_name: ServiceNames::AWS, type_name: StepNames::DISCOVER_AWS_ASSETS) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::SYNC_EXTERNAL, previous_type_name: step1.type_name) #This isn't always known immediately, which is why we have IntegrationOption.site_id= step2.add_property(StepConfiguration::ConfigParamProperties::SITE_ID, site_id) if site_id IntegrationOption.new(name: name, steps: [step1, step2]) end
# File lib/eso/integration_options_manager.rb, line 119 def self.build_sync_azure_assets_option(name:, discovery_conn_id:, site_id: nil) step1 = Step.new(service_name: ServiceNames::AZURE, type_name: StepNames::DISCOVER_AZURE_ASSETS) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::SYNC_EXTERNAL, previous_type_name: step1.type_name) #This isn't always known immediately, which is why we have IntegrationOption.site_id= step2.add_property(StepConfiguration::ConfigParamProperties::SITE_ID, site_id) if site_id IntegrationOption.new(name: name, steps: [step1, step2]) end
# File lib/eso/integration_options_manager.rb, line 107 def self.build_verify_aws_targets_option(name:, discovery_conn_id:) step1 = Step.new(service_name: ServiceNames::AWS, type_name: StepNames::VERIFY_AWS_ASSETS) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) step2 = Step.new(service_name: ServiceNames::NEXPOSE, type_name: StepNames::VERIFY_EXTERNAL_TARGETS, previous_type_name: step1.type_name) step3 = Step.new(service_name: ServiceNames::AWS, type_name: StepNames::VERIFY_AWS_ASSETS, previous_type_name: step2.type_name) .add_property(StepConfiguration::ConfigParamProperties::DISCOVERY_CONFIG_ID, discovery_conn_id) IntegrationOption.new(name: name, steps: [step1, step2, step3]) end
Constructor for IntegrationOptionsManager
.
@param [Nexpose::Connection] nsc A logged-in Nexpose::Connection
object with a valid session used to authenticate. @return [Eso::IntegrationOptionsManager] The newly created IntegrationOptionManager object
# File lib/eso/integration_options_manager.rb, line 16 def initialize(nsc) @nexpose_console = nsc @url = "https://#{nsc.host}:#{nsc.port}/eso/integration-manager-service/api/integration-options/" end
Public Instance Methods
Create a new or Update existing integration option.
@param [String] payload The JSON representation of an integration option. @return [String] The integrationOptionID (a UUID) of the newly created configuration. Raises error on failure.
# File lib/eso/integration_options_manager.rb, line 27 def create(payload) # TODO retry if the post fails on timeout response_body = ::Nexpose::AJAX.post(@nexpose_console, "#{@url}", payload, ::Nexpose::AJAX::CONTENT_TYPE::JSON) JSON.parse(response_body)['data']['id'] end
Deleting and stopping are the same thing
# File lib/eso/integration_options_manager.rb, line 35 def delete(integration_option_id) ::Nexpose::AJAX.delete(@nexpose_console, "#{@url}#{integration_option_id}/state") end
Get an existing integration option.
@param [String] integration_option_id The integration_option_id of the integration option. @return IntegrationOption
for that id, or nil
# File lib/eso/integration_options_manager.rb, line 46 def get(integration_option_id) # Gets all integration options response_body = ::Nexpose::AJAX.get(@nexpose_console, "#{@url}", ::Nexpose::AJAX::CONTENT_TYPE::JSON) response = JSON.parse(response_body, symbolize_names: true) # Find the desired one raw_integration_option = response.find{|raw| raw[:id] == integration_option_id} raise "No IntegrationOption with ID #{integration_option_id}" if raw_integration_option.nil? # Load it to an object IntegrationOption.load(raw_integration_option) end
# File lib/eso/integration_options_manager.rb, line 71 def start(integration_option_id) response_body = ::Nexpose::AJAX.post(@nexpose_console, "#{@url}#{integration_option_id}/state", ::Nexpose::AJAX::CONTENT_TYPE::JSON) JSON.parse(response_body) end
Get the status of an integration option.
@param [String] integration_option_id The integration_option_id of the integration option. @return the state (READY, STOPPED, etc)
# File lib/eso/integration_options_manager.rb, line 65 def status(integration_option_id) response_body = ::Nexpose::AJAX.get(@nexpose_console, "#{@url}#{integration_option_id}/status", ::Nexpose::AJAX::CONTENT_TYPE::JSON) response = JSON.parse(response_body) response['state'] end