Issues (162)

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.

tests/functional/BaseRestControllerTest.php (12 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 Ntb\RestAPI;
4
5
use Config;
6
7
/**
8
 * Tests for the base rest controller.
9
 *
10
 * @todo: test different serializers, pagination and error handling
11
 * @author Christian Blank <[email protected]>
12
 */
13
class BaseRestControllerTest extends RestTest {
14
15
    public function setUp() {
16
        parent::setUp();
17
        Config::inst()->update('Director', 'rules', [
18
            'v/1/RestTestRoute/$ID/$OtherID' => 'Ntb\RestAPI\TestController',
19
        ]);
20
    }
21
22
    public function testControllerGET() {
23
        $result = $this->makeApiRequest('RestTestRoute');
24
25
        $this->assertTrue(array_key_exists('message', $result));
0 ignored issues
show
The method assertTrue() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
        $this->assertEquals('Test GET', $result['message']);
0 ignored issues
show
The method assertEquals() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
    }
28
29
    public function testControllerDELETE() {
30
        $result = $this->makeApiRequest('RestTestRoute', ['method' => 'DELETE']);
31
32
        $this->assertTrue(array_key_exists('message', $result));
0 ignored issues
show
The method assertTrue() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
        $this->assertEquals('Test DELETE', $result['message']);
0 ignored issues
show
The method assertEquals() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
    }
35
36
    public function testControllerPOST() {
37
        $result = $this->makeApiRequest('RestTestRoute', ['method' => 'POST']);
38
39
        $this->assertTrue(array_key_exists('message', $result));
0 ignored issues
show
The method assertTrue() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
        $this->assertEquals('Test POST', $result['message']);
0 ignored issues
show
The method assertEquals() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
    }
42
43
    public function testControllerPUT() {
44
        $result = $this->makeApiRequest('RestTestRoute', ['method' => 'PUT']);
45
46
        $this->assertTrue(array_key_exists('message', $result));
0 ignored issues
show
The method assertTrue() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
        $this->assertEquals('Test PUT', $result['message']);
0 ignored issues
show
The method assertEquals() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
    }
49
50
    public function testControllerHEAD() {
51
        $result = $this->makeApiRequest('RestTestRoute', ['method' => 'HEAD']);
52
        $this->assertEquals(null, $result);
0 ignored issues
show
The method assertEquals() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
53
    }
54
55
    public function testControllerPATCH() {
56
        $result = $this->makeApiRequest('RestTestRoute', ['method' => 'PATCH']);
57
58
        $this->assertTrue(array_key_exists('message', $result));
0 ignored issues
show
The method assertTrue() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
        $this->assertEquals('Test PATCH', $result['message']);
0 ignored issues
show
The method assertEquals() does not seem to exist on object<Ntb\RestAPI\BaseRestControllerTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
    }
61
}
62
63
class TestController extends BaseRestController implements \TestOnly {
64
65
    private static $allowed_actions = array (
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
66
        'post' => true,
67
        'delete' => true,
68
        'get' => true,
69
        'put' => true,
70
        'patch' => true
71
    );
72
73
    public function get() {
74
        return ['message' => 'Test GET'];
75
    }
76
77
    public function post() {
78
        return ['message' => 'Test POST'];
79
    }
80
81
    public function put() {
82
        return ['message' => 'Test PUT'];
83
    }
84
85
    public function delete() {
86
        return ['message' => 'Test DELETE'];
87
    }
88
89
    public function patch() {
90
        return ['message' => 'Test PATCH'];
91
    }
92
}
93