Module: Controls::Client::Assets

Included in:
Controls::Client
Defined in:
lib/controls/client/assets.rb

Overview

A module to encapsulate API methods related to assets

Since:

  • API v1.0

Version:

  • v1.0.0

Asset Methods collapse

Instance Method Details

#applicable_assets(guidance, params = {}) ⇒ Array<Hash> Also known as: assets_by_guidance

Returns an array of hashes that represent assets.

Parameters:

  • guidance (String)

    the guidance name to search by

Returns:

  • (Array<Hash>)

    an array of hashes that represent assets

Since:

  • API v1.0



40
41
42
# File 'lib/controls/client/assets.rb', line 40

def applicable_assets(guidance, params = {})
  get "/guidance/#{guidance}/applicable_assets", params
end

#asset_search(query, params = {}) ⇒ Hash

todo
  • change the name to asset_search/search_assets?

Parameters:

  • query (String)

    the query to retreive assets for

  • params (Hash) (defaults to: {})

    the option hash to be turned into query parameters

Returns:

  • (Hash)

    a hash representing the matching assets

Since:

  • API v1.0



33
34
35
36
# File 'lib/controls/client/assets.rb', line 33

def asset_search(query, params = {})
  params[:query] = query
  get "/assets/search", params
end

#assets(params = {}) ⇒ Hash

Note:

since the uuid is an optional param it has been added to the params options hash

todo
  • use @overload here for assets(params) vs assets(uuid) vs assets({ uuid: ‘uuid-string’, other: ‘param’ })

Returns:

  • (Hash)

    a hash representing the matching asset

Raises:

  • (Controls::NotFound)

    if the uuid didn’t match any assets

Since:

  • API v1.0



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/controls/client/assets.rb', line 14

def assets(params = {})
  if params.is_a? Hash
    uuid = params.delete(:uuid)
  else
    uuid = params
    params = {}
  end

  if uuid && !uuid.empty?
    get "/assets/#{uuid}", params
  else
    get '/assets', params
  end
end

#misconfigured_assets(configuration, params = {}) ⇒ Array<Hash> Also known as: assets_by_configuration

Returns an array of hashes that represent assets.

Parameters:

  • configuration (String)

    the name of the configuration to search by

Returns:

  • (Array<Hash>)

    an array of hashes that represent assets

Since:

  • API v1.0



47
48
49
# File 'lib/controls/client/assets.rb', line 47

def misconfigured_assets(configuration, params = {})
  get "/configurations/#{configuration}/misconfigured_assets", params
end

#threat_assets(threat, params = {}) ⇒ Array<Hash> Also known as: assets_by_threat

Returns an array of hashes that represent assets.

Parameters:

  • threat (String)

    the threat name to search by

Returns:

  • (Array<Hash>)

    an array of hashes that represent assets

Since:

  • API v1.0



54
55
56
57
# File 'lib/controls/client/assets.rb', line 54

def threat_assets(threat, params = {})
  fail NotImplementedError, "Assets by threat is not a valid request. Use Controls::Client#assets or Controls::Client#assets_by_threat_vector instead."
  # get "/threats/#{threat}/assets", params
end

#uncovered_assets(security_control, params = {}) ⇒ Array<Hash> Also known as: assets_by_security_control

Returns an array of hashes that represent assets.

Parameters:

  • security_control (String)

    the name of the security control to search by

Returns:

  • (Array<Hash>)

    an array of hashes that represent assets

Since:

  • API v1.0



63
64
65
# File 'lib/controls/client/assets.rb', line 63

def uncovered_assets(security_control, params = {})
  get "/security_controls/#{security_control}/uncovered_assets", params
end

#undefended_assets(threat_vector, params = {}) ⇒ Array<Hash> Also known as: assets_by_threat_vector

Returns an array of hashes that represent assets.

Parameters:

  • threat_vector (String)

    the threat vectory to search by

Returns:

  • (Array<Hash>)

    an array of hashes that represent assets

Since:

  • API v1.0



70
71
72
# File 'lib/controls/client/assets.rb', line 70

def undefended_assets(threat_vector, params = {})
  get "/threat_vectors/#{threat_vector}/undefended_assets", params
end