Search for any vulnerability definitions which refer to a given CVE.

 @param [String] cve A valid CVE.
 @return [Array[VulnerabilityDefinition]] A list of vuln definitions which check the CVE.
556054
def find_vulns_by_cve(cve)
      uri  = '/api/2.0/vulnerability_definitions'
      resp = AJAX.get(self, uri, AJAX::CONTENT_TYPE::JSON, cve: cve)
      json = JSON.parse(resp, symbolize_names: true)
      json[:resources].map { |e| VulnerabilityDefinition.new.object_from_hash(self, e) }
    end
382139
def inspect_constants(source = constant, ignore = [])
      names          = []
      source_name    = source.name
      have_children  = []
      include_source = source != Object

      if include_source and !ignore.include?(source_name)
        names  << source_name
        ignore << source_name
      end

      source.constants.each do |name|
        next if skip_constant?(source, name)

        full_name = include_source ? "#{source_name}::#{name}" : name.to_s

        # In certain cases this code tries to load a constant that apparently
        # *is* defined but craps out upon error (e.g. Bundler::Specification).
        begin
          constant = source.const_get(name)
        rescue Exception => error
          warn error.message
          next
        end

        # Skip those that we've already processed.
        if ignore.include?(full_name) or source == constant
          next
        end

        names         << full_name
        ignore        << full_name
        have_children << constant if process_child_constants?(constant)
      end

      have_children.each do |const|
        names |= inspect_constants(const, ignore)
      end

      # Reject every constant that, if we should include the source name, was
      # not defined under that constant. This applies on for example Rubinius
      # since `Range::Enumerator` is a constant that points to
      # `Enumerable::Enumerator`.
      if include_source
        names = names.select { |name| name.start_with?(source_name) }
      end

      return names
    end
878617
def html_safe_options(hash)
      hash.inject({}) do |result, (key, value)|
        result[key] = case value
          when String
            ERB::Util.h(value)
          else
            value
          end

        result
      end
    end
1118259
protected HashSet<String> getEmbeddedVulnerabilities(VictimsRecord vr)
            throws SQLException {
        HashSet<String> cves = new HashSet<String>();

        Set<String> hashes = vr.getHashes(Algorithms.SHA512).keySet();
        if (hashes.size() <= 0) {
            return cves;
        }

        for (Integer id : getEmbeddedRecords(hashes)) {
            cves.addAll(getVulnerabilities(id));
        }

        return cves;
    }
190545
def inspect
      attrs = [
        [ :repository, repository.name ],
        [ :model,      model           ],
        [ :fields,     fields          ],
        [ :links,      links           ],
        [ :conditions, conditions      ],
        [ :order,      order           ],
        [ :limit,      limit           ],
        [ :offset,     offset          ],
        [ :reload,     reload?         ],
        [ :unique,     unique?         ],
      ]

      "#<#{self.class.name} #{attrs.map { |key, value| "@#{key}=#{value.inspect}" }.join(' ')}>"
    end
696686
def https_app
      ssl_options  = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options]
      ssl_options |= OpenSSL::SSL::OP_CIPHER_SERVER_PREFERENCE if defined?(OpenSSL::SSL::OP_CIPHER_SERVER_PREFERENCE)
      # This is required to disable SSLv3 on Ruby 1.8.7
      ssl_options |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2)
      ssl_options |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3)
      ssl_options |= OpenSSL::SSL::OP_NO_TLSv1 if defined?(OpenSSL::SSL::OP_NO_TLSv1)

      if Settings.instance.tls_disabled_versions
        Settings.instance.tls_disabled_versions.each do |version|
          constant = OpenSSL::SSL.const_get("OP_NO_TLSv#{version.to_s.tr('.', '_')}") rescue nil

          if constant
            Log.instance.info "TLSv#{version} will be disabled."
            ssl_options |= constant
          else
            Log.instance.warn "TLSv#{version} was not found."
          end
        end
      end

      {
        :SSLEnable => true,
        :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER,
        :SSLPrivateKey => ssl_private_key,
        :SSLCertificate => ssl_certificate,
        :SSLCACertificateFile => Settings.instance.ssl_ca_file,
        :SSLOptions => ssl_options
      }
    end
719472
def disable_vuln_check(check_id)
      checks = REXML::XPath.first(@xml, '//VulnerabilityChecks')
      checks.elements.delete("Enabled/Check[@id='#{check_id}']")
      disabled_checks = checks.elements['Disabled'] || checks.add_element('Disabled')
      disabled_checks.add_element('Check', { 'id' => check_id })
    end
596666
def define_helper(method_name, base_hash)
      # Which kind of wildcards (if any) do we need to support?
      combined = []
      base_hash.each_value do |v|
        combined += v if v.is_a?(Array)
        combined << v if v.is_a?(String)
      end
      key_value = combined.any? { |i| i.is_a?(String) && /<\S+>/ =~ i }
      printf = combined.any? { |i| i.is_a?(String) && /%/ =~ i }

      if key_value && printf
        fail 'Invalid mixture of key-value and printf wildcards ' \
             "in #{method_name}: #{combined}"
      elsif key_value
        define_key_value_helper(method_name, base_hash)
      elsif printf
        arg_count = combined.join.scan(/%/).length
        define_printf_helper(method_name, base_hash, arg_count)
      else
        # simple static token(s)
        define_static_helper(method_name, base_hash)
      end
      @hash[method_name] = true
    end
843476
private static String[] decideCipherSuites()
  {
    String sysCipherSuites = System.getProperty("https.cipherSuites");

    String[] cipherSuites = sysCipherSuites != null ? sysCipherSuites.split(",") :
                            // use jdk default cipher suites
                            ((SSLServerSocketFactory) SSLServerSocketFactory.getDefault())
                                .getDefaultCipherSuites();

    // cipher suites need to be picked up in code explicitly for jdk 1.7
    // https://stackoverflow.com/questions/44378970/
    if (logger.isTraceEnabled())
    {
      logger.trace("Cipher suites used: {}", Arrays.toString(cipherSuites));
    }

    return cipherSuites;
  }
299586
def host
      return @host if defined?(@host)

      # Determine the host class to use. ":detect" is an old Vagrant config
      # that shouldn't be valid anymore, but we respect it here by assuming
      # its old behavior. No need to deprecate this because I thin it is
      # fairly harmless.
      host_klass = vagrantfile.config.vagrant.host
      host_klass = nil if host_klass == :detect

      begin
        @host = Host.new(
          host_klass,
          Vagrant.plugin("2").manager.hosts,
          Vagrant.plugin("2").manager.host_capabilities,
          self)
      rescue Errors::CapabilityHostNotDetected
        # If the auto-detect failed, then we create a brand new host
        # with no capabilities and use that. This should almost never happen
        # since Vagrant works on most host OS's now, so this is a "slow path"
        klass = Class.new(Vagrant.plugin("2", :host)) do
          def detect?(env); true; end
        end

        hosts     = { generic: [klass, nil] }
        host_caps = {}

        @host = Host.new(:generic, hosts, host_caps, self)
      rescue Errors::CapabilityHostExplicitNotDetected => e
        raise Errors::HostExplicitNotDetected, e.extra_data
      end
    end
168526
def inspect
      if alert.exists?
        format('#<%s:0x%x alert=true>', self.class, hash * 2)
      else
        format('#<%s:0x%x url=%s title=%s>', self.class, hash * 2, url.inspect, title.inspect)
      end
    rescue Errno::ECONNREFUSED
      format('#<%s:0x%x closed=true>', self.class, hash * 2)
    end
1276772
def checks_pass?
      rv = true
      unless File.exist?(@platform)
        puts "No platform or invalid platform configuration given: (#{@platform}) !"
        puts "Use either property 'platform' via RakeOE::Config object in the Rakefile or environment variable TOOLCHAIN_ENV"
        rv = false
      end
      rv
    end
364402
public List<VulnerableSoftware> getVulnerableSoftware(boolean sorted) {
        final List<VulnerableSoftware> sortedVulnerableSoftware = new ArrayList<>(this.vulnerableSoftware);
        if (sorted) {
            Collections.sort(sortedVulnerableSoftware);
        }
        return sortedVulnerableSoftware;
    }
682665
def flag_cookies_as_secure!(headers)
      if cookies = headers['Set-Cookie']
        # Support Rails 2.3 / Rack 1.1 arrays as headers
        unless cookies.is_a?(Array)
          cookies = cookies.split("\n")
        end

        headers['Set-Cookie'] = cookies.map do |cookie|
          cookie !~ /(^|;\s)secure($|;)/ ? "#{cookie}; secure" : cookie
        end.join("\n")
      end
    end
1322562
def handle_get_vts_command(self, vt_et):
        

        vt_id = vt_et.attrib.get('vt_id')
        vt_filter = vt_et.attrib.get('filter')

        if vt_id and vt_id not in self.vts:
            text = "Failed to find vulnerability test '{0}'".format(vt_id)
            return simple_response_str('get_vts', 404, text)

        filtered_vts = None
        if vt_filter:
            filtered_vts = self.vts_filter.get_filtered_vts_list(
                self.vts, vt_filter)

        responses = []

        vts_xml = self.get_vts_xml(vt_id, filtered_vts)

        responses.append(vts_xml)

        return simple_response_str('get_vts', 200, 'OK', responses)
967521
private static boolean isSecure(String protocol) throws BugError {
		if (HTTP.equalsIgnoreCase(protocol)) {
			return false;
		} else if (HTTPS.equalsIgnoreCase(protocol)) {
			return true;
		} else {
			throw new BugError("Unsupported protocol |%s| for HTTP transaction.", protocol);
		}
	}
1339092
def cmd(send, msg, args):
    
    elements = msg.split('-')
    if len(elements) > 3 or len(elements) < 2:
        send("Invalid CVE format")
        return
    # If there are three fields, ignore the first (we don't actually need to send CVE-
    if len(elements) == 3:
        if elements[0].upper() != 'CVE':
            send("Invalid CVE format")
            return
        elements.pop(0)
    # The first digit field should be exactly four digits long, the second is 4+
    if not re.search(r"^[\d]{4}$", elements[0]) or not re.search(r"^[\d]{4,}$", elements[1]):
        send("Invalid CVE format")
        return
    search = "%s-%s" % (elements[0], elements[1])
    url = 'http://cve.mitre.org/cgi-bin/cvename.cgi?name=%s' % search
    html = fromstring(get(url).text)
    title = html.find(".//title").text.splitlines()[2]
    if title.startswith('ERROR'):
        output = 'Invalid CVE Number'
    else:
        key = args['config']['api']['bitlykey']
        output = "%s -- %s" % (title, get_short(url, key))
    send(output)