ecadlabs/signatory

View on GitHub

Showing 102 of 102 total issues

Method Config.jwtTokenSource has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Config) jwtTokenSource(ctx context.Context, scopes []string) (oauth2.TokenSource, error) {
    var (
        pk         interface{}
        thumbprint []byte
        err        error
Severity: Minor
Found in pkg/vault/azure/auth/auth.go - 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

Method USBHIDTransport.Open has 5 return statements (exceeds 4 allowed).
Open

func (u *USBHIDTransport) Open(path string) (Exchanger, error) {
    if path == "" {
        devs, err := u.Enumerate()
        if err != nil {
            return nil, err
Severity: Major
Found in pkg/vault/ledger/ledger/usbhid.go - About 35 mins to fix

    Method Vault.GetPublicKey has 5 return statements (exceeds 4 allowed).
    Open

    func (v *Vault) GetPublicKey(ctx context.Context, keyID string) (vault.StoredKey, error) {
        pkresp, err := v.kmsapi.GetPublicKeyWithContext(ctx, &kms.GetPublicKeyInput{
            KeyId: &keyID,
        })
        if err != nil {
    Severity: Major
    Found in pkg/vault/aws/awskms.go - About 35 mins to fix

      Method HSM.signED25519 has 5 return statements (exceeds 4 allowed).
      Open

      func (h *HSM) signED25519(digest []byte, id uint16) (crypt.Ed25519Signature, error) {
          command, err := commands.CreateSignDataEddsaCommand(id, digest)
          if err != nil {
              return nil, fmt.Errorf("(YubiHSM/%s): %w", h.conf.id(), err)
          }
      Severity: Major
      Found in pkg/vault/yubi/yubi.go - About 35 mins to fix

        Method usbHIDRoundTripper.readCommand has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func (u *usbHIDRoundTripper) readCommand() (channel uint16, cmd uint8, data []byte, err error) {
            var (
                dataLen int
                idx     uint16
            )
        Severity: Minor
        Found in pkg/vault/ledger/ledger/usbhid.go - 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

        Method Vault.Ready has 5 return statements (exceeds 4 allowed).
        Open

        func (v *Vault) Ready(ctx context.Context) (bool, error) {
            if v.managementClient == nil {
                return true, nil // ignore
            }
        
        
        Severity: Major
        Found in pkg/vault/azure/azure.go - About 35 mins to fix

          Function New has 5 return statements (exceeds 4 allowed).
          Open

          func New(ctx context.Context, cfg *Config) (*Vault, error) {
              vaultConfig := &api.Config{
                  Address: cfg.Address,
              }
          
          
          Severity: Major
          Found in pkg/vault/hashicorp/vault.go - About 35 mins to fix

            Function readString has 5 return statements (exceeds 4 allowed).
            Open

            func readString(p []byte, end rune) (rem []byte, out string, err error) {
                r, sz := utf8.DecodeRune(p)
                if r == utf8.RuneError {
                    return nil, "", errRune
                }
            Severity: Major
            Found in pkg/utils/utils.go - About 35 mins to fix

              Method Vault.GetPublicKey has 5 return statements (exceeds 4 allowed).
              Open

              func (v *Vault) GetPublicKey(ctx context.Context, keyID string) (vault.StoredKey, error) {
                  wrappingPubKeyString, err := v.Transit().GetKeyWithContext(ctx, keyID)
                  if err != nil {
                      return nil, err
                  }
              Severity: Major
              Found in pkg/vault/hashicorp/vault.go - About 35 mins to fix

                Method HSM.signECDSA has 5 return statements (exceeds 4 allowed).
                Open

                func (h *HSM) signECDSA(digest []byte, id uint16, curve elliptic.Curve) (*crypt.ECDSASignature, error) {
                    command, err := commands.CreateSignDataEcdsaCommand(id, digest)
                    if err != nil {
                        return nil, fmt.Errorf("(YubiHSM/%s): %w", h.conf.id(), err)
                    }
                Severity: Major
                Found in pkg/vault/yubi/yubi.go - About 35 mins to fix

                  Method HSM.Ready has 5 return statements (exceeds 4 allowed).
                  Open

                  func (h *HSM) Ready(ctx context.Context) (bool, error) {
                      command, err := commands.CreateEchoCommand(echoMessage)
                      if err != nil {
                          return false, fmt.Errorf("(YubiHSM/%s): %w", h.conf.id(), err)
                      }
                  Severity: Major
                  Found in pkg/vault/yubi/yubi.go - About 35 mins to fix

                    Method Config.GetPrivateKey has 5 return statements (exceeds 4 allowed).
                    Open

                    func (conf *Config) GetPrivateKey() (crypt.PrivateKey, error) {
                        var keyData []byte
                        if conf.PrivateKey != "" {
                            if priv, err := crypt.ParsePrivateKey([]byte(conf.PrivateKey)); err == nil {
                                return priv, nil
                    Severity: Major
                    Found in cmd/approve-list-svc/config.go - About 35 mins to fix

                      Method tcpRoundTripper.Exchange has 5 return statements (exceeds 4 allowed).
                      Open

                      func (t *tcpRoundTripper) Exchange(req *APDUCommand) (*APDUResponse, error) {
                          data := req.Bytes()
                          //log.Printf("> %s", hex.EncodeToString(data))
                      
                          buf := make([]byte, len(data)+4)
                      Severity: Major
                      Found in pkg/vault/ledger/ledger/tcp.go - About 35 mins to fix

                        Function parsePrivateKey has 5 return statements (exceeds 4 allowed).
                        Open

                        func parsePrivateKey(name, password string) (pk interface{}, err error) {
                            buf, err := ioutil.ReadFile(name)
                            if err != nil {
                                return nil, err
                            }
                        Severity: Major
                        Found in pkg/vault/azure/auth/auth.go - About 35 mins to fix

                          Method scanner.open has 5 return statements (exceeds 4 allowed).
                          Open

                          func (s *scanner) open(id string) (*tezosapp.App, error) {
                              s.mtx.Lock()
                              defer s.mtx.Unlock()
                          
                              devs, err := s.tr.Enumerate()
                          Severity: Major
                          Found in pkg/vault/ledger/scan.go - About 35 mins to fix

                            Method JWTMiddleware.LoginHandler has 5 return statements (exceeds 4 allowed).
                            Open

                            func (m *JWTMiddleware) LoginHandler(w http.ResponseWriter, r *http.Request) {
                                user := r.Header.Get("username")
                                pass := r.Header.Get("password")
                                if user == "" || pass == "" {
                                    w.WriteHeader(http.StatusUnauthorized)
                            Severity: Major
                            Found in pkg/middlewares/jwt.go - About 35 mins to fix

                              Method JWK.ecPublicKey has 5 return statements (exceeds 4 allowed).
                              Open

                              func (j *JWK) ecPublicKey() (k *ecdsa.PublicKey, err error) {
                                  var key ecdsa.PublicKey
                                  if key.Curve = curveByName(j.Curve); key.Curve == nil {
                                      return nil, fmt.Errorf("jwk: unknown curve: %s", j.Curve)
                                  }
                              Severity: Major
                              Found in pkg/vault/azure/jwk/jwk.go - About 35 mins to fix

                                Method Transit.GetKeyWithContext has 5 return statements (exceeds 4 allowed).
                                Open

                                func (t *Transit) GetKeyWithContext(ctx context.Context, keyID string) (string, error) {
                                    s, err := t.c.Logical().ReadWithContext(ctx, fmt.Sprintf("%s/keys/%s", t.cfg.MountPoint, keyID))
                                    if err != nil {
                                        return "", err
                                    }
                                Severity: Major
                                Found in pkg/vault/hashicorp/vault_transit.go - About 35 mins to fix

                                  Method awsKMSIterator.Next has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (i *awsKMSIterator) Next() (key vault.StoredKey, err error) {
                                      for {
                                          if i.lko == nil || i.index == len(i.lko.Keys) {
                                              // get next page
                                              if i.lko != nil && i.lko.NextMarker == nil {
                                  Severity: Major
                                  Found in pkg/vault/aws/awskms.go - About 35 mins to fix

                                    Method Vault.Unlock has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (v *Vault) Unlock(ctx context.Context) error {
                                        v.mtx.Lock()
                                        if v.unlocked {
                                            v.mtx.Unlock()
                                            return nil
                                    Severity: Major
                                    Found in pkg/vault/memory/vault.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language