rapid7/metasploit-framework

View on GitHub
modules/exploits/unix/webapp/zoneminder_lang_exec.rb

Summary

Maintainability
D
2 days
Test Coverage

Method exploit has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

  def exploit
    unless datastore['AutoCheck']
      cookie_jar.clear
      res = authenticate
      fail_with(Failure::NoAccess, 'Authentication failed') if res&.body =~ %r{<title>ZM - Login</title>}
Severity: Minor
Found in modules/exploits/unix/webapp/zoneminder_lang_exec.rb - About 7 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 exploit has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def exploit
    unless datastore['AutoCheck']
      cookie_jar.clear
      res = authenticate
      fail_with(Failure::NoAccess, 'Authentication failed') if res&.body =~ %r{<title>ZM - Login</title>}
Severity: Major
Found in modules/exploits/unix/webapp/zoneminder_lang_exec.rb - About 4 hrs to fix

    Method check has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def check
        res = send_request_cgi(
          'uri' => normalize_uri(target_uri.path, '/index.php'),
          'method' => 'GET'
        )
    Severity: Minor
    Found in modules/exploits/unix/webapp/zoneminder_lang_exec.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 initialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'ZoneMinder Language Settings Remote Code Execution',
    Severity: Minor
    Found in modules/exploits/unix/webapp/zoneminder_lang_exec.rb - About 1 hr to fix

      Method check has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def check
          res = send_request_cgi(
            'uri' => normalize_uri(target_uri.path, '/index.php'),
            'method' => 'GET'
          )
      Severity: Minor
      Found in modules/exploits/unix/webapp/zoneminder_lang_exec.rb - About 1 hr to fix

        Avoid too many return statements within this method.
        Open

            return Exploit::CheckCode::Unknown('Could not connect to the web service')
        Severity: Major
        Found in modules/exploits/unix/webapp/zoneminder_lang_exec.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return Exploit::CheckCode::Appears("Version Detected: #{version}") if version <= Rex::Version.new('1.37.10')
          Severity: Major
          Found in modules/exploits/unix/webapp/zoneminder_lang_exec.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return Exploit::CheckCode::Safe('Unable to determine ZoneMinder version')
            Severity: Major
            Found in modules/exploits/unix/webapp/zoneminder_lang_exec.rb - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status