Issues (865)

Security Analysis    4 potential vulnerabilities

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection (1)
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection (2)
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  Cross-Site Scripting (1)
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.
  Header Injection
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.

src/Composer/Installers/BaseInstaller.php (5 issues)

Labels
Severity
1
<?php
2
namespace Composer\Installers;
3
4
use Composer\IO\IOInterface;
5
use Composer\Composer;
6
use Composer\Package\PackageInterface;
7
8
abstract class BaseInstaller
9
{
10
    protected $locations = array();
11
    protected $composer;
12
    protected $package;
13
    protected $io;
14
15
    /**
16
     * Initializes base installer.
17
     *
18
     * @param PackageInterface $package
0 ignored issues
show
The type Composer\Package\PackageInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
     * @param Composer         $composer
0 ignored issues
show
The type Composer\Composer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
     * @param IOInterface      $io
0 ignored issues
show
The type Composer\IO\IOInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
     */
22
    public function __construct(PackageInterface $package = null, Composer $composer = null, IOInterface $io = null)
23
    {
24
        $this->composer = $composer;
25
        $this->package = $package;
26
        $this->io = $io;
27
    }
28
29
    /**
30
     * Return the install path based on package type.
31
     *
32
     * @param  PackageInterface $package
33
     * @param  string           $frameworkType
34
     * @return string
35
     */
36
    public function getInstallPath(PackageInterface $package, $frameworkType = '')
37
    {
38
        $type = $this->package->getType();
0 ignored issues
show
The method getType() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        /** @scrutinizer ignore-call */ 
39
        $type = $this->package->getType();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
40
        $prettyName = $this->package->getPrettyName();
41
        if (strpos($prettyName, '/') !== false) {
42
            list($vendor, $name) = explode('/', $prettyName);
43
        } else {
44
            $vendor = '';
45
            $name = $prettyName;
46
        }
47
48
        $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type'));
49
50
        $extra = $package->getExtra();
51
        if (!empty($extra['installer-name'])) {
52
            $availableVars['name'] = $extra['installer-name'];
53
        }
54
55
        if ($this->composer->getPackage()) {
0 ignored issues
show
The method getPackage() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
        if ($this->composer->/** @scrutinizer ignore-call */ getPackage()) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
56
            $extra = $this->composer->getPackage()->getExtra();
57
            if (!empty($extra['installer-paths'])) {
58
                $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor);
59
                if ($customPath !== false) {
60
                    return $this->templatePath($customPath, $availableVars);
61
                }
62
            }
63
        }
64
65
        $packageType = substr($type, strlen($frameworkType) + 1);
66
        $locations = $this->getLocations();
67
        if (!isset($locations[$packageType])) {
68
            throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type));
69
        }
70
71
        return $this->templatePath($locations[$packageType], $availableVars);
72
    }
73
74
    /**
75
     * For an installer to override to modify the vars per installer.
76
     *
77
     * @param  array<string, string> $vars This will normally receive array{name: string, vendor: string, type: string}
78
     * @return array<string, string>
79
     */
80
    public function inflectPackageVars($vars)
81
    {
82
        return $vars;
83
    }
84
85
    /**
86
     * Gets the installer's locations
87
     *
88
     * @return array<string, string> map of package types => install path
89
     */
90
    public function getLocations()
91
    {
92
        return $this->locations;
93
    }
94
95
    /**
96
     * Replace vars in a path
97
     *
98
     * @param  string                $path
99
     * @param  array<string, string> $vars
100
     * @return string
101
     */
102
    protected function templatePath($path, array $vars = array())
103
    {
104
        if (strpos($path, '{') !== false) {
105
            extract($vars);
106
            preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches);
107
            if (!empty($matches[1])) {
108
                foreach ($matches[1] as $var) {
109
                    $path = str_replace('{$' . $var . '}', $$var, $path);
110
                }
111
            }
112
        }
113
114
        return $path;
115
    }
116
117
    /**
118
     * Search through a passed paths array for a custom install path.
119
     *
120
     * @param  array  $paths
121
     * @param  string $name
122
     * @param  string $type
123
     * @param  string $vendor = NULL
124
     * @return string|false
125
     */
126
    protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL)
127
    {
128
        foreach ($paths as $path => $names) {
129
            $names = (array) $names;
130
            if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) {
131
                return $path;
132
            }
133
        }
134
135
        return false;
136
    }
137
}
138