rapid7/metasploit-framework

View on GitHub
lib/msf/core/db_export.rb

Summary

Maintainability
D
2 days
Test Coverage

File db_export.rb has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf

##
#
# This class provides export capabilities
Severity: Minor
Found in lib/msf/core/db_export.rb - About 5 hrs to fix

    Method extract_host_info has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def extract_host_info(report_file)
        @hosts.each do |h|
          report_file.write("  <host>\n")
          host_id = h.attributes["id"]
    
    
    Severity: Major
    Found in lib/msf/core/db_export.rb - About 3 hrs to fix

      Class DBExport has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class DBExport
      
        attr_accessor :workspace
      
        STATUS_START = "start"
      Severity: Minor
      Found in lib/msf/core/db_export.rb - About 3 hrs to fix

        Method extract_module_detail_info has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def extract_module_detail_info(report_file)
              Mdm::Module::Detail.all.each do |m|
              report_file.write("<module_detail>\n")
              #m_id = m.attributes["id"]
        
        
        Severity: Major
        Found in lib/msf/core/db_export.rb - About 2 hrs to fix

          Method to_xml_file has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def to_xml_file(path, &block)
          
              yield(:status, STATUS_START, "report") if block_given?
              extract_target_entries
              report_file = ::File.open(path, "wb")
          Severity: Major
          Found in lib/msf/core/db_export.rb - About 2 hrs to fix

            Method to_xml_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def to_xml_file(path, &block)
            
                yield(:status, STATUS_START, "report") if block_given?
                extract_target_entries
                report_file = ::File.open(path, "wb")
            Severity: Minor
            Found in lib/msf/core/db_export.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 create_xml_element has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def create_xml_element(key,value,skip_encoding=false)
                tag = key.tr("_","-")
                el = REXML::Element.new(tag)
                if value
                  unless skip_encoding
            Severity: Minor
            Found in lib/msf/core/db_export.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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              def extract_event_info(report_file)
                @events.each do |e|
                  report_file.write("  <event>\n")
                  e.attributes.each_pair do |k,v|
                    el = create_xml_element(k,v)
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 2 other locations - About 35 mins to fix
            lib/msf/core/db_export.rb on lines 453..463
            lib/msf/core/db_export.rb on lines 468..478

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              def extract_service_info(report_file)
                @services.each do |e|
                  report_file.write("  <service>\n")
                  e.attributes.each_pair do |k,v|
                    el = create_xml_element(k,v)
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 2 other locations - About 35 mins to fix
            lib/msf/core/db_export.rb on lines 439..449
            lib/msf/core/db_export.rb on lines 468..478

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

              def extract_service_info(report_file)
                @services.each do |e|
                  report_file.write("  <service>\n")
                  e.attributes.each_pair do |k,v|
                    el = create_xml_element(k,v)
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 2 other locations - About 35 mins to fix
            lib/msf/core/db_export.rb on lines 439..449
            lib/msf/core/db_export.rb on lines 453..463

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  @notes.where(host_id: host_id).each do |e|
                    report_file.write("      <note>\n")
                    e.attributes.each_pair do |k,v|
                      el = create_xml_element(k,v)
                      report_file.write("      #{el}\n")
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 1 other location - About 25 mins to fix
            lib/msf/core/db_export.rb on lines 352..358

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 31.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                  @services.where(host_id: host_id).each do |e|
                    report_file.write("      <service>\n")
                    e.attributes.each_pair do |k,v|
                      el = create_xml_element(k,v)
                      report_file.write("      #{el}\n")
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 1 other location - About 25 mins to fix
            lib/msf/core/db_export.rb on lines 364..370

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 31.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                    e.vuln_details.each do |d|
                      report_file.write("                <vuln_detail>\n")
                      d.attributes.each_pair do |k,v|
                        el = create_xml_element(k,v)
                        report_file.write("                    #{el}\n")
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 3 other locations - About 20 mins to fix
            lib/msf/core/db_export.rb on lines 328..334
            lib/msf/core/db_export.rb on lines 340..346
            lib/msf/core/db_export.rb on lines 419..425

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 28.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                  h.host_details.each do |d|
                    report_file.write("        <host_detail>\n")
                    d.attributes.each_pair do |k,v|
                      el = create_xml_element(k,v)
                      report_file.write("            #{el}\n")
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 3 other locations - About 20 mins to fix
            lib/msf/core/db_export.rb on lines 340..346
            lib/msf/core/db_export.rb on lines 406..412
            lib/msf/core/db_export.rb on lines 419..425

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 28.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                  h.exploit_attempts.each do |d|
                    report_file.write("        <exploit_attempt>\n")
                    d.attributes.each_pair do |k,v|
                      el = create_xml_element(k,v)
                      report_file.write("            #{el}\n")
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 3 other locations - About 20 mins to fix
            lib/msf/core/db_export.rb on lines 328..334
            lib/msf/core/db_export.rb on lines 406..412
            lib/msf/core/db_export.rb on lines 419..425

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 28.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 4 locations. Consider refactoring.
            Open

                    e.vuln_attempts.each do |d|
                      report_file.write("                <vuln_attempt>\n")
                      d.attributes.each_pair do |k,v|
                        el = create_xml_element(k,v)
                        report_file.write("                    #{el}\n")
            Severity: Minor
            Found in lib/msf/core/db_export.rb and 3 other locations - About 20 mins to fix
            lib/msf/core/db_export.rb on lines 328..334
            lib/msf/core/db_export.rb on lines 340..346
            lib/msf/core/db_export.rb on lines 406..412

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 28.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            There are no issues that match your filters.

            Category
            Status