Issues (1704)

Branch: master

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/WidgetBundle/Resolver/WidgetResolver.php (2 issues)

Severity

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 Victoire\Bundle\WidgetBundle\Resolver;
4
5
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
6
use Victoire\Bundle\BusinessEntityBundle\Resolver\BusinessEntityResolver;
7
use Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage;
8
use Victoire\Bundle\CoreBundle\Helper\CurrentViewHelper;
9
use Victoire\Bundle\CriteriaBundle\Chain\DataSourceChain;
10
use Victoire\Bundle\CriteriaBundle\Entity\Criteria;
11
use Victoire\Bundle\WidgetBundle\Model\Widget;
12
use Victoire\Bundle\WidgetMapBundle\Entity\WidgetMap;
13
14
class WidgetResolver
0 ignored issues
show
Missing class doc comment
Loading history...
15
{
16
    const OPERAND_EQUAL = 'equal';
17
    const OPERAND_TRUE = 'true';
18
    const OPERAND_FALSE = 'false';
19
    const OPERAND_IN = 'in';
20
    const IS_GRANTED = 'is_granted';
21
    const IS_NOT_GRANTED = 'is_not_granted';
22
23
    private $dataSourceChain;
24
    private $authorizationChecker;
25
    private $currentViewHelper;
26
    private $businessEntityResolver;
27
28
    /**
29
     * WidgetResolver constructor.
30
     *
31
     * @param DataSourceChain        $dataSourceChain
32
     * @param AuthorizationChecker   $authorizationChecker
33
     * @param CurrentViewHelper      $currentViewHelper
34
     * @param BusinessEntityResolver $businessEntityResolver
35
     */
36
    public function __construct(
37
        DataSourceChain $dataSourceChain,
38
        AuthorizationChecker $authorizationChecker,
39
        CurrentViewHelper $currentViewHelper,
40
        BusinessEntityResolver $businessEntityResolver
41
    ) {
42
        $this->dataSourceChain = $dataSourceChain;
43
        $this->authorizationChecker = $authorizationChecker;
44
        $this->currentViewHelper = $currentViewHelper;
45
        $this->businessEntityResolver = $businessEntityResolver;
46
    }
47
48
    public function resolve(WidgetMap $widgetMap)
0 ignored issues
show
Missing function doc comment
Loading history...
49
    {
50
        //TODO: orderize it
51
        $widgets = $widgetMap->getWidgets();
52
        // if the widgetmap is linked to no widgets, it seems that it is an overwrite of the position so keep the replaced widgets for display
53
54
        if ($widgetMap->getReplaced() && count($widgets) === 0) {
55
            $widgets = $widgetMap->getReplaced()->getWidgets();
56
        }
57
        /* @var \Victoire\Bundle\WidgetBundle\Entity\Widget $widget */
58
        foreach ($widgets as $_widget) {
59
60
            /** @var Criteria $criteria */
61
            foreach ($_widget->getCriterias() as $criteria) {
62
                $value = $this->dataSourceChain->getData($criteria->getName());
63
                if (!$this->assert($value(), $criteria->getOperator(), $criteria->getValue())) {
64
                    continue 2; //try with break
65
                }
66
            }
67
68
            if ($_widget instanceof Widget && $proxy = $_widget->getEntityProxy()) {
69
                $_widget->setEntity($this->businessEntityResolver->getBusinessEntity($proxy));
70
            }
71
72
            return $_widget;
73
        }
74
    }
75
76
    protected function assert($value, $operator, $expected)
77
    {
78
        $businessEntity = null;
79
        if ($this->currentViewHelper->getCurrentView() instanceof BusinessPage) {
80
            $businessEntity = $this->currentViewHelper->getCurrentView()->getEntity();
81
        }
82
        $result = false;
83
        switch ($operator) {
84
            case self::OPERAND_EQUAL:
85
                $result = $value === $expected;
86
                break;
87
            case self::OPERAND_TRUE:
88
                $result = $value == true;
89
                break;
90
            case self::OPERAND_FALSE:
91
                $result = $value == false;
92
                break;
93
            case self::OPERAND_IN:
94
                $result = in_array($value, unserialize($expected));
95
                break;
96
            case self::IS_GRANTED:
97
            case self::IS_NOT_GRANTED:
98
                if (!$this->authorizationChecker->isGranted('ROLE_VICTOIRE')) {
99
                    $granted = $this->authorizationChecker->isGranted($expected, $businessEntity);
100
                    if ($operator === self::IS_GRANTED) {
101
                        $result = $granted;
102
                    } else {
103
                        $result = (false === $granted);
104
                    }
105
                } else {
106
                    $result = true;
107
                }
108
                break;
109
        }
110
111
        return $result;
112
    }
113
}
114