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.

Entity/PageParts/MultiLineTextPagePart.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\FormBundle\Entity\PageParts;
4
5
use ArrayObject;
6
use Doctrine\ORM\Mapping as ORM;
7
use Kunstmaan\FormBundle\Entity\FormSubmissionFieldTypes\TextFormSubmissionField;
8
use Kunstmaan\FormBundle\Form\MultiLineTextPagePartAdminType;
9
use Kunstmaan\FormBundle\Form\TextFormSubmissionType;
10
use Symfony\Component\Form\FormBuilderInterface;
11
use Symfony\Component\Validator\Constraints\NotBlank;
12
use Symfony\Component\Validator\Constraints\Regex;
13
14
/**
15
 * The multi-line text page part can be used to create forms with multi-line text fields
16
 *
17
 * @ORM\Entity
18
 * @ORM\Table(name="kuma_multi_line_text_page_parts")
19
 */
20 View Code Duplication
class MultiLineTextPagePart extends AbstractFormPagePart
0 ignored issues
show
This class 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...
21
{
22
    /**
23
     * If set to true, you are obligated to fill in this page part
24
     *
25
     * @ORM\Column(type="boolean", nullable=true)
26
     */
27
    protected $required = false;
28
29
    /**
30
     * Error message shows when the page part is required and nothing is filled in
31
     *
32
     * @ORM\Column(type="string", name="error_message_required", nullable=true)
33
     */
34
    protected $errorMessageRequired;
35
36
    /**
37
     * If set the entered value will be matched with this regular expression
38
     *
39
     * @ORM\Column(type="string", nullable=true)
40
     */
41
    protected $regex;
42
43
    /**
44
     * If a regular expression is set and it doesn't match with the given value, this error message will be shown
45
     *
46
     * @ORM\Column(type="string", name="error_message_regex", nullable=true)
47
     */
48
    protected $errorMessageRegex;
49
50
    /**
51
     * Set the regular expression to match the entered value against
52
     *
53
     * @param string $regex
54
     *
55
     * @return MultiLineTextPagePart
56
     */
57 3
    public function setRegex($regex)
58
    {
59 3
        $this->regex = $regex;
60
61 3
        return $this;
62
    }
63
64
    /**
65
     * Get the current regular expression
66
     *
67
     * @return string
68
     */
69 3
    public function getRegex()
70
    {
71 3
        return $this->regex;
72
    }
73
74
    /**
75
     * Set the error message which will be shown when the entered value doesn't match the regular expression
76
     *
77
     * @param string $errorMessageRegex
78
     *
79
     * @return MultiLineTextPagePart
80
     */
81 3
    public function setErrorMessageRegex($errorMessageRegex)
82
    {
83 3
        $this->errorMessageRegex = $errorMessageRegex;
84
85 3
        return $this;
86
    }
87
88
    /**
89
     * Get the current error message which will be shown when the entered value doesn't match the regular expression
90
     *
91
     * @return string
92
     */
93 2
    public function getErrorMessageRegex()
94
    {
95 2
        return $this->errorMessageRegex;
96
    }
97
98
    /**
99
     * Returns the frontend view
100
     *
101
     * @return string
102
     */
103 1
    public function getDefaultView()
104
    {
105 1
        return '@KunstmaanForm/MultiLineTextPagePart/view.html.twig';
106
    }
107
108
    /**
109
     * Sets the required valud of this page part
110
     *
111
     * @param bool $required
112
     *
113
     * @return MultiLineTextPagePart
114
     */
115 3
    public function setRequired($required)
116
    {
117 3
        $this->required = $required;
118
119 3
        return $this;
120
    }
121
122
    /**
123
     * Check if the page part is required
124
     *
125
     * @return bool
126
     */
127 3
    public function getRequired()
128
    {
129 3
        return $this->required;
130
    }
131
132
    /**
133
     * Sets the message shown when the page part is required and no value was entered
134
     *
135
     * @param string $errorMessageRequired
136
     *
137
     * @return MultiLineTextPagePart
138
     */
139 2
    public function setErrorMessageRequired($errorMessageRequired)
140
    {
141 2
        $this->errorMessageRequired = $errorMessageRequired;
142
143 2
        return $this;
144
    }
145
146
    /**
147
     * Get the error message that will be shown when the page part is required and no value was entered
148
     *
149
     * @return string
150
     */
151 2
    public function getErrorMessageRequired()
152
    {
153 2
        return $this->errorMessageRequired;
154
    }
155
156
    /**
157
     * Modify the form with the fields of the current page part
158
     *
159
     * @param FormBuilderInterface $formBuilder The form builder
160
     * @param ArrayObject          $fields      The fields
161
     * @param int                  $sequence    The sequence of the form field
162
     */
163 1
    public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence)
164
    {
165 1
        $mfsf = new TextFormSubmissionField();
166 1
        $mfsf->setFieldName('field_'.$this->getUniqueId());
167 1
        $mfsf->setLabel($this->getLabel());
168 1
        $mfsf->setSequence($sequence);
169
170 1
        $data = $formBuilder->getData();
171 1
        $data['formwidget_'.$this->getUniqueId()] = $mfsf;
172
173 1
        $constraints = [];
174 1
        if ($this->getRequired()) {
175 1
            $options = [];
176 1
            if (!empty($this->errorMessageRequired)) {
177 1
                $options['message'] = $this->errorMessageRequired;
178
            }
179 1
            $constraints[] = new NotBlank($options);
180
        }
181 1
        if ($this->getRegex()) {
182 1
            $options = ['pattern' => $this->getRegex()];
183 1
            if (!empty($this->errorMessageRegex)) {
184 1
                $options['message'] = $this->errorMessageRegex;
185
            }
186 1
            $constraints[] = new Regex($options);
187
        }
188
189 1
        $formBuilder->add(
190 1
            'formwidget_'.$this->getUniqueId(),
191 1
            TextFormSubmissionType::class,
192
            [
193 1
                'label' => $this->getLabel(),
194 1
                'value_constraints' => $constraints,
195 1
                'required' => $this->getRequired(),
196
            ]
197
        );
198 1
        $formBuilder->setData($data);
199
200 1
        $fields->append($mfsf);
201 1
    }
202
203
    /**
204
     * Returns the default backend form type for this page part
205
     *
206
     * @return string
207
     */
208 1
    public function getDefaultAdminType()
209
    {
210 1
        return MultiLineTextPagePartAdminType::class;
211
    }
212
}
213