Issues (24)

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.

Zewa/App.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
declare(strict_types=1);
3
namespace Zewa;
4
5
use Sabre\Event\Emitter;
6
use Zewa\Exception\Exception;
7
use Zewa\HTTP\Request;
8
9
/**
10
 * This class is the starting point for application
11
 *
12
 * @author Zechariah Walden<zech @ zewadesign.com>
13
 */
14
class App
15
{
16
    /**
17
     * Return value from application
18
     *
19
     * @var string
20
     */
21
    public $output = '';
22
23
    /**
24
     * @var Dependency $dependency
25
     */
26
    private $dependency;
27
28
    /**
29
     * @var Emitter
30
     */
31
    private $event;
32
33
    /**
34
     * @var Router
35
     */
36
    private $router;
37
38
    /**
39
     * @var Request
40
     */
41
    private $request;
42
43
    /**
44
     * Application bootstrap process
45
     *
46
     * The application registers the configuration in the app/config/core.php
47
     * and then processes, and makes available the configured resources
48
     *
49
     * App constructor.
50
     * @param Dependency $dependency
51
     */
52 5
    public function __construct(Dependency $dependency)
53
    {
54 5
        $this->configuration = $dependency->resolve('\Zewa\Config');
0 ignored issues
show
The property configuration does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
55 5
        $this->event = $dependency->resolve('\Sabre\Event\Emitter', true);
56 5
        $this->dependency = $dependency;
57
58
        /** @var Security security */
59 5
        $this->security = $dependency->resolve('\Zewa\Security', true);
0 ignored issues
show
The property security does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
60
        /** @var Router router */
61 5
        $this->router = $dependency->resolve('\Zewa\Router', true);
62
        /** @var Request request */
63 5
        $this->request = $dependency->resolve('\Zewa\HTTP\Request', true);
64 5
    }
65
66
    /**
67
     * Calls the proper shell for app execution
68
     *
69
     * @access private
70
     */
71 5
    public function initialize()
72
    {
73 5
        $request = $this->router->getAction();
74
75 5
        $isRouteCallback = $this->processRequestParameters($request);
76
77 4
        $this->start($isRouteCallback);
78
79 4
        return $this;
80
    }
81
82
    /**
83
     * @param $request array
84
     * @param $request[0] string namespace to load
85
     * @param $request[1] string method to call
86
     * @access private
87
     * @return bool
88
     * @throws Exception
89
     */
90 5
    private function processRequestParameters($request) : bool
91
    {
92 5
        $params = $this->router->getParameters();
93
94 5
        if ($request !== null) {
95 4
            if (is_array($request)) {
96 2
                $callback = false;
97 2
                $this->request->setRequest($this->dependency->resolve($request[0]));
98 2
                $this->request->setMethod(($request[1]??[]));
99
            } else {
100 2
                $callback = true;
101 2
                $this->request->setRequest($request);
102 2
                array_unshift($params, $this->dependency);
103
            }
104 4
            $this->request->setParams($params);
105 4
            return $callback;
106
        }
107
108 1
        throw new Exception('Invalid request');
109
    }
110
111
    /**
112
     * @param bool $isRouteCallback
113
     */
114 4
    private function start(bool $isRouteCallback)
115
    {
116 4
        $request = $this->request->getRequest();
117 4
        $method = $this->request->getMethod();
118 4
        $params = $this->request->getParams();
119
120 4
        if ($isRouteCallback === false) { // Routed Callback
121 2
            $this->output = call_user_func_array(
122 2
                [&$request, $method],
123
                $params
124
            );
125
        } else {
126 2
            $this->output = call_user_func_array($request, $params);
127
        }
128 4
    }
129
130
    /**
131
     * Prepare application return value into a string
132
     *
133
     * @access public
134
     * @return string
135
     */
136 1
    public function __toString()
137
    {
138 1
        return $this->output;
139
    }
140
}
141