Issues (1704)

Branch: master

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.

Bundle/TemplateBundle/Entity/Template.php (7 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 Victoire\Bundle\TemplateBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use Symfony\Component\Validator\Constraints as Assert;
8
use Symfony\Component\Validator\Context\ExecutionContextInterface;
9
use Victoire\Bundle\CoreBundle\Entity\View;
10
use Victoire\Bundle\PageBundle\Entity\BasePage;
11
12
/**
13
 * Template.
14
 *
15
 * @ORM\Entity(repositoryClass="Victoire\Bundle\TemplateBundle\Repository\TemplateRepository")
16
 */
17
class Template extends View
18
{
19
    const TYPE = 'template';
20
21
    /**
22
     * @var string
23
     *
24
     * @ORM\OneToMany(targetEntity="\Victoire\Bundle\CoreBundle\Entity\View", mappedBy="template")
25
     */
26
    protected $inheritors;
27
28
    /**
29
     * @var string
30
     *
31
     * @ORM\Column(name="layout", type="string", length=255)
32
     */
33
    protected $layout;
34
35
    /**
36
     * Construct.
37
     **/
38
    public function __construct()
39
    {
40
        parent::__construct();
41
        $this->widgets = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type string of property $widgets.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
        $this->inheritors = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type string of property $inheritors.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
43
        $this->pages = new ArrayCollection();
0 ignored issues
show
The property pages does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
    }
45
46
    /**
47
     * to string.
48
     *
49
     * @return string
50
     **/
51
    public function __toString()
52
    {
53
        return 'Modèle > '.$this->getName();
54
    }
55
56
    /**
57
     * add page.
58
     *
59
     * @param BasePage $page
60
     *
61
     * @return Template
62
     **/
63
    public function addPage(BasePage $page)
64
    {
65
        $page->setTemplate($this);
66
        $this->pages[] = $page;
67
68
        return $this;
69
    }
70
71
    /**
72
     * set page.
73
     *
74
     * @param array $pages
75
     *
76
     * @return Template
77
     **/
78
    public function setPages(array $pages)
79
    {
80
        foreach ($pages as $page) {
81
            $this->addPage($page);
82
        }
83
84
        return $this;
85
    }
86
87
    /**
88
     * remove page.
89
     *
90
     * @param BasePage $page
91
     *
92
     * @return Template
93
     **/
94
    public function removePage($page)
95
    {
96
        $this->pages->removeElement($page);
97
98
        return $this;
99
    }
100
101
    /**
102
     * Get pages (all Pages having this object as Template).
103
     *
104
     * @return ArrayCollection
105
     */
106
    public function getPages()
107
    {
108
        return $this->pages;
109
    }
110
111
    /**
112
     * Set layout.
113
     *
114
     * @param string $layout
115
     *
116
     * @return Template
117
     */
118
    public function setLayout($layout)
119
    {
120
        $this->layout = $layout;
121
122
        return $this;
123
    }
124
125
    /**
126
     * Get layout.
127
     *
128
     * @return string
129
     */
130
    public function getLayout()
131
    {
132
        return $this->layout;
133
    }
134
135
    /**
136
     * Set inheritors.
137
     *
138
     * @param string $inheritors
139
     *
140
     * @return Template
141
     */
142
    public function setInheritors($inheritors)
143
    {
144
        $this->inheritors = $inheritors;
145
146
        return $this;
147
    }
148
149
    /**
150
     * Get inheritors (all Views having this object as Template).
151
     *
152
     * @return [View]
0 ignored issues
show
The doc-type [View] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
153
     */
154
    public function getInheritors()
155
    {
156
        return $this->inheritors;
157
    }
158
159
    /**
160
     * Get inheritors (all Templates having this object as Template).
161
     *
162
     * @return [Template]
0 ignored issues
show
The doc-type [Template] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
163
     */
164 View Code Duplication
    public function getTemplateInheritors()
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...
165
    {
166
        $templateInheritors = [];
167
        foreach ($this->inheritors as $inheritor) {
0 ignored issues
show
The expression $this->inheritors of type string is not traversable.
Loading history...
168
            if ($inheritor instanceof self) {
169
                $templateInheritors[] = $inheritor;
170
            }
171
        }
172
173
        return $templateInheritors;
174
    }
175
176
    /**
177
     * @Assert\Callback(groups={"victoire"})
178
     *
179
     * @param ExecutionContextInterface $context
180
     */
181
    public function validate(ExecutionContextInterface $context)
182
    {
183
        $template = $this;
184
        while ($template != null) {
185
            if ($template->getLayout() != null) {
186
                return;
187
            }
188
            $template = $template->getTemplate();
189
        }
190
191
        if ($this->getLayout() == null) {
192
            $context->buildViolation('data.template.templateform.view.type.template.layout.validator_message')->addViolation();
193
        }
194
    }
195
}
196