Issues (162)

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/GeneratorController.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
namespace Tpg\ExtjsBundle\Controller;
3
4
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
5
use Symfony\Bundle\FrameworkBundle\Tests\Functional\AppKernel;
6
use Symfony\Component\Finder\Finder;
7
use Symfony\Component\Finder\SplFileInfo;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\HttpFoundation\StreamedResponse;
10
use Symfony\Component\HttpFoundation\Response;
11
use Symfony\Component\HttpKernel\Bundle\Bundle;
12
use Tpg\ExtjsBundle\Service\GeneratorService;
13
14
class GeneratorController extends Controller {
15
    public function generateModelAction() {
16
        $models = $this->getRequest()->get("model");
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Bundle\Framework...ontroller::getRequest() has been deprecated with message: since version 2.4, to be removed in 3.0. Ask Symfony to inject the Request object into your controller method instead by type hinting it in the method's signature.

This method 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 method will be removed from the class and what other method or class to use instead.

Loading history...
17
        /** @var $generator GeneratorService */
18
        $generator = $this->get("tpg_extjs.generator");
19
        /** @var $kernel AppKernel */
20
        $kernel = $this->get('kernel');
21
        if ($models === null) {
22
            $list = $this->container->getParameter("tpg_extjs.entities");
23
            return new StreamedResponse(function () use($list, $generator, $kernel) {
24
                foreach ($list as $configEntityLine) {
25
                    list($bundleName, $path) = explode("/", substr($configEntityLine, 1), 2);
26
                    /** @var Bundle $bundle */
27
                    $bundle = $kernel->getBundle($bundleName, true);
28
29
                    /** Entity end with backslash, it is a directory */
30
                    $loadAllEntitiesFromDir = ($configEntityLine[strlen($configEntityLine)-1] == "/");
31
32
                    if ( $loadAllEntitiesFromDir ) {
33
                        $bundleRef = new \ReflectionClass($bundle);
34
                        $dir = new Finder();
35
                        $dir->files()->depth('== 0')->in(dirname($bundleRef->getFileName()).'/'.$path)->name('/.*\.php$/');
36
                        foreach($dir as $file) {
37
                            /** @var SplFileInfo $file*/
38
                            $entityClassname = $bundleRef->getNamespaceName() . "\\" . str_replace("/", "\\", $path) . substr($file->getFilename(), 0, -4);
39
                            echo $generator->generateMarkupForEntity($entityClassname);
40
                        }
41
                    } else  {
42
                        $entityClassname = $bundle->getNamespace() . "\\" . str_replace("/", "\\", $path);
43
                        echo $generator->generateMarkupForEntity($entityClassname);
44
                    }
45
                }
46
                flush();
47
            }, 200, array(
48
                'Content-Type'=>'application/javascript'
49
            ));
50
        } else {
51
            if (!is_array($models)) {
52
                $models = array($models);
53
            }
54
            return new StreamedResponse(function () use($models, $generator) {
55
                foreach ($models as $model) {
56
                    $model = str_replace(".", "\\", $model);
57
                    echo $generator->generateMarkupForEntity($model);
58
                }
59
                flush();
60
            }, 200, array(
61
                'Content-Type'=>'application/javascript'
62
            ));
63
        }
64
    }
65
66
    public function generateRemoteApiAction() {
67
        /** @var $generator GeneratorService */
68
        $generator = $this->get("tpg_extjs.generator");
69
        $apis = $generator->generateRemotingApi();
70
        $response = new Response();
71
        $response->headers->set('Content-Type', 'application/javascript');
72
        return $this->render(
73
            "TpgExtjsBundle:ExtjsMarkup:remoteapi.js.twig",
74
            array(
75
                "apis"=>$apis,
76
                "route"=>'extjs_remoting',
77
            ),
78
            $response
79
        );
80
    }
81
82
    public function remotingAction($bundle) {
83
        $bundleName = str_replace('.', "", $bundle);
84
        $request = json_decode($this->getRequest()->getContent(), true);
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Bundle\Framework...ontroller::getRequest() has been deprecated with message: since version 2.4, to be removed in 3.0. Ask Symfony to inject the Request object into your controller method instead by type hinting it in the method's signature.

This method 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 method will be removed from the class and what other method or class to use instead.

Loading history...
85
        if (!isset($request['data'])) {
86
            $data = array();
87
        } else {
88
            $data = $request['data'];
89
        }
90
        $controller = str_replace('.', "\\", $bundle)."\\Controller\\".$request['action'].'Controller';
91
        $ref = (new \ReflectionClass($controller));
92
        $actionMethod = $ref->getMethod($request['method'].'Action');
93
        $actionparams = $actionMethod->getParameters();
94
        if (count($actionparams) == 1
95
            && is_object($actionparams[0]->getClass())
96
            && (
97
                $actionparams[0]->getClass()->name == 'FOS\RestBundle\Request\ParamFetcherInterface'
98
                || $actionparams[0]->getClass()->name == 'Symfony\Component\HttpFoundation\Request'
99
            )) {
100
            // if the action expects only a ParamFetcher or Request param just give it the first member of $data
101
            $requestData = $data[0];
102
        } else {
103
            $requestData = array();
104
            $i = 0;
105
            foreach($actionparams as $parameter) {
106
                $requestData[$parameter->getName()] = $data[$i++];
107
            }
108
        }
109
110
        /* TODO:
111
            figure out which request params need to be "path params" and which are "query params".
112
            We would need to check the route for the action to figure this out.
113
            Meanwhile we just give the complete request param array as both pathParams and queryParams
114
            so the action can fetch the params from where it expects them to be.
115
        */
116
        $pathParams = $requestData;
117
        $queryParams = $requestData;
118
119
        /** @var JsonResponse $response */
120
        $response = $this->forward($bundleName.':'.$request['action'].':'.$request['method'], $pathParams, $queryParams);
121
        return new JsonResponse(array(
122
            'type'=>$request['type'],
123
            'tid'=>$request['tid'],
124
            'action'=>$request['action'],
125
            'method'=>$request['method'],
126
            'result'=>json_decode($response->getContent())
127
        ));
128
    }
129
}