Issues (58)

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/DoctrineObjectEngine/Metadata.php (4 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
 * @link    https://github.com/nnx-framework/doctrine-fixture-module
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace Nnx\JmsSerializerModule\DoctrineObjectEngine;
7
8
use Nnx\JmsSerializerModule\DataContainer;
9
10
/**
11
 * Class Metadata
12
 *
13
 * @package Nnx\JmsSerializerModule\DoctrineObjectEngine
14
 */
15
class Metadata implements MetadataInterface
16
{
17
    /**
18
     * Ассоциция ведет только на одну сущность
19
     *
20
     * @var string
21
     */
22
    const SINGLE_VALUE_ASSOCIATION = 'singleValuedAssociation';
23
24
    /**
25
     * Ассоциция ведет только на одну сущность
26
     *
27
     * @var string
28
     */
29
    const COLLECTION_VALUE_ASSOCIATION = 'collectionValuedAssociation';
30
31
    /**
32
     * Ключем является id контейнера с данными для фикстуры, а значением является имя класса сущности
33
     *
34
     * @var array
35
     */
36
    protected $dataContainerIdToEntityClassName = [];
37
38
    /**
39
     * id контейнера с данными, для которого стоит искать уже созданную сущность в базе данных
40
     *
41
     * @var array
42
     */
43
    protected $candidatesForSearchInDb = [];
44
45
    /**
46
     * Ключем является id контейнера с данными, а значением массив со следующей структурой:
47
     * имя ассоциации => массив с id контейнеров, на которые ведет ассоциация
48
     *
49
     * @var array
50
     */
51
    protected $associationMap = [];
52
53
    /**
54
     * Добавляет элемент в карту ассоциаций
55
     *
56
     * @param DataContainer\EntityInterface $fromDataItem
57
     * @param DataContainer\EntityInterface $toDataItem
58
     * @param        $association
59
     *
60
     * @return $this
61
     */
62 View Code Duplication
    public function addAssociationInfo(DataContainer\EntityInterface $fromDataItem, DataContainer\EntityInterface $toDataItem, DataContainer\Association $association)
0 ignored issues
show
This method seems to be duplicated in 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...
63
    {
64
        $fromDataItemId = $fromDataItem->getId();
65
        if (!array_key_exists($fromDataItemId, $this->associationMap)) {
66
            $this->associationMap[$fromDataItemId] = [];
67
        }
68
        $associationName = $association->getName();
69
        if (!array_key_exists($associationName, $this->associationMap[$fromDataItemId])) {
70
            $this->associationMap[$fromDataItemId][$associationName] = [];
71
        }
72
        $toDataItemId = $toDataItem->getId();
73
        $this->associationMap[$fromDataItemId][$associationName][$toDataItemId] = $toDataItemId;
74
75
        return $this;
76
    }
77
78
    /**
79
     * Добавляет обратную связь
80
     *
81
     * @param DataContainer\EntityInterface $fromDataItem
82
     * @param DataContainer\EntityInterface $toDataItem
83
     * @param        $associationName
84
     *
85
     * @return $this
86
     */
87 View Code Duplication
    public function addReverseAssociationInfo(DataContainer\EntityInterface $fromDataItem, DataContainer\EntityInterface $toDataItem, $associationName)
0 ignored issues
show
This method seems to be duplicated in 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...
88
    {
89
        $fromDataItemId = $fromDataItem->getId();
90
        if (!array_key_exists($fromDataItemId, $this->associationMap)) {
91
            $this->associationMap[$fromDataItemId] = [];
92
        }
93
        if (!array_key_exists($associationName, $this->associationMap[$fromDataItemId])) {
94
            $this->associationMap[$fromDataItemId][$associationName] = [];
95
        }
96
        $toDataItemId = $toDataItem->getId();
97
        $this->associationMap[$fromDataItemId][$associationName][$toDataItemId] = $toDataItemId;
98
99
        return $this;
100
    }
101
102
    /**
103
     * Связывает id контейнера с данными, с именем класса сущности
104
     *
105
     * @param DataContainer\EntityInterface $dataItem
106
     * @param string $entityClassName
107
     *
108
     * @return $this
109
     */
110
    public function linkDataContainerToEntityClassName(DataContainer\EntityInterface $dataItem, $entityClassName)
111
    {
112
        $this->dataContainerIdToEntityClassName[$dataItem->getId()] = $entityClassName;
113
114
        return $this;
115
    }
116
117
118
119
    /**
120
     * Возвращает имя класса сущности, который привязан к контейнеру
121
     *
122
     * @param DataContainer\EntityInterface $dataItem
123
     *
124
     * @return string
125
     * @throws \Nnx\JmsSerializerModule\DoctrineObjectEngine\Exception\RuntimeException
126
     */
127 View Code Duplication
    public function getEntityClassNameByDataContainer(DataContainer\EntityInterface $dataItem)
0 ignored issues
show
This method seems to be duplicated in 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...
128
    {
129
        $dataItemId = $dataItem->getId();
130
        if (!array_key_exists($dataItemId, $this->dataContainerIdToEntityClassName)) {
131
            $errMsg = sprintf('Entity class name not found for data container:#id %s', $dataItemId);
132
            throw new Exception\RuntimeException($errMsg);
133
        }
134
135
        return $this->dataContainerIdToEntityClassName[$dataItemId];
136
    }
137
138
139
    /**
140
     * Возвращает данные о асоцицих, на основе контейнера
141
     *
142
     * @param DataContainer\EntityInterface $dataItem
143
     *
144
     * @return array
145
     * @throws \Nnx\JmsSerializerModule\DoctrineObjectEngine\Exception\RuntimeException
146
     */
147 View Code Duplication
    public function getAssociationsForEntity(DataContainer\EntityInterface $dataItem)
0 ignored issues
show
This method seems to be duplicated in 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...
148
    {
149
        $dataItemId = $dataItem->getId();
150
        if (!array_key_exists($dataItemId, $this->associationMap)) {
151
            $errMsg = sprintf('Associations for data container id: %s not found', $dataItemId);
152
            throw new Exception\RuntimeException($errMsg);
153
        }
154
155
        return $this->associationMap[$dataItemId];
156
    }
157
158
    /**
159
     * Проверяет есть ли для контейнера с данными связанная ассоциация
160
     *
161
     * @param DataContainer\EntityInterface $dataItem
162
     *
163
     * @return boolean
164
     */
165
    public function hasAssociationsForEntity(DataContainer\EntityInterface $dataItem)
166
    {
167
        return array_key_exists($dataItem->getId(), $this->associationMap);
168
    }
169
}
170