Module: NurseAndrea::ManagedServiceScanner

Defined in:
lib/nurse_andrea/managed_service_scanner.rb

Constant Summary collapse

SCAN_MAP =
{
  "DATABASE_URL"      => "database",
  "DATABASE_PRIVATE_URL" => "database",
  "REDIS_URL"         => "cache",
  "REDIS_PRIVATE_URL" => "cache",
  "RABBITMQ_URL"      => "queue",
  "CLOUDAMQP_URL"     => "queue",
  "MONGODB_URI"       => "database",
  "MONGO_URL"         => "database",
  "ELASTICSEARCH_URL" => "search",
  "KAFKA_BROKERS"     => "queue"
}.freeze

Class Method Summary collapse

Class Method Details

.scanObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/nurse_andrea/managed_service_scanner.rb', line 21

def self.scan
  # Skip env-based discovery entirely when the SDK is loaded inside
  # NurseAndrea itself — every URL we'd find belongs to the platform's
  # own infrastructure, not a customer component.
  return [] if NurseAndrea::SelfFilter.platform_self?

  discoveries = []

  SCAN_MAP.each do |var_name, component_type|
    url = ENV[var_name]
    next if url.nil? || url.strip.empty?
    next if NurseAndrea::SelfFilter.host_matches?(url)

    tech     = Sanitizer.extract_tech(url)
    provider = Sanitizer.extract_provider(url)

    raw = {
      type: component_type,
      tech: tech,
      provider: provider,
      source: "env_detection",
      variable_name: var_name
    }

    discoveries << Sanitizer.sanitize_discovery(raw)
  end

  discoveries.uniq { |d| [ d[:type], d[:tech], d[:provider] ] }
end