Issues (20)

Security Analysis    no request data  

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/BaseController.php (7 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 Stinger Soft Platform package.
5
 *
6
 * (c) Oliver Kotte <[email protected]>
7
 * (c) Florian Meyer <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
namespace StingerSoft\PlatformBundle\Controller;
13
14
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
15
use Symfony\Component\Stopwatch\Stopwatch;
16
use Symfony\Component\Translation\TranslatorInterface;
17
use Doctrine\Common\Persistence\ObjectRepository;
18
19
class BaseController extends Controller {
20
21
	/**
22
	 * Returns the default locale for the system
23
	 *
24
	 * @return string
25
	 */
26
	protected function getDefaultLocale() {
27
		return 'en';
28
	}
29
30
	/**
31
	 * Returns all available (i.e.
32
	 * configured) locales of the system
33
	 *
34
	 * @return string[]
35
	 */
36
	protected function getLocales() {
37
		return array(
38
			'en' 
39
		);
40
	}
41
42
	/**
43
	 * Proxy to use the transChoice method of the translator
44
	 *
45
	 * @see TranslatorInterface::transChoice()
46
	 *
47
	 * @param string $id        	
48
	 * @param int $number        	
49
	 * @param array $parameters        	
50
	 * @param string $domain        	
0 ignored issues
show
Should the type for parameter $domain not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
51
	 * @param string $locale        	
0 ignored issues
show
Should the type for parameter $locale not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
52
	 * @return string
53
	 */
54 View Code Duplication
	protected function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) {
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...
55
		/**
56
		 *
57
		 * @var TranslatorInterface $translator
58
		 */
59
		$translator = $this->getTranslator();
60
		return $translator->transChoice($id, $number, $parameters, $domain, $locale);
61
	}
62
63
	/**
64
	 * Proxy to use the transChoice method of the translator
65
	 *
66
	 * @see TranslatorInterface::trans()
67
	 *
68
	 * @param string $id        	
69
	 * @param array $parameters        	
70
	 * @param string $domain        	
0 ignored issues
show
Should the type for parameter $domain not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
71
	 * @param string $locale        	
0 ignored issues
show
Should the type for parameter $locale not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
72
	 * @return string
73
	 */
74 View Code Duplication
	protected function trans($id, array $parameters = array(), $domain = null, $locale = null) {
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...
75
		/**
76
		 *
77
		 * @var TranslatorInterface $translator
78
		 */
79
		$translator = $this->getTranslator();
80
		return $translator->trans($id, $parameters, $domain, $locale);
81
	}
82
83
	/**
84
	 * Returns the translator service
85
	 *
86
	 * @return TranslatorInterface
87
	 */
88
	protected function getTranslator() {
89
		return $this->get('translator');
90
	}
91
92
	/**
93
	 * Returns the paginator service
94
	 *
95
	 * @return \Knp\Component\Pager\PaginatorInterface
96
	 */
97
	protected function getPaginator() {
98
		return $this->get('knp_paginator');
99
	}
100
101
	/**
102
	 * Returns the stopwatch service if available
103
	 *
104
	 * @return Stopwatch|NULL
0 ignored issues
show
Should the return type not be object|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
105
	 */
106
	protected function getStopWatch() {
107
		if($this->has('debug.stopwatch')) {
108
			return $this->get('debug.stopwatch');
109
		}
110
		return null;
111
	}
112
113
	/**
114
	 * Checks whether the current user has the specified role or not
115
	 *
116
	 * @param string $role        	
117
	 * @throws \LogicException
118
	 * @return boolean
119
	 */
120
	protected function hasRole($role) {
121
		if(!$this->container->has('security.authorization_checker')) {
122
			throw new \LogicException('The SecurityBundle is not registered in your application.');
123
		}
124
		return false !== $this->get('security.authorization_checker')->isGranted($role);
125
	}
126
127
	/**
128
	 * Returns the repository for the given clazz
129
	 * 
130
	 * @param string $class
131
	 * @return ObjectRepository
132
	 */
133
	protected function getRepository($class) {
134
		return $this->getDoctrine()->getManagerForClass($class)->getRepository($class);
135
	}
136
}