Issues (50)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Container.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Sinergi\Users;
4
5
use Doctrine\ORM\EntityManager;
6
use Interop\Container\ContainerInterface;
7
use Sinergi\Users\Doctrine\User\UserEntity as DoctrineUserEntity;
8
use Sinergi\Users\Doctrine\User\UserRepository as DoctrineUserRepository;
9
use Sinergi\Users\Eloquent\User\UserEntity as EloquentUserEntity;
10
use Sinergi\Users\Eloquent\User\UserRepository as EloquentUserRepository;
11
use Sinergi\Users\Doctrine\Session\SessionEntity as DoctrineSessionEntity;
12
use Sinergi\Users\Doctrine\Session\SessionRepository as DoctrineSessionRepository;
13
use Sinergi\Users\Eloquent\Session\SessionEntity as EloquentSessionEntity;
14
use Sinergi\Users\Eloquent\Session\SessionRepository as EloquentSessionRepository;
15
use Sinergi\Users\Doctrine\Group\GroupEntity as DoctrineGroupEntity;
16
use Sinergi\Users\Doctrine\Group\GroupRepository as DoctrineGroupRepository;
17
use Sinergi\Users\Eloquent\Group\GroupEntity as EloquentGroupEntity;
18
use Sinergi\Users\Eloquent\Group\GroupRepository as EloquentGroupRepository;
19
use Sinergi\Users\Group\GroupEntityInterface;
20
use Sinergi\Users\Group\GroupRepositoryInterface;
21
use Sinergi\Users\Group\GroupValidator;
22
use Sinergi\Users\Group\GroupValidatorInterface;
23
use Sinergi\Users\Session\SessionEntityInterface;
24
use Sinergi\Users\Session\SessionRepositoryInterface;
25
use Sinergi\Users\User\UserEntityInterface;
26
use Sinergi\Users\User\UserRepositoryInterface;
27
use Sinergi\Users\User\UserValidator;
28
use Sinergi\Users\User\UserValidatorInterface;
29
30
class Container implements ContainerInterface
31
{
32
    private $container;
33
    private $items = [];
34
35
    public function __construct(ContainerInterface $container)
36
    {
37
        $this->container = $container;
38
        $this->init();
39
    }
40
41
    private function init()
42
    {
43
        $self = $this;
44
        $hasUserEntity = $this->container->has(UserEntityInterface::class);
45
        $hasUserRepository = $this->container->has(UserRepositoryInterface::class);
46
        $hasSessionEntity = $this->container->has(SessionEntityInterface::class);
47
        $hasSessionRepository = $this->container->has(SessionRepositoryInterface::class);
48
        $hasGroupEntity = $this->container->has(GroupEntityInterface::class);
49
        $hasGroupRepository = $this->container->has(GroupRepositoryInterface::class);
50
        $hasUserValidator = $this->container->has(UserValidatorInterface::class);
51
        $hasGroupValidator = $this->container->has(GroupValidatorInterface::class);
52
53
        if (!$hasUserEntity || !$hasSessionEntity || !$hasGroupEntity) {
54
            throw new \Exception('Container passed to Sinergi\\Users must contain user, group and session\'s entities');
55
        }
56
57 View Code Duplication
        if ($hasUserEntity && !$hasUserRepository) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
            $userEntity = $this->container->get(UserEntityInterface::class);
59
            if ($userEntity instanceof DoctrineUserEntity) {
60
                $em = $this->container->get(EntityManager::class);
61
                $this->items[UserRepositoryInterface::class] = function () use ($em, $userEntity, $self) {
62
                    return new DoctrineUserRepository($em, $em->getClassMetadata(get_class($userEntity)), $self);
63
                };
64
            } elseif ($userEntity instanceof EloquentUserEntity) {
65
                $this->items[UserRepositoryInterface::class] = function () {
66
                    return new EloquentUserRepository();
67
                };
68
            }
69
        }
70
71 View Code Duplication
        if ($hasSessionEntity && !$hasSessionRepository) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
            $sessionEntity = $this->container->get(SessionEntityInterface::class);
73
            if ($sessionEntity instanceof DoctrineSessionEntity) {
74
                $em = $this->container->get(EntityManager::class);
75
                $this->items[SessionRepositoryInterface::class] = function () use ($em, $sessionEntity, $self) {
76
                    return new DoctrineSessionRepository($em, $em->getClassMetadata(get_class($sessionEntity)), $self);
77
                };
78
            } elseif ($sessionEntity instanceof EloquentSessionEntity) {
79
                $this->items[SessionRepositoryInterface::class] = function () {
80
                    return new EloquentSessionRepository();
81
                };
82
            }
83
        }
84
85 View Code Duplication
        if ($hasGroupEntity && !$hasGroupRepository) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
            $groupEntity = $this->container->get(GroupEntityInterface::class);
87
            if ($groupEntity instanceof DoctrineGroupEntity) {
88
                $em = $this->container->get(EntityManager::class);
89
                $this->items[GroupRepositoryInterface::class] = function () use ($em, $groupEntity, $self) {
90
                    return new DoctrineGroupRepository($em, $em->getClassMetadata(get_class($groupEntity)), $self);
91
                };
92
            } elseif ($groupEntity instanceof EloquentGroupEntity) {
93
                $this->items[GroupRepositoryInterface::class] = function () {
94
                    return new EloquentGroupRepository();
95
                };
96
            }
97
        }
98
99
        if (!$hasUserValidator) {
100
            $this->items[UserValidatorInterface::class] = function () use ($self) {
101
                return new UserValidator($self);
102
            };
103
        }
104
105
        if (!$hasGroupValidator) {
106
            $this->items[GroupValidatorInterface::class] = function () use ($self) {
107
                return new GroupValidator($self);
108
            };
109
        }
110
    }
111
112
    public function get($id)
113
    {
114
        if (isset($this->items[$id])) {
115
            $item = $this->items[$id];
116
            if (is_callable($item)) {
117
                return call_user_func($item);
118
            } else {
119
                return $item;
120
            }
121
        }
122
        return $this->container->get($id);
123
    }
124
125
    public function has($id): bool
126
    {
127
        if (isset($this->items[$id])) {
128
            return true;
129
        }
130
        return $this->container->has($id);
131
    }
132
}
133