Issues (3887)

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/NotificationBundle/Entity/RecipientList.php (2 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 Oro\Bundle\NotificationBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Doctrine\Common\Collections\ArrayCollection;
7
8
use Symfony\Component\Validator\Context\ExecutionContextInterface;
9
10
use Oro\Bundle\UserBundle\Entity\User;
11
use Oro\Bundle\UserBundle\Entity\Group;
12
13
/**
14
 * EmailNotification
15
 *
16
 * @ORM\Table("oro_notification_recip_list")
17
 * @ORM\Entity(repositoryClass="Oro\Bundle\NotificationBundle\Entity\Repository\RecipientListRepository")
18
 */
19
class RecipientList
20
{
21
    /**
22
     * @var integer
23
     *
24
     * @ORM\Column(name="id", type="integer")
25
     * @ORM\Id
26
     * @ORM\GeneratedValue(strategy="AUTO")
27
     */
28
    protected $id;
29
30
    /**
31
     * @var User[]|ArrayCollection
32
     * @ORM\ManyToMany(targetEntity="Oro\Bundle\UserBundle\Entity\User")
33
     * @ORM\JoinTable(name="oro_notification_recip_user",
34
     *      joinColumns={@ORM\JoinColumn(name="recipient_list_id", referencedColumnName="id", onDelete="CASCADE")},
35
     *      inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")}
36
     * )
37
     */
38
    protected $users;
39
40
    /**
41
     * @var Group[]|ArrayCollection
42
     * @ORM\ManyToMany(targetEntity="Oro\Bundle\UserBundle\Entity\Group")
43
     * @ORM\JoinTable(name="oro_notification_recip_group",
44
     *      joinColumns={@ORM\JoinColumn(name="recipient_list_id", referencedColumnName="id", onDelete="CASCADE")},
45
     *      inverseJoinColumns={@ORM\JoinColumn(name="group_id", referencedColumnName="id", onDelete="CASCADE")}
46
     * )
47
     */
48
    protected $groups;
49
50
    /**
51
     * @var string
52
     * @ORM\Column(name="email", type="string", length=255, nullable=true)
53
     */
54
    protected $email;
55
56
    /**
57
     * @var boolean
58
     * @ORM\Column(name="owner", type="boolean", nullable=true)
59
     */
60
    protected $owner;
61
62
    public function __construct()
63
    {
64
        $this->groups = new ArrayCollection();
65
        $this->users = new ArrayCollection();
66
    }
67
68
    /**
69
     * @return int
70
     */
71
    public function getId()
72
    {
73
        return $this->id;
74
    }
75
76
    /**
77
     * Setter for email
78
     *
79
     * @param string $email
80
     */
81
    public function setEmail($email)
82
    {
83
        $this->email = $email;
84
    }
85
86
    /**
87
     * Getter for email
88
     *
89
     * @return string
90
     */
91
    public function getEmail()
92
    {
93
        return $this->email;
94
    }
95
96
    /**
97
     * Gets the groups related to list
98
     *
99
     * @return ArrayCollection
100
     */
101
    public function getGroups()
102
    {
103
        return $this->groups;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->groups; of type Oro\Bundle\UserBundle\En...ections\ArrayCollection adds the type Oro\Bundle\UserBundle\Entity\Group[] to the return on line 103 which is incompatible with the return type documented by Oro\Bundle\NotificationB...ecipientList::getGroups of type Doctrine\Common\Collections\ArrayCollection.
Loading history...
104
    }
105
106
    /**
107
     * Add specified group
108
     *
109
     * @param Group $group
110
     * @return $this
111
     */
112
    public function addGroup(Group $group)
113
    {
114
        if (!$this->getGroups()->contains($group)) {
115
            $this->getGroups()->add($group);
116
        }
117
118
        return $this;
119
    }
120
121
    /**
122
     * Remove specified group
123
     *
124
     * @param Group $group
125
     * @return $this
126
     */
127
    public function removeGroup(Group $group)
128
    {
129
        if ($this->getGroups()->contains($group)) {
130
            $this->getGroups()->removeElement($group);
131
        }
132
133
        return $this;
134
    }
135
136
    /**
137
     * Add specified user
138
     *
139
     * @param User $user
140
     * @return $this
141
     */
142
    public function addUser(User $user)
143
    {
144
        if (!$this->getUsers()->contains($user)) {
145
            $this->getUsers()->add($user);
146
        }
147
148
        return $this;
149
    }
150
151
    /**
152
     * Remove specified user
153
     *
154
     * @param User $user
155
     * @return $this
156
     */
157
    public function removeUser(User $user)
158
    {
159
        if ($this->getUsers()->contains($user)) {
160
            $this->getUsers()->removeElement($user);
161
        }
162
163
        return $this;
164
    }
165
166
    /**
167
     * Getters for users
168
     *
169
     * @return ArrayCollection
170
     */
171
    public function getUsers()
172
    {
173
        return $this->users;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->users; of type Oro\Bundle\UserBundle\En...ections\ArrayCollection adds the type Oro\Bundle\UserBundle\Entity\User[] to the return on line 173 which is incompatible with the return type documented by Oro\Bundle\NotificationB...RecipientList::getUsers of type Doctrine\Common\Collections\ArrayCollection.
Loading history...
174
    }
175
176
    /**
177
     * Setter for owner field
178
     *
179
     * @param boolean $owner
180
     */
181
    public function setOwner($owner)
182
    {
183
        $this->owner = $owner;
184
    }
185
186
    /**
187
     * Getter for owner field
188
     *
189
     * @return boolean
190
     */
191
    public function getOwner()
192
    {
193
        return $this->owner;
194
    }
195
196
    /**
197
     * To string implementation
198
     *
199
     * @return string
200
     */
201
    public function __toString()
202
    {
203
        // get user emails
204
        $results = $this->getUsers()->map(
205
            function (User $user) {
206
                return sprintf(
207
                    '%s %s <%s>',
208
                    $user->getFirstName(),
209
                    $user->getLastName(),
210
                    $user->getEmail()
211
                );
212
            }
213
        )->toArray();
214
215
        $results = array_merge(
216
            $results,
217
            $this->getGroups()->map(
218
                function (Group $group) use (&$results) {
219
                    return sprintf(
220
                        '%s (group)',
221
                        $group->getName()
222
                    );
223
                }
224
            )->toArray()
225
        );
226
227
        if ($this->getEmail()) {
228
            $results[] = sprintf('Custom email: <%s>', $this->getEmail());
229
        }
230
231
        if ($this->getOwner()) {
232
            $results[] = 'Entity owner';
233
        }
234
235
        return implode(', ', $results);
236
    }
237
238
    /**
239
     * Custom validation constraint
240
     * Not valid if no one recipient specified
241
     *
242
     * @param ExecutionContextInterface $context
243
     */
244
    public function isValid(ExecutionContextInterface $context)
245
    {
246
        $notValid =
247
            $this->getGroups()->isEmpty()
248
            && $this->getUsers()->isEmpty()
249
            && $this->getEmail() == null
250
            && $this->getOwner() == null;
251
252
        if ($notValid) {
253
            $propertyPath = $context->getPropertyPath() . '.recipientList';
254
            $context->addViolationAt(
255
                $propertyPath,
256
                'oro.notification.validators.recipient_list.empty.message'
257
            );
258
        }
259
    }
260
}
261