rapid7/metasploit-framework

View on GitHub
tools/modules/cve_xref.rb

Summary

Maintainability
D
1 day
Test Coverage

Method main has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def main
  filter  = 'All'
  filters = ['all','exploit','payload','post','nop','encoder','auxiliary']
  type    = 'CVE'
  db_path = nil
Severity: Minor
Found in tools/modules/cve_xref.rb - About 3 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

Consider simplifying this complex logical expression.
Open

      if (
           (module_full_name_ref && ref_match.match(/#{module_full_name_ref}/)) ||
           (edb_ref               && ref_match.match(/EXPLOIT\-DB:#{edb_ref}$/)) ||
           (osvdb_ref             && ref_match.match(/OSVDB:#{osvdb_ref}$/)) ||
           (bid_ref               && ref_match.match(/BID:#{bid_ref}$/)) ||
Severity: Critical
Found in tools/modules/cve_xref.rb - About 3 hrs to fix

    Method normalize_html_to_hash has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        def normalize_html_to_hash(html)
          puts "[*] Normalizing database..."
    
          db = {}
          current_cve = nil
    Severity: Minor
    Found in tools/modules/cve_xref.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 main has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main
      filter  = 'All'
      filters = ['all','exploit','payload','post','nop','encoder','auxiliary']
      type    = 'CVE'
      db_path = nil
    Severity: Major
    Found in tools/modules/cve_xref.rb - About 2 hrs to fix

      Method has_match? has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def has_match?(ref_match)
            if (
                 (module_full_name_ref && ref_match.match(/#{module_full_name_ref}/)) ||
                 (edb_ref               && ref_match.match(/EXPLOIT\-DB:#{edb_ref}$/)) ||
                 (osvdb_ref             && ref_match.match(/OSVDB:#{osvdb_ref}$/)) ||
      Severity: Minor
      Found in tools/modules/cve_xref.rb - About 1 hr 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 normalize_html_to_hash has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def normalize_html_to_hash(html)
            puts "[*] Normalizing database..."
      
            db = {}
            current_cve = nil
      Severity: Minor
      Found in tools/modules/cve_xref.rb - About 1 hr to fix

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

          def self.collect_references_from_module!(module_references, ref_ids, mod)
            if ref_ids.include?('EDB')
              edb_ref = mod.references.select { |r| r.ctx_id == 'EDB' }.first.ctx_val
              module_references['EDB'] = edb_ref
            end
        Severity: Minor
        Found in tools/modules/cve_xref.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 url_refs_match? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def url_refs_match?(ref_match)
              return false unless url_refs
              return false unless ref_match.match(/^http/)
        
              url_refs.each do |url|
        Severity: Minor
        Found in tools/modules/cve_xref.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

        There are no issues that match your filters.

        Category
        Status