rapid7/metasploit-framework

View on GitHub
modules/exploits/windows/local/lexmark_driver_privesc.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method initialize has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Lexmark Driver Privilege Escalation',
Severity: Major
Found in modules/exploits/windows/local/lexmark_driver_privesc.rb - About 2 hrs to fix

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

      def check
        res = cmd_exec('pnputil.exe /enum-drivers')
        m = res.scan(%r{Published Name:     ([^.]*\.inf)\r\nOriginal Name:      lmu.*?.inf\r\nProvider Name:      Lexmark International\r\nClass Name:         Printers\r\nClass GUID:         {4d36e979-e325-11ce-bfc1-08002be10318}\r\nDriver Version:     (\d+)/\d+/(\d+) \d+\.\d+\.\d+\.\d+}m)
    
        return CheckCode::Safe('No Lexmark print drivers in the driver store') if m.empty?
    Severity: Minor
    Found in modules/exploits/windows/local/lexmark_driver_privesc.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 add_printer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def add_printer
        fail_with(Failure::NotFound, 'Printer driver script not found') unless file?(@script_path)
        fail_with(Failure::NotFound, 'No driver name set') if @drvr_name.empty?
    
        # If the driver has never been installed, then the vulnerable file won't exist. So let's
    Severity: Minor
    Found in modules/exploits/windows/local/lexmark_driver_privesc.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 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def check
        res = cmd_exec('pnputil.exe /enum-drivers')
        m = res.scan(%r{Published Name:     ([^.]*\.inf)\r\nOriginal Name:      lmu.*?.inf\r\nProvider Name:      Lexmark International\r\nClass Name:         Printers\r\nClass GUID:         {4d36e979-e325-11ce-bfc1-08002be10318}\r\nDriver Version:     (\d+)/\d+/(\d+) \d+\.\d+\.\d+\.\d+}m)
    
        return CheckCode::Safe('No Lexmark print drivers in the driver store') if m.empty?
    Severity: Minor
    Found in modules/exploits/windows/local/lexmark_driver_privesc.rb - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status