biurad/php-security

View on GitHub

Showing 27 of 27 total issues

Function authenticate has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function authenticate(ServerRequestInterface $request, array $credentials, array $onlyCheck = [])
    {
        if (empty($authenticators = $this->authenticators)) {
            throw new ProviderNotFoundException('No authenticator found.');
        }
Severity: Minor
Found in src/Authenticator.php - About 4 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 consumeRememberMeCookie has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function consumeRememberMeCookie(string $rawCookie, UserProviderInterface $userProvider): array
    {
        [, $identifier, $expires, $value] = self::fromRawCookie($rawCookie);

        if (!\str_contains($value, ':')) {
Severity: Minor
Found in src/Handler/RememberMeHandler.php - About 2 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 authenticate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function authenticate(ServerRequestInterface $request, array $credentials, string $firewallName): ?TokenInterface
    {
        $loadedUsers = $cookies = [];

        foreach ($request->getCookieParams() as $cookieName => $rawCookie) {
Severity: Minor
Found in src/Authenticator/RememberMeAuthenticator.php - About 2 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 authenticate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function authenticate(ServerRequestInterface $request, array $credentials, $firewallName): ?TokenInterface
    {
        if (empty($credentials)) {
            return null;
        }
Severity: Minor
Found in src/Authenticator/FormLoginAuthenticator.php - About 2 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 __construct has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct(object $storage, $expiry = 60 * 60 * 24 * 30)
    {
        $this->storage = function (string $key, TokenInterface $token = null) use ($storage, $expiry): ?TokenInterface {
            if (1 === \func_num_args()) {
                if ($storage instanceof CacheItemPoolInterface) {
Severity: Minor
Found in src/Token/CacheableTokenStorage.php - About 2 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

Method authenticate has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function authenticate(ServerRequestInterface $request, array $credentials, array $onlyCheck = [])
    {
        if (empty($authenticators = $this->authenticators)) {
            throw new ProviderNotFoundException('No authenticator found.');
        }
Severity: Minor
Found in src/Authenticator.php - About 1 hr to fix

    Method consumeRememberMeCookie has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function consumeRememberMeCookie(string $rawCookie, UserProviderInterface $userProvider): array
        {
            [, $identifier, $expires, $value] = self::fromRawCookie($rawCookie);
    
            if (!\str_contains($value, ':')) {
    Severity: Minor
    Found in src/Handler/RememberMeHandler.php - About 1 hr to fix

      Method authenticate has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function authenticate(ServerRequestInterface $request, array $credentials, $firewallName): ?TokenInterface
          {
              if (empty($credentials)) {
                  return null;
              }
      Severity: Minor
      Found in src/Authenticator/FormLoginAuthenticator.php - About 1 hr to fix

        Method execute has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function execute(InputInterface $input, OutputInterface $output)
            {
                $errorIo = new SymfonyStyle($input, $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output);
                $input->isInteractive() ? $errorIo->title('Biurad User Utility') : $errorIo->newLine();
        
        
        Severity: Minor
        Found in src/Commands/UserStatusCommand.php - About 1 hr to fix

          Function authenticate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function authenticate(ServerRequestInterface $request, array $credentials, string $firewallName): ?TokenInterface
              {
                  if (isset($credentials['g-recaptcha-response'])) {
                      if (empty($captcha = $credentials['g-recaptcha-response'])) {
                          throw new BadCredentialsException('The presented captcha cannot be empty.');
          Severity: Minor
          Found in src/Authenticator/CaptchaAuthenticator.php - 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 supports has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function supports(ServerRequestInterface $request): bool
              {
                  if (!$username = ($request->getServerParams()[$this->userKey] ?? null)) {
                      $username = $request->getServerParams()[$this->credentialsKey] ?? null;
          
          
          Severity: Minor
          Found in src/Authenticator/RemoteUserAuthenticator.php - 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 getParameterValue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function getParameterValue(object $data, string $path, PropertyAccessorInterface $propertyAccessor = null)
              {
                  if ($data instanceof ServerRequestInterface) {
                      $getter = static function (string $value) use ($data) {
                          if ($data instanceof Request) {
          Severity: Minor
          Found in src/Helper.php - 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 __construct has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  array $authenticators,
                  TokenStorageInterface $tokenStorage,
                  AccessDecisionManagerInterface $accessDecisionManager,
                  UserCheckerInterface $userChecker = null,
                  AbstractRequestRateLimiter $limiter = null,
          Severity: Major
          Found in src/Authenticator.php - About 1 hr to fix

            Method __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct(object $storage, $expiry = 60 * 60 * 24 * 30)
                {
                    $this->storage = function (string $key, TokenInterface $token = null) use ($storage, $expiry): ?TokenInterface {
                        if (1 === \func_num_args()) {
                            if ($storage instanceof CacheItemPoolInterface) {
            Severity: Minor
            Found in src/Token/CacheableTokenStorage.php - About 1 hr to fix

              Method authenticate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function authenticate(ServerRequestInterface $request, array $credentials, string $firewallName): ?TokenInterface
                  {
                      $loadedUsers = $cookies = [];
              
                      foreach ($request->getCookieParams() as $cookieName => $rawCookie) {
              Severity: Minor
              Found in src/Authenticator/RememberMeAuthenticator.php - About 1 hr to fix

                Method getParameterValue has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function getParameterValue(object $data, string $path, PropertyAccessorInterface $propertyAccessor = null)
                    {
                        if ($data instanceof ServerRequestInterface) {
                            $getter = static function (string $value) use ($data) {
                                if ($data instanceof Request) {
                Severity: Minor
                Found in src/Helper.php - About 1 hr to fix

                  Function executeAuthenticator has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function executeAuthenticator(AuthenticatorInterface $authenticator, ServerRequestInterface $request, array $credentials): ?TokenInterface
                      {
                          $token = $authenticator->authenticate($request, $credentials, $this->firewallName);
                  
                          if (null !== $token) {
                  Severity: Minor
                  Found in src/Authenticator.php - 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 determineTargetUrl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function determineTargetUrl(
                          ServerRequestInterface $request,
                          SessionInterface $session = null,
                          string $parameter = '_target_path',
                          bool $fromReferer = false
                  Severity: Minor
                  Found in src/Helper.php - About 45 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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          string $secret,
                          TokenProviderInterface $tokenProvider = null,
                          TokenVerifierInterface $tokenVerifier = null,
                          SignatureHasher $signatureHasher = null,
                          string $requestParameter = '_remember_me',
                  Severity: Minor
                  Found in src/Handler/RememberMeHandler.php - About 45 mins to fix

                    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            UserProviderInterface $provider,
                            PasswordHasherFactoryInterface $hasherFactory,
                            RememberMeHandler $rememberMeHandler = null,
                            string $userParameter = '_identifier',
                            string $passwordParameter = '_password'
                    Severity: Minor
                    Found in src/Authenticator/FormLoginAuthenticator.php - About 35 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language