check_for_bad_library

in lib/omnibus/health_check.rb [539:590]


    def check_for_bad_library(bad_libs, good_libs, current_library, name, linked)
      safe = nil

      default_whitelist_libs = case Ohai["platform"]
                               when "arch"
                                 ARCH_WHITELIST_LIBS
                               when "mac_os_x"
                                 MAC_WHITELIST_LIBS
                               when "omnios"
                                 OMNIOS_WHITELIST_LIBS
                               when "solaris2"
                                 SOLARIS_WHITELIST_LIBS
                               when "smartos"
                                 SMARTOS_WHITELIST_LIBS
                               when "freebsd"
                                 FREEBSD_WHITELIST_LIBS
                               when "aix"
                                 AIX_WHITELIST_LIBS
                               else
                                 WHITELIST_LIBS
                               end

      whitelist_libs = [default_whitelist_libs + project.allowed_libs].flatten.compact.uniq

      whitelist_libs.each do |reg|
        safe ||= true if reg.match(name)
      end

      whitelist_files.each do |reg|
        safe ||= true if reg.match(current_library)
      end

      log.debug(log_key) { "  --> Dependency: #{name}" }
      log.debug(log_key) { "  --> Provided by: #{linked}" }

      if !safe && linked !~ Regexp.new(project.install_dir)
        log.debug(log_key) { "    -> FAILED: #{current_library} has unsafe dependencies" }
        bad_libs[current_library] ||= {}
        bad_libs[current_library][name] ||= {}
        if bad_libs[current_library][name].key?(linked)
          bad_libs[current_library][name][linked] += 1
        else
          bad_libs[current_library][name][linked] = 1
        end
      else
        good_libs[current_library] = true
        log.debug(log_key) { "    -> PASSED: #{name} is either whitelisted or safely provided." }
      end

      [bad_libs, good_libs]
    end