ory-am/hydra

View on GitHub

Showing 849 of 849 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it("should fail to update client name when Authorization header is not presented", function () {
    cy.request({
      method: "POST",
      url: Cypress.env("public_url") + "/oauth2/register",
      body: {
Severity: Major
Found in cypress/integration/openid/dynamic_client_registration.js and 1 other location - About 6 hrs to fix
cypress/integration/openid/dynamic_client_registration.js on lines 147..167

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 167.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  it("should fail to delete client when Authorization header is not presented", function () {
    cy.request({
      method: "POST",
      url: Cypress.env("public_url") + "/oauth2/register",
      body: {
Severity: Major
Found in cypress/integration/openid/dynamic_client_registration.js and 1 other location - About 6 hrs to fix
cypress/integration/openid/dynamic_client_registration.js on lines 125..145

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 167.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        cy.get("body")
          .invoke("text")
          .then((content) => {
            const {
              result,
Severity: Major
Found in cypress/integration/oauth2/authorize_code.js and 1 other location - About 6 hrs to fix
cypress/integration/oauth2/authorize_code.js on lines 28..40

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 163.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        cy.get("body")
          .invoke("text")
          .then((content) => {
            const {
              result,
Severity: Major
Found in cypress/integration/oauth2/authorize_code.js and 1 other location - About 6 hrs to fix
cypress/integration/oauth2/authorize_code.js on lines 106..118

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 163.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function TestAuthCodeWithDefaultStrategy has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring.
Open

func TestAuthCodeWithDefaultStrategy(t *testing.T) {
    ctx := context.Background()
    reg := internal.NewMockedRegistry(t, &contextx.Default{})
    reg.Config().MustSet(ctx, config.KeyAccessTokenStrategy, "opaque")
    reg.Config().MustSet(ctx, config.KeyRefreshTokenHook, "")
Severity: Minor
Found in oauth2/oauth2_auth_code_test.go - About 6 hrs 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 TestKeyManager_GetKey has 181 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestKeyManager_GetKey(t *testing.T) {
    ctrl := gomock.NewController(t)
    hsmContext := NewMockContext(ctrl)
    defer ctrl.Finish()
    l := logrusx.New("", "")
Severity: Major
Found in hsm/manager_hsm_test.go - About 6 hrs to fix

    Function TestValidateCsrfSession has 178 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func TestValidateCsrfSession(t *testing.T) {
        const name = "oauth2_authentication_csrf"
    
        type cookie struct {
            name      string
    Severity: Major
    Found in consent/helper_test.go - About 6 hrs to fix

      File api_oidc.go has 666 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      /*
      Ory Hydra API
      
      Documentation for all of Ory Hydra's APIs.
      
      
      Severity: Minor
      Found in internal/httpclient/api_oidc.go - About 6 hrs to fix

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                            t.Run("should fail token refresh with `server_error` if refresh hook fails", func(t *testing.T) {
                                run := func(hookType string) func(t *testing.T) {
                                    return func(t *testing.T) {
                                        hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                                            w.WriteHeader(http.StatusInternalServerError)
        Severity: Major
        Found in oauth2/oauth2_auth_code_test.go and 2 other locations - About 6 hrs to fix
        oauth2/oauth2_auth_code_test.go on lines 1790..1818
        oauth2/oauth2_auth_code_test.go on lines 1820..1848

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 428.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                            t.Run("should fail token refresh with `server_error` if refresh hook response is malformed", func(t *testing.T) {
                                run := func(hookType string) func(t *testing.T) {
                                    return func(t *testing.T) {
                                        hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                                            w.WriteHeader(http.StatusOK)
        Severity: Major
        Found in oauth2/oauth2_auth_code_test.go and 2 other locations - About 6 hrs to fix
        oauth2/oauth2_auth_code_test.go on lines 1760..1788
        oauth2/oauth2_auth_code_test.go on lines 1790..1818

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 428.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

                            t.Run("should fail token refresh with `access_denied` if legacy refresh hook denied the request", func(t *testing.T) {
                                run := func(hookType string) func(t *testing.T) {
                                    return func(t *testing.T) {
                                        hs := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                                            w.WriteHeader(http.StatusForbidden)
        Severity: Major
        Found in oauth2/oauth2_auth_code_test.go and 2 other locations - About 6 hrs to fix
        oauth2/oauth2_auth_code_test.go on lines 1760..1788
        oauth2/oauth2_auth_code_test.go on lines 1820..1848

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 428.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function NewKeysImportCmd has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
        Open

        func NewKeysImportCmd() *cobra.Command {
            cmd := &cobra.Command{
                Use:  "jwk set-id file-1 [file-2] [file-n]",
                Args: cobra.MinimumNArgs(1),
                Example: `{{ .CommandPath }} my-set ./path/to/jwk.json ./path/to/jwk-2.json --format json
        Severity: Minor
        Found in cmd/cmd_import_jwk.go - About 5 hrs 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 createPlan has a Cognitive Complexity of 54 (exceeds 20 allowed). Consider refactoring.
        Open

        func createPlan(t *testing.T, extra url.Values, isParallel bool) {
            planName := extra.Get("planName")
            if stringslice.Has(skipWhenShort, planName) && testing.Short() {
                t.Skipf("Skipping test plan '%s' because short tests", planName)
                return
        Severity: Minor
        Found in test/conformance/run_test.go - About 5 hrs 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 TestKeyManager_GenerateAndPersistKeySet has 172 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func TestKeyManager_GenerateAndPersistKeySet(t *testing.T) {
            ctrl := gomock.NewController(t)
            hsmContext := NewMockContext(ctrl)
            defer ctrl.Finish()
            l := logrusx.New("", "")
        Severity: Major
        Found in hsm/manager_hsm_test.go - About 5 hrs to fix

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          func (s *PersisterTestSuite) TestDeleteOpenIDConnectSession() {
              t := s.T()
              for k, r := range s.registries {
                  t.Run(k, func(t *testing.T) {
                      client := &client.Client{ID: "client-id"}
          Severity: Major
          Found in persistence/sql/persister_nid_test.go and 2 other locations - About 5 hrs to fix
          persistence/sql/persister_nid_test.go on lines 694..716
          persistence/sql/persister_nid_test.go on lines 718..740

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 419.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          func (s *PersisterTestSuite) TestDeleteRefreshTokenSession() {
              t := s.T()
              for k, r := range s.registries {
                  t.Run(k, func(t *testing.T) {
                      client := &client.Client{ID: "client-id"}
          Severity: Major
          Found in persistence/sql/persister_nid_test.go and 2 other locations - About 5 hrs to fix
          persistence/sql/persister_nid_test.go on lines 670..692
          persistence/sql/persister_nid_test.go on lines 694..716

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 419.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          func (s *PersisterTestSuite) TestDeletePKCERequestSession() {
              t := s.T()
              for k, r := range s.registries {
                  t.Run(k, func(t *testing.T) {
                      client := &client.Client{ID: "client-id"}
          Severity: Major
          Found in persistence/sql/persister_nid_test.go and 2 other locations - About 5 hrs to fix
          persistence/sql/persister_nid_test.go on lines 670..692
          persistence/sql/persister_nid_test.go on lines 718..740

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 419.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          File index.js has 409 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // Copyright © 2022 Ory Corp
          // SPDX-License-Identifier: Apache-2.0
          
          const express = require("express")
          const session = require("express-session")
          Severity: Minor
          Found in test/e2e/oauth2-client/src/index.js - About 5 hrs to fix

            Function TestDoesRequestSatisfyTermination has 168 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func TestDoesRequestSatisfyTermination(t *testing.T) {
                c := internal.NewConfigurationWithDefaultsAndHTTPS()
                r := internal.NewRegistryMemory(t, c, &contextx.Default{})
            
                t.Run("case=tls-termination-disabled", func(t *testing.T) {
            Severity: Major
            Found in x/tls_termination_test.go - About 5 hrs to fix

              OAuth2ClientTokenLifespans has 42 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type OAuth2ClientTokenLifespans struct {
                  // Specify a time duration in milliseconds, seconds, minutes, hours.
                  AuthorizationCodeGrantAccessTokenLifespan *string `json:"authorization_code_grant_access_token_lifespan,omitempty"`
                  // Specify a time duration in milliseconds, seconds, minutes, hours.
                  AuthorizationCodeGrantIdTokenLifespan *string `json:"authorization_code_grant_id_token_lifespan,omitempty"`
              Severity: Minor
              Found in internal/httpclient/model_o_auth2_client_token_lifespans.go - About 5 hrs to fix
                Severity
                Category
                Status
                Source
                Language