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.

FormBundle/Entity/PageParts/CheckboxPagePart.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\BooleanFormSubmissionField;
8
use Kunstmaan\FormBundle\Form\BooleanFormSubmissionType;
9
use Kunstmaan\FormBundle\Form\CheckboxPagePartAdminType;
10
use Symfony\Component\Form\FormBuilderInterface;
11
use Symfony\Component\Validator\Constraints\NotBlank;
12
13
/**
14
 * The checkbox page part can be used to create forms with checkbox input fields
15
 *
16
 * @ORM\Entity
17
 * @ORM\Table(name="kuma_checkbox_page_parts")
18
 */
19 View Code Duplication
class CheckboxPagePart 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...
20
{
21
    /**
22
     * If set to true, you are obligated to fill in this page part
23
     *
24
     * @ORM\Column(type="boolean", nullable=true)
25
     */
26
    protected $required = false;
27
28
    /**
29
     * Error message shows when the page part is required and nothing is filled in
30
     *
31
     * @ORM\Column(type="string", name="error_message_required", nullable=true)
32
     */
33
    protected $errorMessageRequired;
34
35
    /**
36
     * Sets the required valud of this page part
37
     *
38
     * @param bool $required
39
     *
40
     * @return CheckboxPagePart
41
     */
42 2
    public function setRequired($required)
43
    {
44 2
        $this->required = $required;
45
46 2
        return $this;
47
    }
48
49
    /**
50
     * Check if the page part is required
51
     *
52
     * @return bool
53
     */
54 2
    public function getRequired()
55
    {
56 2
        return $this->required;
57
    }
58
59
    /**
60
     * Sets the message shown when the page part is required and no value was entered
61
     *
62
     * @param string $errorMessageRequired
63
     *
64
     * @return CheckboxPagePart
65
     */
66 3
    public function setErrorMessageRequired($errorMessageRequired)
67
    {
68 3
        $this->errorMessageRequired = $errorMessageRequired;
69
70 3
        return $this;
71
    }
72
73
    /**
74
     * Get the error message that will be shown when the page part is required and no value was entered
75
     *
76
     * @return string
77
     */
78 2
    public function getErrorMessageRequired()
79
    {
80 2
        return $this->errorMessageRequired;
81
    }
82
83
    /**
84
     * Returns the frontend view
85
     *
86
     * @return string
87
     */
88 1
    public function getDefaultView()
89
    {
90 1
        return '@KunstmaanForm/CheckboxPagePart/view.html.twig';
91
    }
92
93
    /**
94
     * Modify the form with the fields of the current page part
95
     *
96
     * @param FormBuilderInterface $formBuilder The form builder
97
     * @param ArrayObject          $fields      The fields
98
     * @param int                  $sequence    The sequence of the form field
99
     */
100 1
    public function adaptForm(FormBuilderInterface $formBuilder, ArrayObject $fields, $sequence)
101
    {
102 1
        $bfsf = new BooleanFormSubmissionField();
103 1
        $bfsf->setFieldName('field_'.$this->getUniqueId());
104 1
        $bfsf->setLabel($this->getLabel());
105 1
        $bfsf->setSequence($sequence);
106
107 1
        $data = $formBuilder->getData();
108 1
        $data['formwidget_'.$this->getUniqueId()] = $bfsf;
109 1
        $constraints = [];
110 1
        if ($this->getRequired()) {
111 1
            $options = [];
112 1
            if (!empty($this->errorMessageRequired)) {
113 1
                $options['message'] = $this->errorMessageRequired;
114
            }
115 1
            $constraints[] = new NotBlank($options);
116
        }
117 1
        $formBuilder->add(
118 1
            'formwidget_'.$this->getUniqueId(),
119 1
            BooleanFormSubmissionType::class,
120
            [
121 1
                'label' => $this->getLabel(),
122 1
                'value_constraints' => $constraints,
123 1
                'required' => $this->getRequired(),
124
            ]
125
        );
126 1
        $formBuilder->setData($data);
127
128 1
        $fields->append($bfsf);
129 1
    }
130
131
    /**
132
     * Returns the default backend form type for this page part
133
     *
134
     * @return string
135
     */
136 1
    public function getDefaultAdminType()
137
    {
138 1
        return CheckboxPagePartAdminType::class;
139
    }
140
}
141