Issues (154)

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.

src/Guesser/TypeGuesser.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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\DoctrineMongoDBAdminBundle\Guesser;
15
16
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
17
use Doctrine\ODM\MongoDB\Types\Type;
18
use Sonata\AdminBundle\Model\ModelManagerInterface;
19
use Symfony\Component\Form\Guess\Guess;
20
use Symfony\Component\Form\Guess\TypeGuess;
21
22
class TypeGuesser extends AbstractTypeGuesser
23
{
24
    public function guessType($class, $property, ModelManagerInterface $modelManager)
25
    {
26
        if (!$ret = $this->getParentMetadataForProperty($class, $property, $modelManager)) {
27
            return new TypeGuess('text', [], Guess::LOW_CONFIDENCE);
28
        }
29
30
        [$metadata, $propertyName, $parentAssociationMappings] = $ret;
31
32
        if ($metadata->hasAssociation($propertyName)) {
33
            $mapping = $metadata->fieldMappings[$propertyName];
34
35
            switch ($mapping['type']) {
36
                case ClassMetadata::ONE:
37
                    return new TypeGuess('mongo_one', [], Guess::HIGH_CONFIDENCE);
38
39
                case ClassMetadata::MANY:
40
                    return new TypeGuess('mongo_many', [], Guess::HIGH_CONFIDENCE);
41
            }
42
        }
43
44
        switch ($metadata->getTypeOfField($propertyName)) {
0 ignored issues
show
The variable $propertyName does not exist. Did you mean $property?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
45
            case Type::COLLECTION:
46
            case Type::HASH:
47
                return new TypeGuess('array', [], Guess::HIGH_CONFIDENCE);
48
            case 'array':
49
                @trigger_error(
50
                    'The array type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
51
                    E_USER_DEPRECATED
52
                );
53
54
                return new TypeGuess('array', [], Guess::HIGH_CONFIDENCE);
55
            case Type::BOOL:
56
            case Type::BOOLEAN:
57
                return new TypeGuess('boolean', [], Guess::HIGH_CONFIDENCE);
58
            case 'datetime':
59
                @trigger_error(
60
                    'The datetime type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
61
                    E_USER_DEPRECATED
62
                );
63
64
                return new TypeGuess('datetime', [], Guess::HIGH_CONFIDENCE);
65
            case 'vardatetime':
66
                @trigger_error(
67
                    'The vardatetime type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
68
                    E_USER_DEPRECATED
69
                );
70
71
                return new TypeGuess('datetime', [], Guess::HIGH_CONFIDENCE);
72
            case 'datetimetz':
73
                @trigger_error(
74
                    'The datetimetz type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
75
                    E_USER_DEPRECATED
76
                );
77
78
                return new TypeGuess('datetime', [], Guess::HIGH_CONFIDENCE);
79
            case Type::TIMESTAMP:
80
                return new TypeGuess('datetime', [], Guess::HIGH_CONFIDENCE);
81
            case Type::DATE:
82
            // NEXT_MAJOR: Use only the constant when dropping support for doctrine/mongodb-odm 1.3.
83
            // case Type::DATE_IMMUTABLE:
84
            case 'date_immutable':
85
                return new TypeGuess('date', [], Guess::HIGH_CONFIDENCE);
86
            case 'decimal':
87
                @trigger_error(
88
                    'The decimal type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
89
                    E_USER_DEPRECATED
90
                );
91
92
                return new TypeGuess('number', [], Guess::MEDIUM_CONFIDENCE);
93
            case Type::FLOAT:
94
                return new TypeGuess('number', [], Guess::MEDIUM_CONFIDENCE);
95
            case Type::INTEGER:
96
            case Type::INT:
97
                return new TypeGuess('integer', [], Guess::MEDIUM_CONFIDENCE);
98
            case 'bigint':
99
                @trigger_error(
100
                    'The bigint type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
101
                    E_USER_DEPRECATED
102
                );
103
104
                return new TypeGuess('integer', [], Guess::MEDIUM_CONFIDENCE);
105
            case 'smallint':
106
                @trigger_error(
107
                    'The smallint type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
108
                    E_USER_DEPRECATED
109
                );
110
111
                return new TypeGuess('integer', [], Guess::MEDIUM_CONFIDENCE);
112
            case Type::STRING:
113
                return new TypeGuess('text', [], Guess::MEDIUM_CONFIDENCE);
114
            case 'text':
115
                @trigger_error(
116
                    'The text type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
117
                    E_USER_DEPRECATED
118
                );
119
120
                return new TypeGuess('textarea', [], Guess::MEDIUM_CONFIDENCE);
121
            case 'time':
122
                @trigger_error(
123
                    'The time type is deprecated since sonata-project/doctrine-mongodb-admin-bundle 3.x, to be removed in 4.0.'.
124
                    E_USER_DEPRECATED
125
                );
126
127
                return new TypeGuess('time', [], Guess::HIGH_CONFIDENCE);
128
            default:
129
                return new TypeGuess('text', [], Guess::LOW_CONFIDENCE);
130
        }
131
    }
132
}
133