rapid7/metasploit-framework

View on GitHub

Showing 21,757 of 21,757 total issues

Avoid deeply nested control flow statements.
Open

              elsif info =~ /sh: id: not found/
                info = ssh_socket.exec!("vmware -v\n").to_s
              else
                info << ssh_socket.exec!("help\n?\n\n\n").to_s
Severity: Major
Found in lib/metasploit/framework/ssh/platform.rb - About 45 mins to fix

    Method CfConvertToPlaceholder has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

                SafeHandle FileHandle,
                IntPtr FileIdentity,
                int FileIdentityLength,
                CF_CONVERT_FLAGS ConvertFlags,
                out long ConvertUsn,

      Method modify_function has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

                def modify_function(s)
                  function_statements = s.var.initializer.statements
                  new_function_statements = []
      
                  function_statements.each do |func_stmt|
      Severity: Minor
      Found in lib/metasploit/framework/obfuscation/crandomizer/modifier.rb - About 45 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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse(request,result)
      
          return unless result['Content-Type'].include?('text/html')
      
          doc = Nokogiri::HTML(result.body.to_s)
      Severity: Minor
      Found in data/msfcrawler/image.rb - About 45 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 print_results has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def print_results(doc, action)
                response = "#{action}Response"
                result = "#{action}Result"
                resource = /[A-Z][a-z]+([A-Za-z]+)/.match(action)[1]
      
      
      Severity: Minor
      Found in lib/metasploit/framework/aws/client.rb - About 45 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

      Avoid deeply nested control flow statements.
      Open

                      if version && platform && board
                        info = "#{platform.strip} #{board.strip} #{version.strip}"
                      end
      Severity: Major
      Found in lib/metasploit/framework/ssh/platform.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    s[:lmhash] = "00" * 24 if s[:lmhash] == s[:ntlmhash]
        Severity: Major
        Found in data/exploits/psnuffle/smb.rb - About 45 mins to fix

          Method parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def parse(request,result)
          
              return unless result['Content-Type'].include?('text/html')
          
              doc = Nokogiri::HTML(result.body.to_s)
          Severity: Minor
          Found in data/msfcrawler/frames.rb - About 45 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 write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def write(buf, opts={})
          
                    return super(buf, opts) if not @evasive
          
                    ret = 0
          Severity: Minor
          Found in lib/metasploit/framework/tcp/client.rb - About 45 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 CreateThread has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
          Severity: Minor
          Found in external/source/psh_exe/dot_net_service.cs - About 45 mins to fix

            Method CreateThread has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private static extern IntPtr CreateThread(IntPtr lpThreadAttributes, UIntPtr dwStackSize, IntPtr lpStartAddress, IntPtr param, Int32 dwCreationFlags, ref IntPtr lpThreadId);
            Severity: Minor
            Found in external/source/SqlClrPayload/StoredProcedures.cs - About 45 mins to fix

              Method parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def parse(request,result)
                  return unless result['Content-Type'].include?('text/html')
              
                  # doc = Hpricot(result.body.to_s)
                  doc = Nokogiri::HTML(result.body.to_s)
              Severity: Minor
              Found in data/msfcrawler/basic.rb - About 45 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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def parse(request,result)
                  return unless result['Content-Type'].include?('text/html')
              
                  doc = Nokogiri::HTML(result.body.to_s)
                  doc.css('link').each do |link|
              Severity: Minor
              Found in data/msfcrawler/link.rb - About 45 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 CreateThread has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
              Severity: Minor
              Found in external/source/psh_exe/dot_net_exe.cs - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                            s[:lmhash] = "00" * 24 if s[:lmhash] == '' or s[:lmhash] =~ /^(00)*$/m
                Severity: Major
                Found in data/exploits/psnuffle/smb.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if smb_status == 0 # success
                  
                                ntlm_ver = detect_ntlm_ver(s[:lmhash],s[:ntlmhash])
                  
                                logmessage =
                  Severity: Major
                  Found in data/exploits/psnuffle/smb.rb - About 45 mins to fix

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

                                    for root, dirs, files in os.walk('./src/single/'):
                                        for name in files:
                                            build(name[:-4])
                    Severity: Major
                    Found in external/source/shellcode/windows/x86/build.py and 5 other locations - About 45 mins to fix
                    external/source/shellcode/windows/x86/build.py on lines 109..111
                    external/source/shellcode/windows/x86/build.py on lines 112..114
                    external/source/shellcode/windows/x86/build.py on lines 118..120
                    external/source/shellcode/windows/x86/build.py on lines 121..123
                    external/source/shellcode/windows/x86/build.py on lines 124..126

                    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 35.

                    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 6 locations. Consider refactoring.
                    Open

                                    for root, dirs, files in os.walk('./src/stage/'):
                                        for name in files:
                                            build(name[:-4])
                    Severity: Major
                    Found in external/source/shellcode/windows/x86/build.py and 5 other locations - About 45 mins to fix
                    external/source/shellcode/windows/x86/build.py on lines 109..111
                    external/source/shellcode/windows/x86/build.py on lines 112..114
                    external/source/shellcode/windows/x86/build.py on lines 115..117
                    external/source/shellcode/windows/x86/build.py on lines 121..123
                    external/source/shellcode/windows/x86/build.py on lines 124..126

                    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 35.

                    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 6 locations. Consider refactoring.
                    Open

                                    for root, dirs, files in os.walk('./src/stager/'):
                                        for name in files:
                                            build(name[:-4])
                    Severity: Major
                    Found in external/source/shellcode/windows/x86/build.py and 5 other locations - About 45 mins to fix
                    external/source/shellcode/windows/x86/build.py on lines 109..111
                    external/source/shellcode/windows/x86/build.py on lines 112..114
                    external/source/shellcode/windows/x86/build.py on lines 115..117
                    external/source/shellcode/windows/x86/build.py on lines 118..120
                    external/source/shellcode/windows/x86/build.py on lines 124..126

                    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 35.

                    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

                            except SessionError as e:
                                if str(e).find('STATUS_NOT_SUPPORTED') > 0:
                                    raise Exception('The SMB request is not supported. Probably NTLM is disabled. Try to specify '
                    Severity: Minor
                    Found in modules/auxiliary/gather/get_user_spns.py and 1 other location - About 45 mins to fix
                    modules/auxiliary/gather/get_user_spns.py on lines 121..123

                    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 35.

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language