sensu-plugins/sensu-plugins-ssl

View on GitHub

Showing 10 of 14 total issues

Method ssl_recheck has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

  def ssl_recheck
    1.upto(config[:num_checks]) do |step|
      p "step: #{step}" if config[:debug]
      start_time = Time.now
      p "start_time: #{start_time}" if config[:debug]
Severity: Minor
Found in bin/check-ssl-qualys.rb - About 4 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method validate_opts has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_opts
    if !config[:pem] && !config[:pkcs12]
      unknown 'Host and port required' unless config[:host] && config[:port]
    elsif config[:pem]
      unknown 'No such cert' unless File.exist? config[:pem]
Severity: Minor
Found in bin/check-ssl-cert.rb - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method find_root_cert has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def find_root_cert(uri)
    root_cert = nil
    http = Net::HTTP.new(uri.host, uri.port)
    http.open_timeout = 10
    http.read_timeout = 10
Severity: Minor
Found in bin/check-ssl-root-issuer.rb - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method get_cert_chain has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def get_cert_chain(host, port, address, client_cert, client_key)
Severity: Minor
Found in bin/check-ssl-host.rb - About 35 mins to fix

    Method run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        validate_opts
        data = anchor_information
        if data == 'NOTOK'
          critical 'An error was encountered while trying to retrieve the certificate chain.'
    Severity: Minor
    Found in bin/check-ssl-anchor.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        validate_opts
    
        expiry = if config[:pem]
                   ssl_pem_expiry
    Severity: Minor
    Found in bin/check-ssl-cert.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        chain = get_cert_chain(config[:host], config[:port], config[:address], config[:client_cert], config[:client_key])
        verify_hostname(chain[0]) unless config[:skip_hostname_verification]
        verify_certificate_chain(chain) unless config[:skip_chain_verification]
        verify_expiry(chain[0])
    Severity: Minor
    Found in bin/check-ssl-host.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        Timeout.timeout(config[:timeout]) do
          grade = lowest_grade
          unless grade
            message "#{config[:domain]} not rated"
    Severity: Minor
    Found in bin/check-ssl-qualys.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method get_cert_chain has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_cert_chain(host, port, address, client_cert, client_key)
        tcp_client = TCPSocket.new(address ? address : host, port) # rubocop:disable Style/RedundantCondition
        handle_starttls(config[:starttls], tcp_client) if config[:starttls]
        ssl_context = OpenSSL::SSL::SSLContext.new
        ssl_context.cert = OpenSSL::X509::Certificate.new File.read(client_cert) if client_cert
    Severity: Minor
    Found in bin/check-ssl-host.rb - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        uri       = URI(config[:api_url])
        uri.query = URI.encode_www_form(domain: config[:domain])
        response  = fetch(uri)
        if response.nil?
    Severity: Minor
    Found in bin/check-ssl-hsts-status.rb - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Severity
    Category
    Status
    Source
    Language