ecadlabs/signatory

View on GitHub

Showing 91 of 102 total issues

Method Vault.Import has 14 return statements (exceeds 4 allowed).
Open

func (c *Vault) Import(ctx context.Context, pk crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
    keyName, ok, err := opt.GetString("name")
    if err != nil {
        return nil, fmt.Errorf("(CloudKMS/%s): %w", c.config.keyRingName(), err)
    }
Severity: Major
Found in pkg/vault/cloudkms/cloudkms.go - About 1 hr to fix

    Method JWK.PrivateKey has 14 return statements (exceeds 4 allowed).
    Open

    func (j *JWK) PrivateKey() (crypto.PrivateKey, error) {
        switch j.KeyType {
        case "EC", "EC-HSM":
            if j.D == "" {
                return nil, ErrPublic
    Severity: Major
    Found in pkg/vault/azure/jwk/jwk.go - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                  if c >= 32 && c <= 126 && !((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
      Severity: Critical
      Found in pkg/middlewares/jwt.go - About 1 hr to fix

        Function ParseMap has 13 return statements (exceeds 4 allowed).
        Open

        func ParseMap(s string, namevalSep, tuplesSep rune) (res map[string]string, err error) {
            res = make(map[string]string)
            p := []byte(s)
            for {
                p, err = eatSpace(p)
        Severity: Major
        Found in pkg/utils/utils.go - About 1 hr to fix

          Method JWT.CheckUpdateNewCred has 12 return statements (exceeds 4 allowed).
          Open

          func (j *JWT) CheckUpdateNewCred() error {
              for user, data := range j.Users {
                  if data.NewData != nil {
                      if data.NewData.Password == data.Password || data.NewData.Secret == data.Secret {
                          return fmt.Errorf("JWT: new credentials are same as old for user %s", user)
          Severity: Major
          Found in pkg/middlewares/jwt.go - About 1 hr to fix

            Function NewRootCommand has 12 return statements (exceeds 4 allowed).
            Open

            func NewRootCommand(c *Context, name string) *cobra.Command {
                var (
                    level      string
                    configFile string
                    baseDir    string
            Severity: Major
            Found in cmd/commands/root.go - About 1 hr to fix

              Method JWK.PrivateKey has 54 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (j *JWK) PrivateKey() (crypto.PrivateKey, error) {
                  switch j.KeyType {
                  case "EC", "EC-HSM":
                      if j.D == "" {
                          return nil, ErrPublic
              Severity: Minor
              Found in pkg/vault/azure/jwk/jwk.go - About 1 hr to fix

                Method App.GetAppVersion has 11 return statements (exceeds 4 allowed).
                Open

                func (a *App) GetAppVersion() (*Version, error) {
                    res, err := a.Exchange(&APDUCommand{
                        Cla: claGlobal,
                        Ins: insVersion,
                    })
                Severity: Major
                Found in pkg/vault/ledger/ledger/ledger.go - About 1 hr to fix

                  Function Footer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function Footer() {
                      const footerContainer = useRef(null);
                      const [isActive, setIsActive] = useState(false);
                      const { footer } = useThemeConfig();
                      const { copyright, links = [], logo = {} } = footer || {};
                  Severity: Minor
                  Found in website/src/theme/Footer/index.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

                  Method azureIterator.Next has 11 return statements (exceeds 4 allowed).
                  Open

                  func (a *azureIterator) Next() (key vault.StoredKey, err error) {
                      if a.done {
                          return nil, vault.ErrDone
                      }
                  
                  
                  Severity: Major
                  Found in pkg/vault/azure/azure.go - About 1 hr to fix

                    Function NewServeCommand has 11 return statements (exceeds 4 allowed).
                    Open

                    func NewServeCommand(c *Context) *cobra.Command {
                        var noList bool
                    
                        serveCmd := cobra.Command{
                            Use:   "serve",
                    Severity: Major
                    Found in cmd/commands/serve.go - About 1 hr to fix

                      Method Vault.Import has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (v *Vault) Import(ctx context.Context, priv crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
                          keyName, ok, err := opt.GetString("name")
                          if err != nil {
                              return nil, fmt.Errorf("(Azure/%s): %w", v.config.Vault, err)
                          }
                      Severity: Minor
                      Found in pkg/vault/azure/azure.go - About 1 hr to fix

                        Function NewGenKeyCommand has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func NewGenKeyCommand() *cobra.Command {
                            var (
                                keyType string
                                num     int
                            )
                        Severity: Minor
                        Found in cmd/signatory-tools/genkey.go - About 1 hr to fix

                          Method App.GetAppVersion has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (a *App) GetAppVersion() (*Version, error) {
                              res, err := a.Exchange(&APDUCommand{
                                  Cla: claGlobal,
                                  Ins: insVersion,
                              })
                          Severity: Minor
                          Found in pkg/vault/ledger/ledger/ledger.go - About 1 hr to fix

                            Method Vault.Import has 9 return statements (exceeds 4 allowed).
                            Open

                            func (v *Vault) Import(ctx context.Context, priv crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
                                keyName, ok, err := opt.GetString("name")
                                if err != nil {
                                    return nil, fmt.Errorf("(Azure/%s): %w", v.config.Vault, err)
                                }
                            Severity: Major
                            Found in pkg/vault/azure/azure.go - About 55 mins to fix

                              Method JWT.Authenticate has 8 return statements (exceeds 4 allowed).
                              Open

                              func (j *JWT) Authenticate(user string, token string) (string, error) {
                                  var tok *jwt.Token
                                  var err error
                                  ud, ok := j.GetUserData(user)
                                  if ok {
                              Severity: Major
                              Found in pkg/middlewares/jwt.go - About 50 mins to fix

                                Method Vault.SignMessage has 8 return statements (exceeds 4 allowed).
                                Open

                                func (v *Vault) SignMessage(ctx context.Context, message []byte, key vault.StoredKey) (crypt.Signature, error) {
                                    digest := crypt.DigestFunc(message)
                                    azureKey, ok := key.(*azureKey)
                                    if !ok {
                                        return nil, errors.Wrap(fmt.Errorf("(Azure/%s): not a Azure key: %T", v.config.Vault, key), http.StatusBadRequest)
                                Severity: Major
                                Found in pkg/vault/azure/azure.go - About 50 mins to fix

                                  Function NewImportCommand has 8 return statements (exceeds 4 allowed).
                                  Open

                                  func NewImportCommand(c *Context) *cobra.Command {
                                      var (
                                          vaultName string
                                          password  string
                                          opt       string
                                  Severity: Major
                                  Found in cmd/commands/import.go - About 50 mins to fix

                                    Method Vault.request has 7 return statements (exceeds 4 allowed).
                                    Open

                                    func (v *Vault) request(ctx context.Context, client *http.Client, method, url string, body io.Reader, result interface{}) (status int, err error) {
                                        req, err := http.NewRequestWithContext(ctx, method, url, body)
                                        if err != nil {
                                            return status, err
                                        }
                                    Severity: Major
                                    Found in pkg/vault/azure/azure.go - About 45 mins to fix

                                      Function NewAuthRequestCommand has 7 return statements (exceeds 4 allowed).
                                      Open

                                      func NewAuthRequestCommand() *cobra.Command {
                                          cmd := &cobra.Command{
                                              Use:   "authenticate <secret key> <request pkh> <request body>",
                                              Short: "Authenticate (sign) a sign request",
                                              Args:  cobra.ExactArgs(3),
                                      Severity: Major
                                      Found in cmd/signatory-tools/authenticate.go - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language