Issues (159)

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.

tests/Unit/Filter/NumberFilterTest.php (8 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
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\DoctrinePHPCRAdminBundle\Tests\Unit\Filter;
15
16
use Sonata\AdminBundle\Form\Type\Filter\NumberType;
17
use Sonata\DoctrinePHPCRAdminBundle\Filter\NumberFilter;
18
19
class NumberFilterTest extends BaseTestCase
20
{
21
    protected function setUp(): void
22
    {
23
        parent::setUp();
24
        $this->filter = new NumberFilter();
25
    }
26
27
    public function testFilterNullData(): void
28
    {
29
        $res = $this->filter->filter($this->proxyQuery, null, 'somefield', null);
30
        $this->assertNull($res);
31
        $this->assertFalse($this->filter->isActive());
32
    }
33
34
    public function testFilterEmptyArrayData(): void
35
    {
36
        $res = $this->filter->filter($this->proxyQuery, null, 'somefield', []);
37
        $this->assertNull($res);
38
        $this->assertFalse($this->filter->isActive());
39
    }
40
41
    public function testFilterEmptyArrayDataSpecifiedType(): void
42
    {
43
        $res = $this->filter->filter($this->proxyQuery, null, 'somefield', ['type' => NumberType::TYPE_EQUAL]);
0 ignored issues
show
Deprecated Code introduced by
The constant Sonata\AdminBundle\Form\...\NumberType::TYPE_EQUAL has been deprecated with message: since sonata-project/admin-bundle 3.57, to be removed with 4.0: Use NumberOperatorType::TYPE_EQUAL instead

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
44
        $this->assertNull($res);
45
        $this->assertFalse($this->filter->isActive());
46
    }
47
48
    public function testFilterEmptyArrayDataWithMeaninglessValue(): void
49
    {
50
        $this->proxyQuery->expects($this->never())
0 ignored issues
show
Documentation Bug introduced by
The method expects does not exist on object<Sonata\DoctrinePH...le\Datagrid\ProxyQuery>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
51
            ->method('getQueryBuilder');
52
53
        $this->filter->filter($this->proxyQuery, null, 'somefield', ['type' => NumberType::TYPE_EQUAL, 'value' => ' ']);
0 ignored issues
show
Deprecated Code introduced by
The constant Sonata\AdminBundle\Form\...\NumberType::TYPE_EQUAL has been deprecated with message: since sonata-project/admin-bundle 3.57, to be removed with 4.0: Use NumberOperatorType::TYPE_EQUAL instead

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
54
        $this->assertFalse($this->filter->isActive());
55
    }
56
57
    public function getFilters()
58
    {
59
        return [
60
            ['gte', NumberType::TYPE_GREATER_EQUAL, 2],
0 ignored issues
show
Deprecated Code introduced by
The constant Sonata\AdminBundle\Form\...ype::TYPE_GREATER_EQUAL has been deprecated with message: since sonata-project/admin-bundle 3.57, to be removed with 4.0: Use NumberOperatorType::TYPE_GREATER_EQUAL instead

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
61
            ['gt', NumberType::TYPE_GREATER_THAN, 3],
0 ignored issues
show
Deprecated Code introduced by
The constant Sonata\AdminBundle\Form\...Type::TYPE_GREATER_THAN has been deprecated with message: since sonata-project/admin-bundle 3.57, to be removed with 4.0: Use NumberOperatorType::TYPE_GREATER_THAN instead

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
62
            ['lte', NumberType::TYPE_LESS_EQUAL, 4],
0 ignored issues
show
Deprecated Code introduced by
The constant Sonata\AdminBundle\Form\...erType::TYPE_LESS_EQUAL has been deprecated with message: since sonata-project/admin-bundle 3.57, to be removed with 4.0: Use NumberOperatorType::TYPE_LESS_EQUAL instead

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
63
            ['lt', NumberType::TYPE_LESS_THAN, 5],
0 ignored issues
show
Deprecated Code introduced by
The constant Sonata\AdminBundle\Form\...berType::TYPE_LESS_THAN has been deprecated with message: since sonata-project/admin-bundle 3.57, to be removed with 4.0: Use NumberOperatorType::TYPE_LESS_THAN instead

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
64
            ['eq', NumberType::TYPE_EQUAL, 6],
0 ignored issues
show
Deprecated Code introduced by
The constant Sonata\AdminBundle\Form\...\NumberType::TYPE_EQUAL has been deprecated with message: since sonata-project/admin-bundle 3.57, to be removed with 4.0: Use NumberOperatorType::TYPE_EQUAL instead

This class constant has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.

Loading history...
65
            ['eq', 'default', 7],
66
        ];
67
    }
68
69
    /**
70
     * @dataProvider getFilters
71
     */
72
    public function testFilterSwitch($operatorMethod, $choiceType, $expectedValue = 'somevalue'): void
73
    {
74
        $this->filter->filter(
75
            $this->proxyQuery,
76
            null,
77
            'somefield',
78
            ['type' => $choiceType, 'value' => $expectedValue]
79
        );
80
81
        $opDynamic = $this->qbTester->getNode('where.constraint.operand_dynamic');
82
        $opStatic = $this->qbTester->getNode('where.constraint.operand_static');
83
84
        $this->assertSame('a', $opDynamic->getAlias());
85
        $this->assertSame('somefield', $opDynamic->getField());
86
        $this->assertSame($expectedValue, $opStatic->getValue());
87
88
        $this->assertTrue($this->filter->isActive());
89
    }
90
}
91