rapid7/metasploit-framework

View on GitHub
lib/msf/core/post/windows/accounts.rb

Summary

Maintainability
F
4 days
Test Coverage

File accounts.rb has 450 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Msf
  class Post
    module Windows
      module Accounts
        include Msf::Post::Windows::Error
Severity: Minor
Found in lib/msf/core/post/windows/accounts.rb - About 6 hrs to fix

    Method resolve_sid has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def resolve_sid(sid, system_name = nil)
              unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                return nil
              end
    
    
    Severity: Major
    Found in lib/msf/core/post/windows/accounts.rb - About 2 hrs to fix

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

              def resolve_sid(sid, system_name = nil)
                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                  return nil
                end
      
      
      Severity: Minor
      Found in lib/msf/core/post/windows/accounts.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 enum_user has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def enum_user(server_name = nil)
                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                  raise "Session doesn't support Railgun!"
                end
      
      
      Severity: Minor
      Found in lib/msf/core/post/windows/accounts.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 enum_localgroup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def enum_localgroup(server_name = nil)
                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                  raise "Session doesn't support Railgun!"
                end
      
      
      Severity: Minor
      Found in lib/msf/core/post/windows/accounts.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 get_members_from_group has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_members_from_group(groupname, server_name = nil)
                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                  raise "Session doesn't support Railgun!"
                end
      
      
      Severity: Minor
      Found in lib/msf/core/post/windows/accounts.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 enum_group has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def enum_group(server_name = nil)
                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                  raise "Session doesn't support Railgun!"
                end
      
      
      Severity: Minor
      Found in lib/msf/core/post/windows/accounts.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 check_dir_perms has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def check_dir_perms(dir, token)
                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                  raise "Session doesn't support Railgun!"
                end
      
      
      Severity: Minor
      Found in lib/msf/core/post/windows/accounts.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 get_members_from_localgroup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_members_from_localgroup(localgroupname, server_name = nil)
                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                  raise "Session doesn't support Railgun!"
                end
      
      
      Severity: Minor
      Found in lib/msf/core/post/windows/accounts.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 check_dir_perms has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def check_dir_perms(dir, token)
                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                  raise "Session doesn't support Railgun!"
                end
      
      
      Severity: Minor
      Found in lib/msf/core/post/windows/accounts.rb - About 1 hr to fix

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

                def get_primary_domain_controller
                  if session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                    domain = get_domain('DomainControllerName')
                  else
                    # Use cached domain controller name
        Severity: Minor
        Found in lib/msf/core/post/windows/accounts.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

        Avoid too many return statements within this method.
        Open

                    return :success
        Severity: Major
        Found in lib/msf/core/post/windows/accounts.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                        return nil
          Severity: Major
          Found in lib/msf/core/post/windows/accounts.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return {
                        name: lookup['Name'],
                        domain: lookup['ReferencedDomainName'],
                        type: sid_type,
                        mapped: true
            Severity: Major
            Found in lib/msf/core/post/windows/accounts.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                            return { type: :invalid }
              Severity: Major
              Found in lib/msf/core/post/windows/accounts.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return :access_denied
                Severity: Major
                Found in lib/msf/core/post/windows/accounts.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                return { mapped: false }
                  Severity: Major
                  Found in lib/msf/core/post/windows/accounts.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                  return nil
                    Severity: Major
                    Found in lib/msf/core/post/windows/accounts.rb - About 30 mins to fix

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

                              def delete_user(username, server_name = nil)
                                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                                  return nil
                                end
                      
                      
                      Severity: Minor
                      Found in lib/msf/core/post/windows/accounts.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

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

                              def get_members_from_group(groupname, server_name = nil)
                                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                                  raise "Session doesn't support Railgun!"
                                end
                      
                      
                      Severity: Major
                      Found in lib/msf/core/post/windows/accounts.rb and 1 other location - About 2 hrs to fix
                      lib/msf/core/post/windows/accounts.rb on lines 626..649

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

                      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

                              def get_members_from_localgroup(localgroupname, server_name = nil)
                                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                                  raise "Session doesn't support Railgun!"
                                end
                      
                      
                      Severity: Major
                      Found in lib/msf/core/post/windows/accounts.rb and 1 other location - About 2 hrs to fix
                      lib/msf/core/post/windows/accounts.rb on lines 589..615

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

                      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

                              def enum_group(server_name = nil)
                                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                                  raise "Session doesn't support Railgun!"
                                end
                      
                      
                      Severity: Major
                      Found in lib/msf/core/post/windows/accounts.rb and 1 other location - About 2 hrs to fix
                      lib/msf/core/post/windows/accounts.rb on lines 693..716

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

                      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

                              def enum_localgroup(server_name = nil)
                                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                                  raise "Session doesn't support Railgun!"
                                end
                      
                      
                      Severity: Major
                      Found in lib/msf/core/post/windows/accounts.rb and 1 other location - About 2 hrs to fix
                      lib/msf/core/post/windows/accounts.rb on lines 726..749

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

                      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

                              def add_localgroup(localgroup, server_name = nil)
                                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                                  raise "Session doesn't support Railgun!"
                                end
                      
                      
                      Severity: Major
                      Found in lib/msf/core/post/windows/accounts.rb and 1 other location - About 1 hr to fix
                      lib/msf/core/post/windows/accounts.rb on lines 518..532

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

                      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

                              def add_group(group, server_name = nil)
                                unless session.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_RAILGUN_API)
                                  raise "Session doesn't support Railgun!"
                                end
                      
                      
                      Severity: Major
                      Found in lib/msf/core/post/windows/accounts.rb and 1 other location - About 1 hr to fix
                      lib/msf/core/post/windows/accounts.rb on lines 492..506

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

                      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