Module: ESP

Defined in:
lib/esp.rb,
lib/esp/version.rb,
lib/esp/exceptions.rb,
lib/esp/aws_clients.rb,
lib/esp/resources/tag.rb,
lib/esp/resources/role.rb,
lib/esp/resources/stat.rb,
lib/esp/resources/team.rb,
lib/esp/resources/user.rb,
lib/esp/resources/alert.rb,
lib/esp/commands/console.rb,
lib/esp/resources/region.rb,
lib/esp/resources/report.rb,
lib/esp/resources/service.rb,
lib/esp/resources/metadata.rb,
lib/esp/resources/resource.rb,
lib/esp/resources/dashboard.rb,
lib/esp/resources/signature.rb,
lib/esp/resources/stat_region.rb,
lib/esp/resources/suppression.rb,
lib/esp/resources/organization.rb,
lib/esp/resources/stat_service.rb,
lib/esp/commands/commands_tasks.rb,
lib/esp/resources/scan_interval.rb,
lib/esp/external_account_creator.rb,
lib/esp/resources/stat_signature.rb,
lib/esp/resources/contact_request.rb,
lib/esp/resources/custom_signature.rb,
lib/esp/resources/external_account.rb,
lib/esp/resources/sub_organization.rb,
lib/esp/resources/cloud_trail_event.rb,
lib/esp/resources/suppression/region.rb,
lib/esp/resources/concerns/stat_totals.rb,
lib/esp/resources/stat_custom_signature.rb,
lib/esp/resources/suppression/signature.rb,
lib/esp/resources/custom_signature/result.rb,
lib/esp/resources/reports/export/integration.rb,
lib/esp/resources/custom_signature/definition.rb,
lib/esp/resources/custom_signature/result/alert.rb,
lib/esp/resources/suppression/unique_identifier.rb

Defined Under Namespace

Classes: Alert, CloudTrailEvent, ContactRequest, CustomSignature, Dashboard, ExternalAccount, Metadata, Organization, Region, Report, Role, ScanInterval, Service, Signature, Stat, StatCustomSignature, StatRegion, StatService, StatSignature, SubOrganization, Suppression, Tag, Team, User

Constant Summary collapse

PATH =
'/api/v2'.freeze
VERSION =
'2.7.0'.freeze

Class Method Summary collapse

Class Method Details

.access_key_idString?

Reads the ESP_ACCESS_KEY_ID environment variable if access_key_id= was not set manually.

Returns nil if no key or environment variable has been set.

Returns:

  • (String, nil)


18
19
20
# File 'lib/esp.rb', line 18

def self.access_key_id
  @access_key_id || ENV['ESP_ACCESS_KEY_ID']
end

.access_key_id=(access_key_id) ⇒ void

This method returns an undefined value.

Manually set the access_key_id you created from esp.evident.io/settings/api_keys.

You can optionally set the ESP_ACCESS_KEY_ID environment variable.

Parameters:

  • access_key_id (String)

    Your access key ID.



8
9
10
11
# File 'lib/esp.rb', line 8

def self.access_key_id=(access_key_id)
  @access_key_id               = access_key_id
  ESP::Resource.hmac_access_id = access_key_id
end

.configure {|self| ... } ⇒ void

This method returns an undefined value.

For use in a Rails initializer to set the access_key_id=, secret_access_key= and site.

Examples:


ESP.configure do |config|
  config.access_key_id = <your key>
  config.secret_access_key = <your secret key>
  config.host = <host of your appliance instance>
  config.http_proxy = <your proxy URI>
end

Yields:

  • (self)


97
98
99
# File 'lib/esp.rb', line 97

def self.configure
  yield self
end

.envString

Default environment is production which will set site to “api.evident.io/api/v2”.

Returns:

  • (String)


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

def self.env
  @env ||= ActiveSupport::StringInquirer.new(ENV['ESP_ENV'] || ENV['RAILS_ENV'] || 'production')
end

.host=(host) ⇒ void

This method returns an undefined value.

Users of the Evident.io marketplace appliance application will need to set the host for their instance.

Parameters:

  • host (String)

    The host for the installed appliance instance.



53
54
55
56
# File 'lib/esp.rb', line 53

def self.host=(host)
  @host              = host
  ESP::Resource.site = site
end

.http_proxyString?

Reads the HTTP_PROXY environment variable if http_proxy= was not set manually.

Returns nil if no proxy or environment variable has been set.

Returns:

  • (String, nil)


81
82
83
# File 'lib/esp.rb', line 81

def self.http_proxy
  @http_proxy || ENV['http_proxy']
end

.http_proxy=(proxy) ⇒ void

This method returns an undefined value.

Manually set an http_proxy

You can optionally set the HTTP_PROXY environment variable.

Parameters:

  • proxy (String)

    The URI of the http proxy



71
72
73
74
# File 'lib/esp.rb', line 71

def self.http_proxy=(proxy)
  @http_proxy         = proxy
  ESP::Resource.proxy = http_proxy
end

.secret_access_keyString?

Reads the ESP_SECRET_ACCESS_KEY environment variable if secret_access_key= was not set manually.

Returns nil if no key or environment variable has been set.

Returns:

  • (String, nil)


38
39
40
# File 'lib/esp.rb', line 38

def self.secret_access_key
  @secret_access_key || ENV['ESP_SECRET_ACCESS_KEY']
end

.secret_access_key=(secret_access_key) ⇒ void

This method returns an undefined value.

Manually set the secret_access_key you created from esp.evident.io/settings/api_keys.

You can optionally set the ESP_SECRET_ACCESS_KEY environment variable.

Parameters:

  • secret_access_key (String)

    Your secret access key.



28
29
30
31
# File 'lib/esp.rb', line 28

def self.secret_access_key=(secret_access_key)
  @secret_access_key            = secret_access_key
  ESP::Resource.hmac_secret_key = secret_access_key
end

.siteString

The site the SDK will hit.

Returns:

  • (String)


61
62
63
# File 'lib/esp.rb', line 61

def self.site
  "#{(@host || HOST[ESP.env.to_sym] || ENV['ESP_HOST'])}#{PATH}"
end