Issues (3099)

Security Analysis    not enabled

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/Kunstmaan/NodeBundle/Entity/Node.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
namespace Kunstmaan\NodeBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
use Gedmo\Tree\Node as GedmoNode;
9
use Kunstmaan\AdminBundle\Entity\AbstractEntity;
10
use Kunstmaan\NodeBundle\Form\NodeAdminType;
11
use Kunstmaan\UtilitiesBundle\Helper\ClassLookup;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
/**
15
 * Node
16
 *
17
 * @ORM\Entity(repositoryClass="Kunstmaan\NodeBundle\Repository\NodeRepository")
18
 * @ORM\Table(
19
 *      name="kuma_nodes",
20
 *      indexes={
21
 *          @ORM\Index(name="idx_node_internal_name", columns={"internal_name"}),
22
 *          @ORM\Index(name="idx_node_ref_entity_name", columns={"ref_entity_name"}),
23
 *          @ORM\Index(name="idx_node_tree", columns={"deleted", "hidden_from_nav", "lft", "rgt"})
24
 *      }
25
 * )
26
 * @ORM\HasLifecycleCallbacks()
27
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
28
 * @Gedmo\Tree(type="nested")
29
 */
30
class Node extends AbstractEntity implements GedmoNode
31
{
32
    /**
33
     * @var Node
34
     *
35
     * @ORM\ManyToOne(targetEntity="Node", inversedBy="children")
36
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
37
     * @Gedmo\TreeParent
38
     */
39
    protected $parent;
40
41
    /**
42
     * @var ArrayCollection
43
     *
44
     * @ORM\OneToMany(targetEntity="Node", mappedBy="parent")
45
     */
46
    protected $children;
47
48
    /**
49
     * @var int
50
     *
51
     * @ORM\Column(name="lft", type="integer", nullable=true)
52
     * @Gedmo\TreeLeft
53
     */
54
    protected $lft;
55
56
    /**
57
     * @var int
58
     *
59
     * @ORM\Column(name="lvl", type="integer", nullable=true)
60
     * @Gedmo\TreeLevel
61
     */
62
    protected $lvl;
63
64
    /**
65
     * @var int
66
     *
67
     * @ORM\Column(name="rgt", type="integer", nullable=true)
68
     * @Gedmo\TreeRight
69
     */
70
    protected $rgt;
71
72
    /**
73
     * @var ArrayCollection
74
     * @Assert\Valid()
75
     * @ORM\OneToMany(targetEntity="NodeTranslation", mappedBy="node")
76
     */
77
    protected $nodeTranslations;
78
79
    /**
80
     * @var bool
81
     *
82
     * @ORM\Column(type="boolean")
83
     */
84
    protected $deleted;
85
86
    /**
87
     * @var bool
88
     *
89
     * @ORM\Column(type="boolean", name="hidden_from_nav")
90
     */
91
    protected $hiddenFromNav;
92
93
    /**
94
     * @var string
95
     *
96
     * @ORM\Column(type="string", nullable=false, name="ref_entity_name")
97
     */
98
    protected $refEntityName;
99
100
    /**
101
     * @var string
102
     *
103
     * @ORM\Column(type="string", nullable=true, name="internal_name")
104
     */
105
    protected $internalName;
106
107
    /**
108
     * constructor
109
     */
110 48
    public function __construct()
111
    {
112 48
        $this->children = new ArrayCollection();
113 48
        $this->nodeTranslations = new ArrayCollection();
114 48
        $this->deleted = false;
115 48
        $this->hiddenFromNav = false;
116 48
    }
117
118
    /**
119
     * @return bool
120
     */
121 1
    public function isHiddenFromNav()
122
    {
123 1
        return $this->hiddenFromNav;
124
    }
125
126
    /**
127
     * @return bool
128
     */
129 1
    public function getHiddenFromNav()
130
    {
131 1
        return $this->hiddenFromNav;
132
    }
133
134
    /**
135
     * @param bool $hiddenFromNav
136
     *
137
     * @return Node
138
     */
139 1
    public function setHiddenFromNav($hiddenFromNav)
140
    {
141 1
        $this->hiddenFromNav = $hiddenFromNav;
142
143 1
        return $this;
144
    }
145
146
    /**
147
     * @return ArrayCollection|Node[]
148
     */
149 11
    public function getChildren()
150
    {
151 11
        return $this->children->filter(
152
            function (Node $entry) {
153 6
                if ($entry->isDeleted()) {
154 1
                    return false;
155
                }
156
157 6
                return true;
158 11
            }
159
        );
160
    }
161
162
    /**
163
     * @param ArrayCollection $children
164
     *
165
     * @return Node
166
     */
167 4
    public function setChildren($children)
168
    {
169 4
        $this->children = $children;
170
171 4
        return $this;
172
    }
173
174
    /**
175
     * Add children
176
     *
177
     * @param Node $child
178
     *
179
     * @return Node
180
     */
181 3
    public function addNode(Node $child)
182
    {
183 3
        $this->children[] = $child;
184 3
        $child->setParent($this);
185
186 3
        return $this;
187
    }
188
189
    /**
190
     * @param bool $includeOffline
191
     *
192
     * @return ArrayCollection|NodeTranslation[]
193
     */
194 15
    public function getNodeTranslations($includeOffline = false)
195
    {
196 15
        return $this->nodeTranslations
197
            ->filter(function (NodeTranslation $entry) use ($includeOffline) {
198 10
                return $includeOffline || $entry->isOnline();
199 15
            }
200
            );
201
    }
202
203
    /**
204
     * @param ArrayCollection $nodeTranslations
205
     *
206
     * @return Node
207
     */
208 1
    public function setNodeTranslations(ArrayCollection $nodeTranslations)
209
    {
210 1
        $this->nodeTranslations = $nodeTranslations;
211
212 1
        return $this;
213
    }
214
215
    /**
216
     * @param string $lang           The locale
217
     * @param bool   $includeOffline Include offline pages or not
218
     *
219
     * @return NodeTranslation|null
220
     */
221 7
    public function getNodeTranslation($lang, $includeOffline = false)
222
    {
223 7
        $nodeTranslations = $this->getNodeTranslations($includeOffline);
224
        /* @var NodeTranslation $nodeTranslation */
225 7
        foreach ($nodeTranslations as $nodeTranslation) {
226 7
            if ($lang == $nodeTranslation->getLang()) {
227 7
                return $nodeTranslation;
228
            }
229
        }
230
231 1
        return null;
232
    }
233
234
    /**
235
     * Add nodeTranslation
236
     *
237
     * @param NodeTranslation $nodeTranslation
238
     *
239
     * @return Node
240
     */
241 13
    public function addNodeTranslation(NodeTranslation $nodeTranslation)
242
    {
243 13
        $this->nodeTranslations[] = $nodeTranslation;
244 13
        $nodeTranslation->setNode($this);
245
246 13
        return $this;
247
    }
248
249
    /**
250
     * Set parent
251
     *
252
     * @param Node $parent
253
     *
254
     * @return Node
255
     */
256 6
    public function setParent($parent)
257
    {
258 6
        $this->parent = $parent;
259
260 6
        return $this;
261
    }
262
263
    /**
264
     * Get parent
265
     *
266
     * @return Node
267
     */
268 11
    public function getParent()
269
    {
270 11
        return $this->parent;
271
    }
272
273
    /**
274
     * @return Node[]
275
     */
276 1 View Code Duplication
    public function getParents()
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...
277
    {
278 1
        $parent = $this->getParent();
279 1
        $parents = array();
280 1
        while ($parent !== null) {
281 1
            $parents[] = $parent;
282 1
            $parent = $parent->getParent();
283
        }
284
285 1
        return array_reverse($parents);
286
    }
287
288
    /**
289
     * @return bool
290
     */
291 8
    public function isDeleted()
292
    {
293 8
        return $this->deleted;
294
    }
295
296
    /**
297
     * @param bool $deleted
298
     *
299
     * @return Node
300
     */
301 10
    public function setDeleted($deleted)
302
    {
303 10
        $this->deleted = $deleted;
304
305 10
        return $this;
306
    }
307
308
    /**
309
     * Set referenced entity
310
     *
311
     * @param HasNodeInterface $entity
312
     *
313
     * @return Node
314
     */
315 3
    public function setRef(HasNodeInterface $entity)
316
    {
317 3
        $this->setRefEntityName(ClassLookup::getClass($entity));
318
319 3
        return $this;
320
    }
321
322
    /**
323
     * Set class name of referenced entity
324
     *
325
     * @param string $refEntityName
326
     *
327
     * @return Node
328
     */
329 3
    protected function setRefEntityName($refEntityName)
330
    {
331 3
        $this->refEntityName = $refEntityName;
332
333 3
        return $this;
334
    }
335
336
    /**
337
     * Get class name of referenced entity
338
     *
339
     * @return string
340
     */
341 9
    public function getRefEntityName()
342
    {
343 9
        return $this->refEntityName;
344
    }
345
346
    /**
347
     * Set internal name
348
     *
349
     * @param string $internalName
350
     *
351
     * @return Node
352
     */
353 1
    public function setInternalName($internalName)
354
    {
355 1
        $this->internalName = $internalName;
356
357 1
        return $this;
358
    }
359
360
    /**
361
     * Get internal name
362
     *
363
     * @return string
364
     */
365 1
    public function getInternalName()
366
    {
367 1
        return $this->internalName;
368
    }
369
370
    /**
371
     * @return string
372
     */
373 1
    public function getDefaultAdminType()
374
    {
375 1
        return NodeAdminType::class;
376
    }
377
378
    /**
379
     * Get tree left
380
     *
381
     * @return int
382
     */
383 1
    public function getLeft()
384
    {
385 1
        return $this->lft;
386
    }
387
388
    /**
389
     * Get tree right
390
     *
391
     * @return int
392
     */
393 1
    public function getRight()
394
    {
395 1
        return $this->rgt;
396
    }
397
398
    /**
399
     * Get tree level
400
     *
401
     * @return int
402
     */
403 1
    public function getLevel()
404
    {
405 1
        return $this->lvl;
406
    }
407
408
    /**
409
     * @return string
410
     */
411 1
    public function __toString()
412
    {
413 1
        return 'node ' . $this->getId() . ', refEntityName: ' . $this->getRefEntityName();
414
    }
415
}
416