Issues (4)

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.

code/tasks/UpgradePath.php (4 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
 * Does what the description says ;)
4
 */
5
class UpgradePath extends BuildTask
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $title = "Upgrade Path checker";
11
12
    /**
13
     * @var string
14
     */
15
    protected $description = 'Checks if which composer dependencies hold your SilverStripe framework upgrade back.';
16
17
    /**
18
     * @param SS_HTTPRequest $request
19
     */
20
    public function run($request)
21
    {
22
        // safe is safe!
23
        if (Permission::check('ADMIN') || $this->isCLI()) {
24
            // get the list of all full releases
25
            $releases = $this->getReleases();
26
            $this->message('Framework versions to consider: ' . join(', ', $releases));
27
            $this->message("--------------------------------------------");
28
29
            // check and print the result
30
            foreach ($releases as $release) {
31
                $this->message($this->getBlockers($release));
32
            }
33
34
            // Done :)
35
            $this->message("\nDone. The information above was not saved anywhere in the DB :)");
36
        } else {
37
            $this->message('Permission issue.');
38
        }
39
    }
40
41
    /**
42
     * for now just return a list of the interesting versions. Later a proper list of all newer versions would be great.
43
     *
44
     * @return array
45
     */
46
    public function getReleases()
47
    {
48
        return array('4.0.0');
49
    }
50
51
    /**
52
     * returns a prepared list of the packages.
53
     *
54
     * parses the following output for convienence reasons:
55
     *
56
     * $ peter@petert-lp /var/www/project (master) $ composer why-not silverstripe/framework:3.3.0
57
     * $ nglasl/silverstripe-misdirection  dev-master  requires  silverstripe/framework (3.1.*)
58
     * $ silverstripe/sqlite3              1.3.x-dev   requires  silverstripe/framework (>=3.0,<3.2)
59
     * $ silverstripe/widgets              1.1.x-dev   requires  silverstripe/framework (3.1.*)
60
     * $ unclecheese/display-logic         1.2.x-dev   requires  silverstripe/framework (3.1.*)
61
     *
62
     * @param string $release
63
     *
64
     * @return array
0 ignored issues
show
Should the return type not be string?

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...
65
     */
66
    public function getBlockers($release)
67
    {
68
        // get the prohibiting packages for a particular framework version
69
        // @TODO refactor to use actual composer package directly instead of via the cli.
70
        exec(
71
            sprintf(
72
                'php %s %s silverstripe/framework:%s --working-dir=.. 2> /dev/null',
73
                '../vendor/composer/composer/bin/composer',
74
                'why-not',
75
                $release
76
            ),
77
            $packages
78
        );
79
80
        // prepare the output
81
        return
82
            "\n".trim(
83
            "Target SilverStripe Framework Version: {$release}\n".
84
            "--------------------------------------------\n\n".
85
            join("", array_unique(array_map(function ($package) use ($release) {
86
                // some string processing to parse the package string
87
                $elements = preg_split('/\s+/', $package);
88
                $limitation = substr($elements[4], 1, -1);
89
90
                // a simple version parser, which should be enough for this purpose:
91
                $limitationAsNumber = preg_replace('/\D/', '', $limitation);
92
                $limitationAsNumber = $limitationAsNumber . str_repeat('0', 10 - strlen($limitationAsNumber));
93
                $releaseAsNumber = preg_replace('/\D/', '', $release);
94
                $releaseAsNumber = $releaseAsNumber . str_repeat('0', 10 - strlen($releaseAsNumber));
95
96
                // check if this is actual an upgrade. Still could be a downgrade.
97
                if ($releaseAsNumber < $limitationAsNumber) {
98
                    return 'This would be a downgrade.';
99
                }
100
                if ($releaseAsNumber > $limitationAsNumber) {
101
                    // prep a new array.
102
                    return sprintf(
103
                        "Package: %s\n - maximum supported version: %s\n\n",
104
                        $elements[0],
105
                        $limitation
106
                    );
107
                }
108
            return $result; }, $packages))));
0 ignored issues
show
The variable $result does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
109
    }
110
111
    /**
112
     * @var boolean
113
     */
114
    protected function isCLI()
115
    {
116
        return (PHP_SAPI === 'cli');
117
    }
118
119
    /**
120
     * prints a message during the run of the task
121
     *
122
     * @param string $text
123
     */
124
    protected function message($text)
125
    {
126
        if (!$this->isCLI()) {
127
            $text = '<pre>' . $text . '</pre>' . PHP_EOL;
128
        }
129
130
        echo $text . PHP_EOL;
131
    }
132
}
133