cyberark/secretless-broker

View on GitHub
internal/plugin/connectors/tcp/mysql/protocol/protocol.go

Summary

Maintainability
D
1 day
Test Coverage
C
75%

File protocol.go has 651 lines of code (exceeds 500 allowed). Consider refactoring.
Open

/*
MIT License

Copyright (c) 2017 Aleksandr Fedotov

Severity: Minor
Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 5 hrs to fix

    Function UnpackHandshakeV10 has 87 lines of code (exceeds 70 allowed). Consider refactoring.
    Open

    func UnpackHandshakeV10(packet []byte) (*HandshakeV10, error) {
        r := bytes.NewReader(packet)
    
        // Header
        header, err := GetPacketHeader(r)
    Severity: Major
    Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 1 hr to fix

      Function UnpackHandshakeV10 has 14 return statements (exceeds 7 allowed).
      Open

      func UnpackHandshakeV10(packet []byte) (*HandshakeV10, error) {
          r := bytes.NewReader(packet)
      
          // Header
          header, err := GetPacketHeader(r)
      Severity: Major
      Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 1 hr to fix

        Function UnpackHandshakeResponse41 has 72 lines of code (exceeds 70 allowed). Consider refactoring.
        Open

        func UnpackHandshakeResponse41(packet []byte) (*HandshakeResponse41, error) {
            r := bytes.NewReader(packet)
        
            // Skip packet header (but save in struct)
            header, err := GetPacketHeader(r)
        Severity: Minor
        Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 1 hr to fix

          Function UnpackHandshakeV10 has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func UnpackHandshakeV10(packet []byte) (*HandshakeV10, error) {
              r := bytes.NewReader(packet)
          
              // Header
              header, err := GetPacketHeader(r)
          Severity: Minor
          Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 55 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

          Function UnpackHandshakeResponse41 has 11 return statements (exceeds 7 allowed).
          Open

          func UnpackHandshakeResponse41(packet []byte) (*HandshakeResponse41, error) {
              r := bytes.NewReader(packet)
          
              // Skip packet header (but save in struct)
              header, err := GetPacketHeader(r)
          Severity: Major
          Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 50 mins to fix

            Function UnpackOkResponse has 9 return statements (exceeds 7 allowed).
            Open

            func UnpackOkResponse(packet []byte) (*OkResponse, error) {
            
                // Min packet length = header(4 bytes) + PacketType(1 byte)
                if err := CheckPacketLength(5, packet); err != nil {
                    return nil, err
            Severity: Major
            Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 40 mins to fix

              Function InjectCredentials has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func InjectCredentials(authPlugin string, clientHandshake *HandshakeResponse41, salt []byte, username string, password string) (err error) {
              Severity: Minor
              Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 35 mins to fix

                Function RemoveSSLFromHandshakeV10 has 8 return statements (exceeds 7 allowed).
                Open

                func RemoveSSLFromHandshakeV10(packet []byte) ([]byte, error) {
                    r := bytes.NewReader(packet)
                    initialLen := r.Len()
                
                    // Skip packet header
                Severity: Major
                Found in internal/plugin/connectors/tcp/mysql/protocol/protocol.go - About 35 mins to fix

                  TODO found
                  Open

                  // TODO: Add packet struct comment

                  TODO found
                  Open

                  // TODO: Add packet length check

                  TODO found
                  Open

                          //TODO: Check for error

                  TODO found
                  Open

                          //TODO: Check for error

                  There are no issues that match your filters.

                  Category
                  Status