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.

Kunstmaan/NodeBundle/Entity/NodeTranslation.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\EntityManager;
7
use Doctrine\ORM\Mapping as ORM;
8
use Kunstmaan\AdminBundle\Entity\AbstractEntity;
9
use Kunstmaan\NodeBundle\Form\NodeTranslationAdminType;
10
use Symfony\Component\Validator\Constraints as Assert;
11
12
/**
13
 * NodeTranslation
14
 *
15
 * @ORM\Entity(repositoryClass="Kunstmaan\NodeBundle\Repository\NodeTranslationRepository")
16
 * @ORM\Table(
17
 *     name="kuma_node_translations",
18
 *     uniqueConstraints={@ORM\UniqueConstraint(name="ix_kuma_node_translations_node_lang", columns={"node_id", "lang"})},
19
 *     indexes={@ORM\Index(name="idx__node_translation_lang_url", columns={"lang", "url"})}
20
 * )
21
 * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")
22
 */
23
class NodeTranslation extends AbstractEntity
24
{
25
    /**
26
     * @var Node
27
     *
28
     * @ORM\ManyToOne(targetEntity="Node", inversedBy="nodeTranslations")
29
     * @ORM\JoinColumn(name="node_id", referencedColumnName="id")
30
     */
31
    protected $node;
32
33
    /**
34
     * @var string
35
     *
36
     * @ORM\Column(type="string")
37
     */
38
    protected $lang;
39
40
    /**
41
     * @var bool
42
     *
43
     * @ORM\Column(type="boolean")
44
     */
45
    protected $online = false;
46
47
    /**
48
     * @var string
49
     *
50
     * @ORM\Column(type="string")
51
     */
52
    protected $title;
53
54
    /**
55
     * @var string
56
     *
57
     * @ORM\Column(type="string", nullable=true)
58
     * @Assert\Regex("/^[a-zA-Z0-9\-_\/]+$/")
59
     */
60
    protected $slug;
61
62
    /**
63
     * @var string
64
     *
65
     * @ORM\Column(type="string", nullable=true)
66
     */
67
    protected $url;
68
69
    /**
70
     * @var NodeVersion
71
     *
72
     * @ORM\ManyToOne(targetEntity="NodeVersion")
73
     * @ORM\JoinColumn(name="public_node_version_id", referencedColumnName="id")
74
     */
75
    protected $publicNodeVersion;
76
77
    /**
78
     * @var ArrayCollection
79
     * @Assert\Valid()
80
     * @ORM\OneToMany(targetEntity="NodeVersion", mappedBy="nodeTranslation")
81
     * @ORM\OrderBy({"created" = "ASC"})
82
     */
83
    protected $nodeVersions;
84
85
    /**
86
     * @var int
87
     *
88
     * @ORM\Column(type="smallint", nullable=true)
89
     */
90
    protected $weight;
91
92
    /**
93
     * @var \DateTime
94
     *
95
     * @ORM\Column(type="datetime", nullable=true)
96
     */
97
    protected $created;
98
99
    /**
100
     * @var \DateTime
101
     *
102
     * @ORM\Column(type="datetime", nullable=true)
103
     */
104
    protected $updated;
105
106
    /**
107
     * contructor
108
     */
109 59
    public function __construct()
110
    {
111 59
        $this->nodeVersions = new ArrayCollection();
112 59
        $this->setCreated(new \DateTime());
113 59
        $this->setUpdated(new \DateTime());
114 59
    }
115
116
    /**
117
     * Set node
118
     *
119
     * @param Node $node
120
     *
121
     * @return NodeTranslation
122
     */
123 30
    public function setNode($node)
124
    {
125 30
        $this->node = $node;
126
127 30
        return $this;
128
    }
129
130
    /**
131
     * Get Node
132
     *
133
     * @return Node
134
     */
135 14
    public function getNode()
136
    {
137 14
        return $this->node;
138
    }
139
140
    /**
141
     * Set lang
142
     *
143
     * @param string $lang
144
     *
145
     * @return NodeTranslation
146
     */
147 17
    public function setLang($lang)
148
    {
149 17
        $this->lang = $lang;
150
151 17
        return $this;
152
    }
153
154
    /**
155
     * Get lang
156
     *
157
     * @return string
158
     */
159 13
    public function getLang()
160
    {
161 13
        return $this->lang;
162
    }
163
164
    /**
165
     * Is online
166
     *
167
     * @return bool
168
     */
169 8
    public function isOnline()
170
    {
171 8
        return $this->online;
172
    }
173
174
    /**
175
     * Set online
176
     *
177
     * @param bool $online
178
     *
179
     * @return NodeTranslation
180
     */
181 13
    public function setOnline($online)
182
    {
183 13
        $this->online = $online;
184
185 13
        return $this;
186
    }
187
188
    /**
189
     * Set title
190
     *
191
     * @param string $title
192
     *
193
     * @return NodeTranslation
194
     */
195 10
    public function setTitle($title)
196
    {
197 10
        $this->title = $title;
198
199 10
        return $this;
200
    }
201
202
    /**
203
     * Get title
204
     *
205
     * @return string
206
     */
207 3
    public function getTitle()
208
    {
209 3
        return $this->title;
210
    }
211
212
    /**
213
     * Set slug
214
     *
215
     * @param string $slug
216
     *
217
     * @return NodeTranslation
218
     */
219 3
    public function setSlug($slug)
220
    {
221 3
        $this->slug = $slug;
222
223 3
        return $this;
224
    }
225
226
    /**
227
     * Get slug
228
     *
229
     * @return string
230
     */
231 2
    public function getFullSlug()
232
    {
233 2
        $slug = $this->getSlugPart();
234
235 2
        if (empty($slug)) {
236 1
            return null;
237
        }
238
239 1
        return $slug;
240
    }
241
242
    /**
243
     * @return string
244
     */
245 2
    public function getSlugPart()
246
    {
247 2
        $slug = '';
248 2
        $parentNode = $this->getNode()->getParent();
249 2
        if ($parentNode !== null) {
250 1
            $nodeTranslation = $parentNode->getNodeTranslation($this->lang, true);
251
252 1
            if ($nodeTranslation !== null) {
253 1
                $parentSlug = $nodeTranslation->getSlugPart();
254 1
                if (!empty($parentSlug)) {
255 1
                    $slug = rtrim($parentSlug, '/') . '/';
256
                }
257
            }
258
        }
259 2
        $slug .= $this->getSlug();
260
261 2
        return $slug;
262
    }
263
264
    /**
265
     * Get slug
266
     *
267
     * @return string
268
     */
269 3
    public function getSlug()
270
    {
271 3
        return $this->slug;
272
    }
273
274
    /**
275
     * @param NodeVersion $publicNodeVersion
276
     *
277
     * @return NodeTranslation
278
     */
279 6
    public function setPublicNodeVersion(NodeVersion $publicNodeVersion)
280
    {
281 6
        $this->publicNodeVersion = $publicNodeVersion;
282
283 6
        return $this;
284
    }
285
286
    /**
287
     * @return NodeVersion
288
     */
289 11
    public function getPublicNodeVersion()
290
    {
291 11
        return $this->publicNodeVersion;
292
    }
293
294
    /**
295
     * @return NodeVersion
0 ignored issues
show
Should the return type not be NodeVersion|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
296
     */
297 1
    public function getDraftNodeVersion()
298
    {
299 1
        return $this->getNodeVersion('draft');
300
    }
301
302
    /**
303
     * @return ArrayCollection
304
     */
305 4
    public function getNodeVersions()
306
    {
307 4
        return $this->nodeVersions;
308
    }
309
310
    /**
311
     * @param ArrayCollection $nodeVersions
312
     *
313
     * @return NodeTranslation
314
     */
315 2
    public function setNodeVersions(ArrayCollection $nodeVersions)
316
    {
317 2
        $this->nodeVersions = $nodeVersions;
318
319 2
        return $this;
320
    }
321
322
    /**
323
     * @param string $type
324
     *
325
     * @return NodeVersion|null
326
     */
327 4
    public function getNodeVersion($type)
328
    {
329 4
        if ($type == 'public') {
330 2
            return $this->publicNodeVersion;
331
        }
332
333 3
        $nodeVersions = $this->getNodeVersions();
334
335 3
        $max = \count($nodeVersions);
336 3
        for ($i = $max - 1; $i >= 0; --$i) {
337
            /* @var NodeVersion $nodeVersion */
338 2
            $nodeVersion = $nodeVersions[$i];
339
340 2
            if ($type == $nodeVersion->getType()) {
341 2
                return $nodeVersion;
342
            }
343
        }
344
345 1
        return null;
346
    }
347
348
    /**
349
     * Add nodeVersion
350
     *
351
     * @param NodeVersion $nodeVersion
352
     *
353
     * @return NodeTranslation
354
     */
355 11
    public function addNodeVersion(NodeVersion $nodeVersion)
356
    {
357 11
        $this->nodeVersions[] = $nodeVersion;
358 11
        $nodeVersion->setNodeTranslation($this);
359
360 11
        if ($nodeVersion->getType() == 'public') {
361 10
            $this->publicNodeVersion = $nodeVersion;
362
        }
363
364 11
        return $this;
365
    }
366
367
    /**
368
     * @return string
369
     */
370 1
    public function getDefaultAdminType()
371
    {
372 1
        return NodeTranslationAdminType::class;
373
    }
374
375
    /**
376
     * @param EntityManager $em   The entity manager
377
     * @param string        $type The type
378
     *
379
     * @return object|null
380
     */
381 1
    public function getRef(EntityManager $em, $type = 'public')
382
    {
383 1
        $nodeVersion = $this->getNodeVersion($type);
384 1
        if ($nodeVersion) {
385 1
            return $em->getRepository($nodeVersion->getRefEntityName())->find($nodeVersion->getRefId());
386
        }
387
388 1
        return null;
389
    }
390
391
    /**
392
     * @param string $url
393
     *
394
     * @return NodeTranslation
395
     */
396 2
    public function setUrl($url)
397
    {
398 2
        $this->url = $url;
399
400 2
        return $this;
401
    }
402
403
    /**
404
     * @return string
405
     */
406 7
    public function getUrl()
407
    {
408 7
        return $this->url;
409
    }
410
411
    /**
412
     * @param int $weight
413
     *
414
     * @return NodeTranslation
415
     */
416 2
    public function setWeight($weight)
417
    {
418 2
        $this->weight = $weight;
419
420 2
        return $this;
421
    }
422
423
    /**
424
     * @return int
425
     */
426 2
    public function getWeight()
427
    {
428 2
        return $this->weight;
429
    }
430
431
    /**
432
     * @return \DateTime
433
     */
434 1
    public function getCreated()
435
    {
436 1
        return $this->created;
437
    }
438
439
    /**
440
     * @param \DateTime $created
441
     *
442
     * @return NodeTranslation
443
     */
444 59
    public function setCreated($created)
445
    {
446 59
        $this->created = $created;
447
448 59
        return $this;
449
    }
450
451
    /**
452
     * @return \DateTime
453
     */
454 1
    public function getUpdated()
455
    {
456 1
        return $this->updated;
457
    }
458
459
    /**
460
     * @param \DateTime $updated
461
     *
462
     * @return NodeTranslation
463
     */
464 59
    public function setUpdated($updated)
465
    {
466 59
        $this->updated = $updated;
467
468 59
        return $this;
469
    }
470
}
471