Issues (29)

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/server/Server.php (6 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 Toolshedr;
4
5
use Toolshedr\Core\{
6
    Headers,
7
    Response,
8
    Request
9
};
10
11
final class Server
12
{
13
    /**
14
     * @var Headers 
15
     */
16
    private $headers;
17
18
    /**
19
     * @var Request
20
     */
21
    private $request;
22
23
    /**
24
     * @var Response
25
     */
26
    private $response;
27
28
    /**
29
     * Server constructor.
30
     */
31 4
    public function __construct()
32
    {
33 4
        $this->headers = new Headers();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Toolshedr\Core\Headers() of type object<Toolshedr\Core\Headers> is incompatible with the declared type object<Headers> of property $headers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
34 4
        $this->request = new Request();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Toolshedr\Core\Request() of type object<Toolshedr\Core\Request> is incompatible with the declared type object<Request> of property $request.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
35 4
        $this->response = new Response();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Toolshedr\Core\Response() of type object<Toolshedr\Core\Response> is incompatible with the declared type object<Response> of property $response.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
36 4
    }
37
38
    /**
39
     * Whitelist your UI
40
     *
41
     * @param $origin
42
     * @return void
43
     */
44 1
    public function whitelist(string $origin)
45
    {
46 1
        $this->headers->addToWhitelist($origin);
47 1
    }
48
49
    /**
50
     * Is Domain whitelisted
51
     * 
52
     * @param string $origin
53
     * @return bool
54
     */
55 1
    public function isWhitelisted(string $origin)
56
    {
57 1
        return $this->headers->isWhitelisted($origin);
58
    }
59
60
    /**
61
     * Chack is API KEY valid
62
     * 
63
     * @param string $apy_key
0 ignored issues
show
There is no parameter named $apy_key. 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...
64
     * @return mixed
65
     */
66 1
    public function isValidApiKey(string $api_key)
67
    {
68 1
        return $this->request->isValidApiKey($api_key);
69
    }
70
    
71
    /**
72
     * Set API KEY
73
     * 
74
     * @param string $api_key
75
     * @return void
76
     */
77 1
    public function apikey(string $api_key)
78
    {
79 1
        $this->request->setApiKey($api_key);
80 1
    }
81
    
82
    /**
83
     * Run the server
84
     *
85
     * @return void
86
     */
87
    public function run()
88
    {
89
        /**
90
         * Check are request headers ok
91
         */
92
        if ($this->headers->areOk() && !$this->request->isOptionRequest()) {
93
            $this->response->handle($this->request, $this->headers);
94
        } else {
95
            $this->response->options($this->headers);
96
        }
97
98
        $this->headers->send();
99
        
100
        print json_encode($this->response->output(), JSON_PRETTY_PRINT);
101
        
102
        // We are done
103
        exit();
104
    }
105
}
106