Issues (115)

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.

Compiler/MinkExtensionBaseUrlPass.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
namespace SilverStripe\BehatExtension\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
8
/**
9
 * Behat\SilverStripe container compilation pass.
10
 * Passes Base URL available in MinkExtension config.
11
 * Used for the {@link \SilverStripe\BehatExtension\MinkExtension} subclass.
12
 *
13
 * @author MichaƂ Ochman <[email protected]>
14
 */
15
class MinkExtensionBaseUrlPass implements CompilerPassInterface
16
{
17
    /**
18
     * Passes MinkExtension's base_url parameter
19
     *
20
     * @param ContainerBuilder $container
21
     */
22
    public function process(ContainerBuilder $container)
23
    {
24
        $frameworkPath = $container->getParameter('behat.silverstripe_extension.framework_path');
25
26
        global $_FILE_TO_URL_MAPPING;
27
        if ($container->getParameter('behat.mink.base_url')) {
28
            // If base_url is already defined, also set it in the SilverStripe mapping
29
            $_FILE_TO_URL_MAPPING[dirname($frameworkPath)] = $container->getParameter('behat.mink.base_url');
30
        } elseif ($envPath = $this->findEnvironmentConfigFile($frameworkPath)) {
31
            // Otherwise try to retrieve it from _ss_environment
32
            include_once $envPath;
33
            if (isset($_FILE_TO_URL_MAPPING)
34
                && !($container->hasParameter('behat.mink.base_url') && $container->getParameter('behat.mink.base_url'))
35
            ) {
36
                $baseUrl = $this->findBaseUrlFromMapping(dirname($frameworkPath), $_FILE_TO_URL_MAPPING);
37
                if ($baseUrl) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $baseUrl of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
38
                    $container->setParameter('behat.mink.base_url', $baseUrl);
39
                }
40
            }
41
        }
42
43
        if (!$container->getParameter('behat.mink.base_url')) {
44
            throw new \InvalidArgumentException(
45
                '"base_url" not configured. Please specify it in your behat.yml configuration, ' .
46
                'or in your _ss_environment.php configuration through $_FILE_TO_URL_MAPPING'
47
            );
48
        }
49
50
        // The Behat\MinkExtension\Extension class copies configuration into an internal hash,
51
        // we need to follow this pattern to propagate our changes.
52
        $parameters = $container->getParameter('behat.mink.parameters');
53
        $parameters['base_url'] = $container->getParameter('behat.mink.base_url');
54
        $container->setParameter('behat.mink.parameters', $parameters);
55
    }
56
57
    /**
58
     * Try to auto-detect host for webroot based on _ss_environment.php data (unless explicitly set in behat.yml)
59
     * Copied logic from Core.php, because it needs to be executed prior to {@link SilverStripeAwareInitializer}.
60
     *
61
     * @param String Absolute start path to search upwards from
62
     * @return Boolean Absolute path to environment file
63
     */
64
    protected function findEnvironmentConfigFile($path)
0 ignored issues
show
The parameter $path 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...
65
    {
66
        $envPath = null;
67
        $envFile = '_ss_environment.php'; //define the name of the environment file
68
        $path = '.'; //define the dir to start scanning from (have to add the trailing slash)
69
70
        //check this dir and every parent dir (until we hit the base of the drive)
71
        do {
72
            $path = realpath($path) . '/';
73
            //if the file exists, then we include it, set relevant vars and break out
74
            if (file_exists($path . $envFile)) {
75
                $envPath = $path . $envFile;
76
                break;
77
            }
78
        // here we need to check that the real path of the last dir and the next one are
79
        // not the same, if they are, we have hit the root of the drive
80
        } while (realpath($path) != realpath($path .= '../'));
81
82
        return $envPath;
83
    }
84
85
    /**
86
     * Copied logic from Core.php, because it needs to be executed prior to {@link SilverStripeAwareInitializer}.
87
     *
88
     * @param String Absolute start path to search upwards from
89
     * @param Array Map of paths to host names
90
     * @return String URL
91
     */
92
    protected function findBaseUrlFromMapping($path, $mapping)
93
    {
94
        $fullPath = $path;
95
        $url = null;
96
        while ($path && $path != "/" && !preg_match('/^[A-Z]:\\\\$/', $path)) {
97
            if (isset($mapping[$path])) {
98
                $url = $mapping[$path] . str_replace(DIRECTORY_SEPARATOR, '/', substr($fullPath, strlen($path)));
99
                break;
100
            } else {
101
                $path = dirname($path); // traverse up
102
            }
103
        }
104
105
        return $url;
106
    }
107
}
108