cyberark/secretless-broker

View on GitHub

Showing 46 of 1,876 total issues

Function TestUnpackHandshakeV10 has 88 lines of code (exceeds 70 allowed). Consider refactoring.
Open

func TestUnpackHandshakeV10(t *testing.T) {

    type UnpackHandshakeV10Assert struct {
        Packet   []byte
        HasError bool
Severity: Major
Found in internal/plugin/connectors/tcp/mysql/protocol/protocol_test.go - About 1 hr to fix

    Method AuthenticationHandshake.handleBackendAuthResponse has 87 lines of code (exceeds 70 allowed). Consider refactoring.
    Open

    func (h *AuthenticationHandshake) handleBackendAuthResponse() {
        if h.err != nil {
            return
        }
    
    
    Severity: Major
    Found in internal/plugin/connectors/tcp/mysql/authentication_handshake.go - About 1 hr 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

        Method LogTest.RunAllTests has 86 lines of code (exceeds 70 allowed). Consider refactoring.
        Open

        func (lt *LogTest) RunAllTests(t *testing.T) {
        
            // Format strings and sample arguments used in the test cases
            const testCaseFormatStr = "aaa %s bbb %d ccc %2.1f ddd \t eee"
            testCaseArgs := []interface{}{"stringval", 123, 1.234}
        Severity: Major
        Found in internal/log/log_test.go - About 1 hr to fix

          Method AuthenticationHandshake.handleBackendAuthResponse has 17 return statements (exceeds 7 allowed).
          Open

          func (h *AuthenticationHandshake) handleBackendAuthResponse() {
              if h.err != nil {
                  return
              }
          
          
          Severity: Major
          Found in internal/plugin/connectors/tcp/mysql/authentication_handshake.go - About 1 hr to fix

            Method proxyService.Start has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
            Open

            func (proxy *proxyService) Start() error {
                logger := proxy.logger
            
                logger.Infof("Starting service")
            
            
            Severity: Minor
            Found in internal/plugin/connectors/ssh/proxy_service.go - 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

            Function extractShellCommand has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function extractShellCommand(shellBlock) {
              var blockLines = shellBlock.innerText.split("\n");
              var command = "";
            
              var includeNextLine = true;
            Severity: Minor
            Found in docs/javascript/clipboard-buttons.js - 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

            Function main has 74 lines of code (exceeds 70 allowed). Consider refactoring.
            Open

            func main() {
                log.Println("Secretless CRD watcher starting up...")
            
                var kubeConfig *string
                if home := getHomeDir(); home != "" {
            Severity: Minor
            Found in resource-definitions/crd_watcher.go - About 1 hr to fix

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

              func handleAuthSCRAM(username string, password string, connection net.Conn) error {
                  sc := scram.NewClient(sha256.New, username, password)
                  sc.Step(nil)
                  if sc.Err() != nil {
                      return fmt.Errorf("SCRAM-SHA-256 error: %s", sc.Err().Error())
              Severity: Major
              Found in internal/plugin/connectors/tcp/pg/protocol/auth.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 TestV1HttpHandlerConversion has 72 lines of code (exceeds 70 allowed). Consider refactoring.
                    Open

                    func TestV1HttpHandlerConversion(t *testing.T) {
                        t.Run("connectorConfig field maps correctly", func(t *testing.T) {
                            v1Cfg := v1HttpExample()
                            v2Cfg, err := NewV2Config(v1Cfg)
                            assert.NoError(t, err)
                    Severity: Minor
                    Found in pkg/secretless/config/v1/v2_conversion_test.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 runTest has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          func runTest(backendName string, threadIndex int, aggregateTimings *timing.AggregateTimings,
                              testManager *TestManager, round int) time.Duration {
                          Severity: Minor
                          Found in bin/juxtaposer/main.go - About 35 mins to fix

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

                                pluginDir string,
                                checksumsFile string,
                                internalLookupFunc InternalPluginLookupFunc,
                                externalLookupfunc ExternalPluginLookupFunc,
                                logger log.Logger,
                            Severity: Minor
                            Found in pkg/secretless/plugin/sharedobj/available_plugins.go - About 35 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 TestConfigEnv has 8 return statements (exceeds 7 allowed).
                                Open

                                func TestConfigEnv(t *testing.T) {
                                
                                    // Shared mocks and doubles
                                
                                    logger := loggermock.NewLogger()
                                Severity: Major
                                Found in pkg/secretless/config/v2/config_env_test.go - About 35 mins to fix

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

                                  func RegisterCRDListener(namespace string, configSpec string, resourceEventHandler ResourceEventHandler) error {
                                      log.Printf("%s: Registering CRD watcher...", PluginName)
                                  
                                      clientConfig, err := NewKubernetesConfig()
                                      if err != nil {
                                  Severity: Major
                                  Found in internal/configurationmanagers/kubernetes/crd/crd_watcher.go - About 35 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language