rapid7/metasploit-framework

View on GitHub
lib/rex/proto/http/web_socket/amazon_ssm.rb

Summary

Maintainability
B
6 hrs
Test Coverage

File amazon_ssm.rb has 311 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'bindata'

module Rex::Proto::Http::WebSocket::AmazonSsm
  module PayloadType
    Output               = 1
Severity: Minor
Found in lib/rex/proto/http/web_socket/amazon_ssm.rb - About 3 hrs to fix

    Method connect_ssm_ws has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def connect_ssm_ws(session_init, timeout = 20)
        # hack-up a "graceful fail-down" in the caller
        # raise Rex::Proto::Http::WebSocket::ConnectionError.new(msg: 'WebSocket sessions still need structs/parsing')
        ws_key = session_init.token_value
        ssm_id = session_init.session_id
    Severity: Minor
    Found in lib/rex/proto/http/web_socket/amazon_ssm.rb - About 1 hr to fix

      Method on_data_read has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def on_data_read(data, _data_type)
              return data if data.blank?
      
              ssm_frame = SsmFrame.read(data)
              case ssm_frame.header.message_type.strip
      Severity: Minor
      Found in lib/rex/proto/http/web_socket/amazon_ssm.rb - About 1 hr to fix

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

            def to_ssm_channel(publish_timeout: 10)
              chan = SsmChannel.new(self)
        
              if publish_timeout
                # Waiting for the channel to start publishing
        Severity: Minor
        Found in lib/rex/proto/http/web_socket/amazon_ssm.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

        There are no issues that match your filters.

        Category
        Status