Issues (98)

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.

src/Data/Manager.php (5 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 Sugarcrm\UpgradeSpec\Data;
4
5
use Sugarcrm\UpgradeSpec\Context\Upgrade;
6
use Sugarcrm\UpgradeSpec\Version\OrderedList;
7
use Sugarcrm\UpgradeSpec\Version\Version;
8
9
class Manager
10
{
11
    /**
12
     * @var ProviderChain
13
     */
14
    private $provider;
15
16
    /**
17
     * Manager constructor.
18
     *
19
     * @param ProviderChain $provider
20
     */
21
    public function __construct(ProviderChain $provider)
22
    {
23
        $this->provider = $provider;
24
    }
25
26
    /**
27
     * Gets all available SugarCRM versions (sorted ASC).
28
     *
29
     * @param string $flav
30
     *
31
     * @return OrderedList
32
     */
33
    public function getVersions($flav)
34
    {
35
        $versions = $this->provider->getVersions($flav);
36
        if (!count($versions)) {
37
            throw new \RuntimeException(sprintf('No "%s" versions available', $flav));
38
        }
39
40
        return $versions;
41
    }
42
43
    /**
44
     * Gets the latest available SugarCRM version with given flav and base version.
45
     *
46
     * Examples: 7.6.1 -> 7.6.1.0, 7.7 -> 7.7.1, 7.8 -> 7.8.0.0
47
     *
48
     * @param string $flav
49
     * @param Version|null $baseVersion
50
     *
51
     * @return Version
52
     */
53
    public function getLatestVersion($flav, Version $baseVersion = null)
54
    {
55
        $versions = $this->getVersions($flav);
56
57
        // the latest available
58
        if (is_null($baseVersion)) {
59
            return $versions->last();
60
        }
61
62
        // is minor bugfix version
63
        if ($baseVersion->isFull()) {
64
            if (!$versions->contains($baseVersion)) {
65
                throw new \InvalidArgumentException(sprintf('Unknown version: %s', $baseVersion));
66
            }
67
68
            return $baseVersion;
69
        }
70
71
        /**
72
         * all versions with $baseVersion base
73
         * for example: 7.6.1 -> [7.6.1, 7.6.1.0, 7.6.1.1], 7.6 -> [7.6.1.0, 7.6.1.1, 7.6.2].
74
         */
75
        $minors = $versions->filter(function (Version $version) use ($baseVersion) {
76
            return $version->isChildOf($baseVersion) || $version->isEqualTo($baseVersion);
77
        });
78
79
        if (!count($minors)) {
80
            throw new \InvalidArgumentException(sprintf('No minor versions available for version: %s', $baseVersion));
81
        }
82
83
        return $minors->last();
84
    }
85
86
    /**
87
     * Gets release notes for all versions from given range.
88
     *
89
     * @param Upgrade $context
90
     *
91
     * @return array
92
     */
93
    public function getReleaseNotes(Upgrade $context)
94
    {
95
        $versions = $this->getVersionRange($context);
96
97
        return $this->provider->getReleaseNotes($context->getBuildFlav(), $versions);
0 ignored issues
show
$versions is of type object<Sugarcrm\UpgradeSpec\Version\OrderedList>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
98
    }
99
100
    /**
101
     * Gets all required information to perform health check.
102
     *
103
     * @param Version $version
104
     *
105
     * @return mixed
106
     */
107
    public function getHealthCheckInfo(Version $version)
108
    {
109
        return $this->provider->getHealthCheckInfo($version);
110
    }
111
112
    /**
113
     * Gets all required information to perform upgrade.
114
     *
115
     * @param Version $version
116
     *
117
     * @return mixed
118
     */
119
    public function getUpgraderInfo(Version $version)
120
    {
121
        return $this->provider->getUpgraderInfo($version);
122
    }
123
124
    /**
125
     * Gets the list of potentially broken customizations (changed and deleted files)
126
     *
127
     * @param Upgrade $context
128
     *
129
     * @return mixed
130
     */
131
    public function getPotentiallyBrokenCustomizations(Upgrade $context)
132
    {
133
        return $this->provider->getPotentiallyBrokenCustomizations($context);
0 ignored issues
show
Documentation Bug introduced by
The method getPotentiallyBrokenCustomizations does not exist on object<Sugarcrm\UpgradeSpec\Data\ProviderChain>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
134
    }
135
136
    /**
137
     * Gets the lists of upgrade steps for the given source
138
     *
139
     * @param Upgrade $context
140
     *
141
     * @return mixed
142
     */
143
    public function getUpgradeSteps(Upgrade $context)
144
    {
145
        return $this->provider->getUpgradeSteps($context);
0 ignored issues
show
Documentation Bug introduced by
The method getUpgradeSteps does not exist on object<Sugarcrm\UpgradeSpec\Data\ProviderChain>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
146
    }
147
148
    /**
149
     * Gets all available versions from given range ($from < version <= $to).
150
     *
151
     * @param Upgrade $context
152
     *
153
     * @return OrderedList
154
     */
155
    private function getVersionRange(Upgrade $context)
156
    {
157
        $from = (string) $context->getBuildVersion()->getFull();
0 ignored issues
show
The method getFull cannot be called on $context->getBuildVersion() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
158
        $to = (string) $context->getTargetVersion()->getFull();
0 ignored issues
show
The method getFull cannot be called on $context->getTargetVersion() (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
159
160
        return $this->getVersions($context->getBuildFlav())->filter(function (Version $version) use ($from, $to) {
161
            return version_compare((string) $version, $from, '>')
162
                && version_compare((string) $version, $to, '<=');
163
        });
164
    }
165
}
166