class Lita::Handlers::AlertlogicThreatManager

Alert Logic Threat Manager Routes

Public Instance Methods

protectedhosts_list(response) click to toggle source
# File lib/lita/handlers/alertlogic_threat_manager.rb, line 192
def protectedhosts_list(response)
  customer_id = valid_cid(response.match_data[1])
  return response.reply(t('validation.customer_id')) if customer_id.nil?
  response.reply(t('warn.standby'))

  params = {
    customer_id: customer_id,
    type: 'tm',
    source: 'protectedhosts'
  }
  resp = parse_json(api_call(params))

  reply_text = process_protectedhosts_list(customer_id, resp)
  if reply_text.length == 3
    head = reply_text[0]
    tables = reply_text[1]
    summary = reply_text[2]
    response.reply(head)
    tables.each do |data, headers|
      response.reply("/code #{build_table(data, headers)}")
    end
    response.reply(summary)
  else
    response.reply(reply_text)
  end
end
protectedhosts_status(response) click to toggle source
# File lib/lita/handlers/alertlogic_threat_manager.rb, line 219
def protectedhosts_status(response)
  customer_id = valid_cid(response.match_data[1])
  response.reply(t('warn.standby'))

  params = {
    customer_id: customer_id,
    type: 'tm',
    source: 'protectedhosts'
  }
  resp = parse_json(api_call(params))
  return response.reply(t('validation.customer_id')) if customer_id.nil?

  if resp['total_count'] == 0
    reply_text = pretty_json(resp)
    response.reply("/code #{reply_text}")
  else
    reply_text = process_protectedhosts(customer_id, resp)
    response.reply(reply_text)
  end
end
tm_appliance_info(response) click to toggle source

TM Data Definitions

# File lib/lita/handlers/alertlogic_threat_manager.rb, line 85
def tm_appliance_info(response)
  customer_id = valid_cid(response.match_data[1])
  uuid = response.match_data[2]
  return response.reply(t('validation.customer_id')) if customer_id.nil?
  return response.reply(t('validation.uuid')) if uuid.nil?
  response.reply(t('warn.standby'))

  url_params = {
    customer_id: customer_id,
    api_type:    'tm',
    source_type: 'appliances'
  }
  url = construct_api_url(url_params)
  url = "#{url}/#{uuid}"

  params = {
    customer_id: customer_id,
    url:         url
  }
  appliance_info = pretty_json(
    parse_json(
      api_call(params)
    )
  )

  reply_text = "/code #{appliance_info}"
  response.reply(reply_text)
end
tm_appliance_list(response) click to toggle source
# File lib/lita/handlers/alertlogic_threat_manager.rb, line 114
def tm_appliance_list(response)
  customer_id = valid_cid(response.match_data[1])
  return response.reply(t('validation.customer_id')) if customer_id.nil?
  appliance_list = []
  customers = get_customer_ids(customer_id)
  return response.reply(customers) unless customers.is_a? Array
  response.reply(t('warn.standby'))

  customers.each do |cid|
    params = {
      customer_id: cid,
      type:        'tm',
      source:      'appliances'
    }
    resp = api_call(params)
    appliance_list << process_appliances(resp, cid)
  end

  reply_text = appliance_list
  response.reply(reply_text)
end
tm_hosts_list(response) click to toggle source
# File lib/lita/handlers/alertlogic_threat_manager.rb, line 136
def tm_hosts_list(response)
  customer_id = valid_cid(response.match_data[1])
  response.reply(t('warn.standby'))

  params = {
    customer_id: customer_id,
    type:        'tm',
    source:      'hosts'
  }
  resp = parse_json(
    api_call(params)
  )

  reply_text = process_tm_hosts(customer_id, resp)
  if reply_text.length == 3
    head = reply_text[0]
    tables = reply_text[1]
    summary = reply_text[2]
    response.reply(head)
    tables.each do |data, headers|
      response.reply("/code #{build_table(data, headers)}")
    end
    response.reply(summary)
  else
    response.reply(reply_text)
  end
end
tm_policies_list(response) click to toggle source
# File lib/lita/handlers/alertlogic_threat_manager.rb, line 164
def tm_policies_list(response)
  customer_id = valid_cid(response.match_data[1])
  response.reply(t('warn.standby'))

  params = {
    customer_id: customer_id,
    type:        'tm',
    source:      'policies'
  }
  resp = parse_json(
    api_call(params)
  )

  reply_text = process_tm_policies(customer_id, resp)
  if reply_text.length == 3
    head = reply_text[0]
    tables = reply_text[1]
    summary = reply_text[2]
    response.reply(head)
    tables.each do |data, headers|
      response.reply("/code #{build_table(data, headers)}")
    end
    response.reply(summary)
  else
    response.reply(reply_text)
  end
end