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/I18nBundle/Resolver/LocaleResolver.php (3 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
namespace Victoire\Bundle\I18nBundle\Resolver;
4
5
use Symfony\Component\HttpFoundation\Request;
6
7
/**
8
 * A class to guess the locale form URL
9
 * ref: victoire_i18n.locale_resolver.
10
 */
11
class LocaleResolver
12
{
13
    const PATTERN_PARAMETER = 'parameter'; // pass the locale the normal way, ie. http://acme.dn/fr
14
    const PATTERN_DOMAIN = 'domain';
15
16
    public $localePattern;
17
    protected $localeDomainConfig;
18
    protected $availableLocales;
19
    public $defaultLocale;
20
    public $defaultDomain;
21
22
    /**
23
     * Constructor.
24
     *
25
     * @param string $localePattern      What is the strategy to resolve locale
26
     * @param array  $localeDomainConfig The locale domain config
27
     * @param string $defaultLocale      The default local app
28
     * @param string $availableLocales   The list of available locales
29
     */
30
    public function __construct($localePattern, array $localeDomainConfig, $defaultLocale, $availableLocales)
31
    {
32
        $this->localePattern = $localePattern;
33
        $this->localeDomainConfig = $localeDomainConfig;
34
        $this->defaultLocale = $defaultLocale;
35
        $this->availableLocales = $availableLocales;
36
37
        foreach ($this->localeDomainConfig as $_domain => $_locale) {
38
            if ($_locale == $this->defaultLocale) {
39
                $this->defaultDomain = $_domain;
40
                break;
41
            }
42
        }
43
    }
44
45
    /**
0 ignored issues
show
Doc comment for parameter "$request" missing
Loading history...
46
     * set the local depending on patterns
47
     * it also set the victoire_locale wich is the locale of the application admin.
48
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
49
    public function resolve(Request $request)
50
    {
51
        //locale
52
        switch ($this->localePattern) {
53
            case self::PATTERN_DOMAIN:
54
                $locale = $this->resolveFromDomain($request);
55
                $request->setLocale($locale);
56
                break;
57
        }
58
59
        return $request->getLocale();
60
    }
61
62
    /**
63
     * @param Request $request
64
     *
65
     * @throws \Exception
66
     *
67
     * @return string
68
     *
69
     * resolves the locale from httpHost or host
70
     */
71
    public function resolveFromDomain(Request $request)
72
    {
73
        $host = $request->getHost();
74
        $httpHost = $request->getHttpHost();
75
76
        if (array_key_exists($host, $this->localeDomainConfig)) {
77
            return $this->localeDomainConfig[$host];
78
        } elseif (array_key_exists($httpHost, $this->localeDomainConfig)) {
79
            return $this->localeDomainConfig[$httpHost];
80
        }
81
82
        error_log(sprintf(
83
            'Host "%s" is not defined in your locale_pattern_table in app/config/victoire_core.yml (%s available), using default locale (%s) instead',
84
            $httpHost,
85
            implode(',', $this->localeDomainConfig),
86
            $this->defaultLocale
87
        ));
88
89
        return $request->getLocale();
90
    }
91
92
    /**
0 ignored issues
show
Doc comment for parameter "$locale" missing
Loading history...
93
     * @return string
94
     *
95
     * This method resolves the domain from locale
96
     */
97
    public function resolveDomainForLocale($locale)
98
    {
99
        foreach ($this->localeDomainConfig as $domain => $domainLocale) {
100
            if ($locale === $domainLocale) {
101
                return $domain;
102
            }
103
        }
104
105
        return $this->defaultLocale;
106
    }
107
108
    /**
109
     * Return available locales.
110
     *
111
     * @return array
112
     */
113
    public function getAvailableLocales()
114
    {
115
        return $this->availableLocales;
116
    }
117
118
    /**
119
     * return domain config.
120
     *
121
     * @return array
122
     */
123
    public function getDomainConfig()
124
    {
125
        return $this->localeDomainConfig;
126
    }
127
}
128