Issues (320)

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/php/Apix/Server.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
/**
4
 *
5
 * This file is part of the Apix Project.
6
 *
7
 * (c) Franck Cassedanne <franck at ouarz.net>
8
 *
9
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
10
 *
11
 */
12
13
namespace Apix;
14
15
if (!defined('APIX_START_TIME')) {
16
    define('APIX_START_TIME', microtime(true));
17
}
18
19
class Server extends Main
20
{
21
22
   /**
23
    * POST request handler
24
    *
25
    * @param string $path The path name to match against.
26
    * @param mixed  $to   Callback that returns the response when matched.
27
    * @see  Server::proxy
28
    * @return Controller Provides a fluent interface.
29
    */
30
    public function onCreate($path, $to)
31
    {
32
        return $this->proxy('POST', $path, $to);
33
    }
34
35
    /**
36
     * GET request handler
37
     *
38
     * @param  string     $path The path name to match against.
39
     * @param  mixed      $to   Callback that returns the response when matched.
40
     * @see  Server::proxy
41
     * @return Controller Provides a fluent interface.
42
     */
43
    public function onRead($path, $to)
44
    {
45
        return $this->proxy('GET', $path, $to);
46
    }
47
48
    /**
49
     * PUT request handler
50
     *
51
     * @param  string     $path The path name to match against.
52
     * @param  mixed      $to   Callback that returns the response when matched.
53
     * @see  Server::proxy
54
     * @return Controller Provides a fluent interface.
55
     */
56
    public function onUpdate($path, $to)
57
    {
58
        return $this->proxy('PUT', $path, $to);
59
    }
60
61
    /**
62
     * PATCH request handler
63
     *
64
     * @param  string     $path The path name to match against.
65
     * @param  mixed      $to   Callback that returns the response when matched.
66
     * @see  Server::proxy
67
     * @return Controller Provides a fluent interface.
68
     */
69
    public function onModify($path, $to)
70
    {
71
        return $this->proxy('PATCH', $path, $to);
72
    }
73
74
    /**
75
     * DELETE request handler
76
     *
77
     * @param  string     $path The path name to match against.
78
     * @param  mixed      $to   Callback that returns the response when matched.
79
     * @see  Server::proxy
80
     * @return Controller Provides a fluent interface.
81
     */
82
    public function onDelete($path, $to)
83
    {
84
        return $this->proxy('DELETE', $path, $to);
85
    }
86
87
    /**
88
     * OPTIONS request handler
89
     *
90
     * @param  string     $path The path name to match against.
91
     * @param  mixed      $to   Callback that returns the response when matched.
92
     * @see  Server::proxy
93
     * @return Controller Provides a fluent interface.
94
     */
95
    public function onHelp($path, $to)
96
    {
97
        return $this->proxy('OPTIONS', $path, $to);
98
    }
99
100
    /**
101
     * HEAD request handler
102
     *
103
     * @param  string     $path The path name to match against.
104
     * @param  mixed      $to   Callback that returns the response when matched.
105
     * @see  Server::proxy
106
     * @return Controller Provides a fluent interface.
107
     */
108
    public function onTest($path, $to)
109
    {
110
        return $this->proxy('HEAD', $path, $to);
111
    }
112
113
   /**
114
    * Acts as a shortcut to resources::add.
115
    * @see      Resources::add
116
    *
117
    * @param    string          $method     The HTTP method to match against.
118
    * @param    string          $path       The path name to match against.
119
    * @param    mixed           $to         Callback that returns the response
120
    *                                       when matched.
121
    * @return   Controller
122
    */
123
    protected function proxy($method, $path, \Closure $to)
124
    {
125
        return $this->resources->add($path,
126
            array(
127
                'action' => $to,
128
                'method' => $method
129
            )
130
        );
131
    }
132
133
    // public function setGroupInfo($path, array $docs=null)
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
134
    // {
135
    //     var_dump( $this->resources); exit;
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
136
    //     $this->group = $infos;
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
137
    // }
138
139
    /**
140
     * TODO: Test Read from a group.
141
     *
142
     * @param  array  $opts Options are:
0 ignored issues
show
There is no parameter named $opts. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
143
     * @return string
144
     * @codeCoverageIgnore
145
     */
146
    public function setGroup($name, array $groupInfo=null)
147
    {
148
        $this->group[$name] = $groupInfo;
0 ignored issues
show
The property group 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...
149
    }
150
151
}
152