ory-am/hydra

View on GitHub

Showing 853 of 853 total issues

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

func (x *XChaCha20Poly1305) Decrypt(ctx context.Context, ciphertext string, aad []byte) (plaintext []byte, err error) {
    msg, err := base64.URLEncoding.DecodeString(ciphertext)
    if err != nil {
        return nil, errorsx.WithStack(err)
    }
Severity: Major
Found in aead/xchacha20.go - About 35 mins to fix

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

    func (a *OAuth2APIService) SetOAuth2ClientExecute(r ApiSetOAuth2ClientRequest) (*OAuth2Client, *http.Response, error) {
        var (
            localVarHTTPMethod  = http.MethodPut
            localVarPostBody    interface{}
            formFiles           []formFile
    Severity: Minor
    Found in internal/httpclient/api_o_auth2.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 Flow.HandleConsentRequest has 5 return statements (exceeds 4 allowed).
    Open

    func (f *Flow) HandleConsentRequest(r *AcceptOAuth2ConsentRequest) error {
        if time.Time(r.HandledAt).IsZero() {
            return errors.New("refusing to handle a consent request with null HandledAt")
        }
    
    
    Severity: Major
    Found in flow/flow.go - About 35 mins to fix

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

      func (x *XChaCha20Poly1305) Encrypt(ctx context.Context, plaintext, additionalData []byte) (string, error) {
          key, err := encryptionKey(ctx, x.d, chacha20poly1305.KeySize)
          if err != nil {
              return "", err
          }
      Severity: Major
      Found in aead/xchacha20.go - About 35 mins to fix

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

        func (s *DefaultStrategy) HandleOAuth2AuthorizationRequest(
            ctx context.Context,
            w http.ResponseWriter,
            r *http.Request,
            req fosite.AuthorizeRequester,
        Severity: Major
        Found in consent/strategy_default.go - About 35 mins to fix

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

          func (o OidcConfiguration) ToMap() (map[string]interface{}, error) {
              toSerialize := map[string]interface{}{}
              toSerialize["authorization_endpoint"] = o.AuthorizationEndpoint
              if !IsNil(o.BackchannelLogoutSessionSupported) {
                  toSerialize["backchannel_logout_session_supported"] = o.BackchannelLogoutSessionSupported
          Severity: Minor
          Found in internal/httpclient/model_oidc_configuration.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 Persister.mySQLConfirmLoginSession has 5 return statements (exceeds 4 allowed).
          Open

          func (p *Persister) mySQLConfirmLoginSession(ctx context.Context, session *flow.LoginSession) error {
              err := sqlcon.HandleError(p.Connection(ctx).Create(session))
              if err == nil {
                  return nil
              }
          Severity: Major
          Found in persistence/sql/persister_consent.go - About 35 mins to fix

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

            func NewPerformClientCredentialsCmd() *cobra.Command {
                cmd := &cobra.Command{
                    Use:     "client-credentials",
                    Args:    cobra.NoArgs,
                    Example: `{{ .CommandPath }} --client-id ... --client-secret`,
            Severity: Major
            Found in cmd/cmd_perform_client_credentials.go - About 35 mins to fix

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

              func (h *MigrateHandler) makePersister(cmd *cobra.Command, args []string) (p persistence.Persister, err error) {
                  var d driver.Registry
              
                  if flagx.MustGetBool(cmd, "read-from-env") {
                      d, err = driver.New(
              Severity: Major
              Found in cmd/cli/handler_migrate.go - About 35 mins to fix

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

                func (v *Validator) ValidateDynamicRegistration(ctx context.Context, c *Client) error {
                    if c.Metadata != nil {
                        return errorsx.WithStack(ErrInvalidClientMetadata.
                            WithHint(`"metadata" cannot be set for dynamic client registration`),
                        )
                Severity: Major
                Found in client/validator.go - About 35 mins to fix

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

                  func (mg migrationGroup) generateSQL(sourceFS fs.FS, target string) error {
                      ms := mg.Children
                      if mg.fallbackDownMigration != nil {
                          ms = append(ms, mg.fallbackDownMigration)
                      }
                  Severity: Major
                  Found in cmd/cli/handler_migrate.go - About 35 mins to fix

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

                    func NewCreateJWKSCmd() *cobra.Command {
                        const alg = "alg"
                        const use = "use"
                    
                        cmd := &cobra.Command{
                    Severity: Major
                    Found in cmd/cmd_create_jwks.go - About 35 mins to fix

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

                      func NewListClientsCmd() *cobra.Command {
                          cmd := &cobra.Command{
                              Use:     "oauth2-clients",
                              Aliases: []string{"clients"},
                              Short:   "List OAuth 2.0 Clients",
                      Severity: Major
                      Found in cmd/cmd_list_clients.go - About 35 mins to fix

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

                        func (c *tlsConfig) GetCertificateFunc(stopReload <-chan struct{}, log *logrusx.Logger) (func(*tls.ClientHelloInfo) (*tls.Certificate, error), error) {
                            if c.certPath != "" && c.keyPath != "" { // attempt to load from disk first (enables hot-reloading)
                                ctx, cancel := context.WithCancel(context.Background())
                                go func() {
                                    <-stopReload
                        Severity: Major
                        Found in driver/config/tls.go - About 35 mins to fix

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

                          func (h *Handler) ValidDynamicAuth(r *http.Request, ps httprouter.Params) (fosite.Client, error) {
                              c, err := h.r.ClientManager().GetConcreteClient(r.Context(), ps.ByName("id"))
                              if err != nil {
                                  return nil, herodot.ErrUnauthorized.
                                      WithTrace(err).
                          Severity: Major
                          Found in client/handler.go - About 35 mins to fix

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

                            func NewGetJWKSCmd() *cobra.Command {
                                cmd := &cobra.Command{
                                    Use:     "jwk set-1 [set-2] ...",
                                    Aliases: []string{"jwks"},
                                    Args:    cobra.MinimumNArgs(1),
                            Severity: Major
                            Found in cmd/cmd_get_jwks.go - About 35 mins to fix

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

                              func (p *Persister) VerifyAndInvalidateLogoutRequest(ctx context.Context, verifier string) (_ *flow.LogoutRequest, err error) {
                                  ctx, span := p.r.Tracer(ctx).Tracer().Start(ctx, "persistence.sql.VerifyAndInvalidateLogoutRequest")
                                  defer otelx.End(span, &err)
                              
                                  var lr flow.LogoutRequest
                              Severity: Major
                              Found in persistence/sql/persister_consent.go - About 35 mins to fix

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

                                func (p *DefaultProvider) getHookConfig(ctx context.Context, key string) *HookConfig {
                                    if hookURL := p.getProvider(ctx).RequestURIF(key, nil); hookURL != nil {
                                        return &HookConfig{
                                            URL: hookURL.String(),
                                        }
                                Severity: Major
                                Found in driver/config/provider.go - About 35 mins to fix

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

                                  func (*JanitorHandler) Args(cmd *cobra.Command, args []string) error {
                                      if len(args) == 0 &&
                                          !flagx.MustGetBool(cmd, ReadFromEnv) &&
                                          len(flagx.MustGetStringSlice(cmd, Config)) == 0 {
                                  
                                  
                                  Severity: Major
                                  Found in cmd/cli/handler_janitor.go - About 35 mins to fix

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

                                    func NewRevokeTokenCmd() *cobra.Command {
                                        cmd := &cobra.Command{
                                            Use:     "token the-token",
                                            Example: `{{ .CommandPath }} --client-id a0184d6c-b313-4e70-a0b9-905b581e9218 --client-secret Hh1BjioNNm ciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNT`,
                                            Args:    cobra.ExactArgs(1),
                                    Severity: Major
                                    Found in cmd/cmd_revoke_token.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language