Issues (59)

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.

Controller/ExperimentsController.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
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\SettingsBundle\Controller;
13
14
use DeviceDetector\Parser\Device\DeviceParserAbstract;
15
use DeviceDetector\Parser\OperatingSystem;
16
use ONGR\SettingsBundle\Document\Setting;
17
use ONGR\SettingsBundle\Service\SettingsManager;
18
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
19
use Symfony\Component\HttpFoundation\JsonResponse;
20
use Symfony\Component\HttpFoundation\Request;
21
22
/**
23
 * Class SettingsListController. Is used for managing settings in General env.
24
 */
25
class ExperimentsController extends Controller
26
{
27
    public function listAction(Request $request)
0 ignored issues
show
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
28
    {
29
        return $this->render('ONGRSettingsBundle:Experiments:list.html.twig');
30
    }
31
32
    /**
33
     * Returns a json list of experiments
34
     *
35
     * @return JsonResponse
36
     */
37
    public function getFullExperimentsAction()
38
    {
39
        $experimentsArray = [];
40
        /** @var SettingsManager $manager */
41
        $manager = $this->get('ongr_settings.settings_manager');
42
        $experiments = $manager->getAllExperiments();
43
        $activeExperiments = $manager->getActiveExperiments();
44
45
        /** @var Setting $experiment */
46
        foreach ($experiments as $experiment) {
47
            $experiment = $experiment->getSerializableData();
48
            $experiment['active'] = in_array($experiment['name'], $activeExperiments);
49
            $experimentsArray[] = $experiment;
50
        }
51
52
        return new JsonResponse(
53
            ['count' => count($experiments), 'documents' => $experimentsArray]
54
        );
55
    }
56
57
    /**
58
     * Returns a json list of targets for experiment
59
     *
60
     * @param Request $request
61
     *
62
     * @return JsonResponse
63
     */
64
    public function getTargetsAction(Request $request)
65
    {
66
        $targets = [
67
            'Devices' => [
68
                'types' => DeviceParserAbstract::getAvailableDeviceTypeNames(),
69
                'brands' => DeviceParserAbstract::$deviceBrands,
70
            ],
71
            'Clients' => [
72
                'types' => [
73
                    'Browser',
74
                    'FeedReader',
75
                    'Library',
76
                    'MediaPlayer',
77
                    'MobileApp',
78
                    'PIM',
79
                ],
80
                'clients' => [],
81
            ],
82
            'OS' => [
83
                'types' => OperatingSystem::getAvailableOperatingSystems(),
84
            ]
85
        ];
86
87
        if (!empty($select = json_decode($request->get('selected'), true)) && isset($select['Clients']['types'])) {
88
            $targets['Clients']['clients'] = $this->getClientsByTypes($select['Clients']['types']);
89
        }
90
91
        return new JsonResponse($targets);
92
    }
93
94
    /**
95
     * Returns a json list of targets for experiment
96
     *
97
     * @param Request $request
98
     *
99
     * @return JsonResponse
100
     */
101
    public function getClientsByTypesAction(Request $request)
102
    {
103
        $types = $request->get('types');
104
105
        if (!$types) {
106
            return new JsonResponse();
107
        }
108
109
        $clients = $this->getClientsByTypes($types);
110
111
        return new JsonResponse($clients);
112
    }
113
114
    /**
115
     * @param Request $request
116
     *
117
     * @return JsonResponse
118
     */
119 View Code Duplication
    public function toggleAction(Request $request)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
120
    {
121
        $name = $request->get('name');
122
        try {
123
            $this->get('ongr_settings.settings_manager')->toggleExperiment($name);
124
        } catch (\Exception $e) {
125
            return new JsonResponse(['error' => true]);
126
        }
127
128
        return new JsonResponse(['error' => false]);
129
    }
130
131
    /**
132
     * @param array $types
133
     * @return array
134
     */
135
    private function getClientsByTypes(array $types)
136
    {
137
        $clients = [];
138
139
        try {
140
            foreach ($types as $type) {
141
                $clients = array_merge(
142
                    ("\\DeviceDetector\\Parser\\Client\\$type")::getAvailableClients(),
143
                    $clients
144
                );
145
            }
146
        } catch (\Exception $e) {
147
            return [];
148
        }
149
150
        return $clients;
151
    }
152
}
153