Issues (116)

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.

EventSubscriber/TimestampableSubscriber.php (1 issue)

assigning incompatible types to properties.

Bug Documentation Major

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
 * WellCommerce Open-Source E-Commerce Platform
4
 *
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 *
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CoreBundle\Doctrine\EventSubscriber;
14
15
use Doctrine\Common\EventSubscriber;
16
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
17
use Doctrine\ORM\Events;
18
19
/**
20
 * Class TimestampableSubscriber
21
 *
22
 * @author  Adam Piotrowski <[email protected]>
23
 */
24
class TimestampableSubscriber implements EventSubscriber
25
{
26
    /**
27
     * @var array Timestampable fields
28
     */
29
    protected $fields = ['createdAt', 'updatedAt'];
30
31
    /**
32
     * @var \Doctrine\ORM\Mapping\ClassMetadataInfo
33
     */
34
    protected $classMetadata;
35
36
    /**
37
     * Returns subscribed events
38
     *
39
     * @return array
40
     */
41
    public function getSubscribedEvents()
42
    {
43
        return [Events::loadClassMetadata];
44
    }
45
46
    /**
47
     * Event triggered during metadata loading
48
     *
49
     * @param LoadClassMetadataEventArgs $eventArgs
50
     */
51
    public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
52
    {
53
        $this->classMetadata = $eventArgs->getClassMetadata();
0 ignored issues
show
Documentation Bug introduced by Adam Piotrowski
It seems like $eventArgs->getClassMetadata() of type object<Doctrine\ORM\EntityManager> is incompatible with the declared type object<Doctrine\ORM\Mapping\ClassMetadataInfo> of property $classMetadata.

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...
54
        $reflectionClass     = $this->classMetadata->getReflectionClass();
55
56
        if (null === $reflectionClass) {
57
            return;
58
        }
59
60
        if ($this->hasMethod($reflectionClass, 'updateTimestamps')) {
61
            $this->addLifecycleCallbacks();
62
            $this->mapFields();
63
        }
64
    }
65
66
    /**
67
     * Adds timestampable lifecycle callbacks to entity
68
     */
69
    protected function addLifecycleCallbacks()
70
    {
71
        foreach ($this->getLifecycleCallbacks() as $callback) {
72
            $this->classMetadata->addLifecycleCallback('updateTimestamps', $callback);
73
        }
74
    }
75
76
    protected function getLifecycleCallbacks()
77
    {
78
        return [
79
            Events::prePersist,
80
            Events::preUpdate
81
        ];
82
    }
83
84
    /**
85
     * Iterates through fields and adds mapping to them
86
     */
87
    protected function mapFields()
88
    {
89
        foreach ($this->fields as $field) {
90
            $this->mapField($field);
91
        }
92
    }
93
94
    /**
95
     * Adds mapping to single field
96
     *
97
     * @param string $field
98
     */
99
    protected function mapField($field)
100
    {
101
        if (!$this->classMetadata->hasField($field)) {
102
            $this->classMetadata->mapField([
103
                'fieldName' => $field,
104
                'type'      => 'datetime',
105
                'nullable'  => true,
106
            ]);
107
        }
108
    }
109
110
    /**
111
     * Checks whether the class contains such a method
112
     *
113
     * @param \ReflectionClass $class
114
     * @param string           $methodName
115
     *
116
     * @return bool
117
     */
118
    protected function hasMethod(\ReflectionClass $class, $methodName)
119
    {
120
        return $class->hasMethod($methodName);
121
    }
122
}
123