Issues (183)

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.

src/Request/Cli.php (1 issue)

Severity

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
namespace FMUP\Request;
3
4
use FMUP\Request;
5
6
class Cli extends Request
7
{
8
    const SHORT = 'SHORT';
9
    const LONG = 'LONG';
10
11
    private $opt = array(self::SHORT => '', self::LONG => array('route:'));
12
13
    /**
14
     * @param string $short
15
     * @param array $long
16
     * @return $this
17
     */
18 1
    public function defineOpt($short = '', array $long = array())
19
    {
20 1
        $long[] = 'route:';
21 1
        $this->opt = array(
22 1
            self::SHORT => (string)$short,
23 1
            self::LONG => (array)$long,
24
        );
25 1
        return $this;
26
    }
27
28
    /**
29
     * Retrieve defined opt
30
     * @return array
31
     */
32 1
    public function getDefinedOpt()
33
    {
34 1
        return $this->opt;
35
    }
36
37
    /**
38
     * @param string $name
39
     * @param mixed $defaultValue
40
     * @return string|mixed
41
     */
42 1
    public function get($name, $defaultValue = null)
43
    {
44 1
        $options = $this->getOpt();
45 1
        return isset($options[$name]) ? $options[$name] : $defaultValue;
46
    }
47
48
    /**
49
     * @return array
50
     */
51 1
    public function getOpt()
52
    {
53 1
        return $this->phpGetOpt($this->opt[self::SHORT], $this->opt[self::LONG]);
54
    }
55
56
    /**
57
     * @param string $short
58
     * @param array $long
59
     * @return array
60
     * @codeCoverageIgnore
61
     */
62
    protected function phpGetOpt($short, array $long = array())
63
    {
64
        return getopt((string)$short, $long);
65
    }
66
67
    /**
68
     * @param string $name
69
     * @return bool
70
     */
71 1
    public function has($name)
72
    {
73 1
        return isset($this->getOpt()[$name]);
74
    }
75
76
    /**
77
     * @param bool|false $withQuerySting
78
     * @return string
79
     */
80 2
    public function getRequestUri($withQuerySting = false)
0 ignored issues
show
getRequestUri uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
81
    {
82 2
        $return = $this->get('route');
83 2
        if (isset($_SERVER['argc']) && $_SERVER['argc'] > 2 && $withQuerySting) {
84 1
            $args = $_SERVER['argv'];
85 1
            unset($args[0]);
86 1
            $return = implode(' ', $args);
87
        }
88 2
        return $return;
89
    }
90
}
91