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.

src/Application.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
3
namespace Fastpress;
4
5
6
Class Application implements \ArrayAccess{
7
    protected $container = array();
8
    function __construct($conf){
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
9
        $this->container = $conf; 
10
    }
11
    public function toJson(array $array){
12
        return json_encode($array);
13
    } 
14
    
15
    public function offsetGet($offset){
16
        if(array_key_exists($offset, $this->container) && 
17
            is_callable($this->container[$offset])){
18
            return $this->container[$offset]();
19
        }
20
        return $this->container[$offset];
21
    }
22
    
23
    public function offsetExists($offset){
24
        return array_key_exists($offset, $this->container);
25
    }
26
    public function offsetSet($offset, $value){
27
        if(strpos($offset, ':')){
28
            list($index, $subset) = explode(':', $offset, 2); 
29
            $this->container[$index][$subset] = $value; 
30
        }
31
        $this->container[$offset] = $value;
32
    }
33
    public  function store(Callable $callable){
34
        return function () use ($callable){
35
            static $object; 
36
            if(null == $object){
37
                $object = $callable($this->container); 
38
            }
39
            return $object;
40
        }; 
41
    }
42
43
    public function escape($text){
44
        return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
45
    }
46
    
47
    public function server($var, $filter = NULL){
48
        return $this['request']->server($var, $filter);
49
    }
50
51
    public function isGet(){
52
        return $this['request']->isGet();  
53
    }
54
    
55
    public function isPost(){
56
        return $this['request']->isPost();
57
    }
58
    
59
    public function isPut(){
60
        return $this['request']->isPut(); 
61
    }
62
    
63
    public function isDelete(){
64
        return $this['request']->isDelete();
65
    }
66
67
    public function app($key, $value = null){
68
        if(null === $value){
69
            return $this->offsetGet($key); 
70
        }
71
72
        $this->offsetSet($key, $value); 
73
        return $this;
74
    }
75
76
    public function setResponse($header = 200, $statusText = null){
77
        $this['response']->setResponse($header, $statusText);
78
    }
79
80
    public function getVar($value, $filter = null){
81
        return $this['request']->get($value, $filter); 
82
    }
83
84
    public function postVar($value, $filter = null){
85
        return $this['request']->post($value, $filter); 
86
    }
87
88
    public function any($path, $resource){
89
        return $this['route']->any($path, $resource);
90
    }
91
92
    public function get($index, $modifier){      
93
        if(!is_string($modifier) && !is_callable($modifier)){
94
            return $this['request']->get($index, $modifier);
95
        }
96
97
        return $this['route']->get($index, $modifier);
98
    }
99
100
    public function post($index, $modifier){
101
        if(!is_string($modifier) && !is_callable($modifier)){
102
            return $this['request']->post($index, $modifier);
103
        }
104
105
        return $this['route']->post($index, $modifier);
106
    }
107
108
    public function put($path, $resource){
109
        return $this['route']->put($path, $resource);
110
    }
111
112
    public function delete($path, $resource){
113
        return $this['route']->delete($path, $resource);
114
    }
115
116
    private function controllerDipatcher($resource){
117
        $controller = $resource['controller']; 
118
        $method     = $resource['method']; 
119
        $args       = $resource['args']; 
120
121
122
        $controller = $resource['controller']; 
123
        
124
        if(!class_exists($controller)){
125
            throw new \Exception("controller $controller does not exist");
126
        }
127
128
        $controller = new $controller; 
129
        if(!method_exists($controller, $method)){
130
            throw new \Exception("method $method does not exist in $controller"); 
131
        }
132
        
133
        (new $controller)->$method($args, $this);
134
        
135
    }
136
137
    public function view($block, array $variables = []){
138
        $this['view']->view($block, $variables);
139
    }
140
141
    public function layout($layout, array $variables = []){
142
        $this['view']->layout($layout, $variables);
143
    }
144
145
    public function run(){
146
        $input = $this['request']->requestGlobals(); 
147
        $resource = $this['route']->match($input['server'], $input['post']);
148
149
        if(is_array($resource) && !empty($resource)){
150
            $dispatch = $this->controllerDipatcher($resource);
0 ignored issues
show
Are you sure the assignment to $dispatch is correct as $this->controllerDipatcher($resource) (which targets Fastpress\Application::controllerDipatcher()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
151
        }
152
    }
153
154
    public function offsetUnset($offset){}
155
    
156
}
157
158