Issues (32)

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/Service/ObjectManagerService.php (1 issue)

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
 * @link    https://github.com/nnx-framework/doctrine
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\Doctrine\Service;
7
8
use Doctrine\Common\Persistence\ObjectRepository;
9
use Nnx\Doctrine\EntityManager\EntityManagerInterface;
10
use Nnx\Doctrine\ObjectManager\ObjectManagerAutoDetectorInterface;
11
use Doctrine\Common\Util\ClassUtils;
12
13
/**
14
 * Class ObjectManagerService
15
 *
16
 * @package Nnx\Doctrine\Service
17
 */
18
class ObjectManagerService implements ObjectManagerServiceInterface
19
{
20
21
    /**
22
     * Сервис позволяющий получить ObjectManager по имени класса
23
     *
24
     * @var ObjectManagerAutoDetectorInterface
25
     */
26
    protected $objectManagerAutoDetector;
27
28
    /**
29
     * Менеджер для создания сущностей по интерфейсу
30
     *
31
     * @var EntityManagerInterface
32
     */
33
    protected $entityManager;
34
35
    /**
36
     * ObjectManagerService constructor.
37
     *
38
     * @param ObjectManagerAutoDetectorInterface $objectManagerAutoDetector
39
     * @param EntityManagerInterface             $entityManager
40
     */
41
    public function __construct(ObjectManagerAutoDetectorInterface $objectManagerAutoDetector, EntityManagerInterface $entityManager)
42
    {
43
        $this->setObjectManagerAutoDetector($objectManagerAutoDetector);
44
        $this->setEntityManager($entityManager);
45
    }
46
47
    /**
48
     * @inheritdoc
49
     *
50
     * @param $entityName
51
     *
52
     * @return ObjectRepository
53
     */
54
    public function getRepository($entityName)
55
    {
56
        $resolvedEntityName = $this->getEntityManager()->getEntityClassByInterface($entityName);
57
        $objectManager = $this->getObjectManagerAutoDetector()->getObjectManagerByClassName($resolvedEntityName);
58
        return $objectManager->getRepository($resolvedEntityName);
59
    }
60
61
    /**
62
     * @inheritdoc
63
     *
64
     * @param mixed $entityObject
65
     *
66
     * @throws Exception\InvalidEntityObjectException
67
     */
68
    public function saveEntityObject($entityObject, $flagFlush = self::FLAG_PERSIST)
69
    {
70
        if (!is_object($entityObject)) {
71
            $errMsg = sprintf('Entity type %s is invalid.', gettype($entityObject));
72
            throw new Exception\InvalidEntityObjectException($errMsg);
73
        }
74
75
        $className = ClassUtils::getClass($entityObject);
76
        $objectManager = $this->getObjectManagerAutoDetector()->getObjectManagerByClassName($className);
77
78
        $objectManager->persist($entityObject);
79
        if ($flagFlush) {
80
            /** @noinspection PhpMethodParametersCountMismatchInspection */
81
            //@TODO На уровне интерфейса ObjectManager'a возможности передать сущность в flush нет, есть только в \Doctrine\ORM\EntityManager::flush. Убрать @noinspection, когда наведут порядок в Doctrine
82
            $objectManager->flush($flagFlush === self::FLAG_FLUSH_ALL ? null : $entityObject);
83
        }
84
    }
85
86
87
    /**
88
     * @inheritdoc
89
     *
90
     * @param string $entityName
91
     *
92
     * @throws \Interop\Container\Exception\ContainerException
93
     * @throws \Nnx\Doctrine\Service\Exception\InvalidEntityObjectException
94
     * @throws \Interop\Container\Exception\NotFoundException
95
     */
96
    public function createEntityObject($entityName, array $options = [])
97
    {
98
        return $this->getEntityManager()->get($entityName, $options);
0 ignored issues
show
The call to EntityManagerInterface::get() has too many arguments starting with $options.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
99
    }
100
101
    /**
102
     * Возвращает сервис позволяющий получить ObjectManager по имени класса
103
     *
104
     * @return ObjectManagerAutoDetectorInterface
105
     */
106
    public function getObjectManagerAutoDetector()
107
    {
108
        return $this->objectManagerAutoDetector;
109
    }
110
111
    /**
112
     * Устанавливает сервис позволяющий получить ObjectManager по имени класса
113
     *
114
     * @param ObjectManagerAutoDetectorInterface $objectManagerAutoDetector
115
     *
116
     * @return $this
117
     */
118
    public function setObjectManagerAutoDetector(ObjectManagerAutoDetectorInterface $objectManagerAutoDetector)
119
    {
120
        $this->objectManagerAutoDetector = $objectManagerAutoDetector;
121
122
        return $this;
123
    }
124
125
    /**
126
     * Возвращает менеджер для создания сущностей по интерфейсу
127
     *
128
     * @return EntityManagerInterface
129
     */
130
    public function getEntityManager()
131
    {
132
        return $this->entityManager;
133
    }
134
135
    /**
136
     * Устанавливает менеджер для создания сущностей по интерфейсу
137
     *
138
     * @param EntityManagerInterface $entityManager
139
     *
140
     * @return $this
141
     */
142
    public function setEntityManager(EntityManagerInterface $entityManager)
143
    {
144
        $this->entityManager = $entityManager;
145
146
        return $this;
147
    }
148
}
149