Issues (53)

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/SoapModelAccessTest.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
 * @todo Test Relation getters
4
 * @todo Test filter and limit through GET params
5
 * @todo Test DELETE verb
6
 */
7
class SoapModelAccessTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    public static $fixture_file = 'SoapModelAccessTest.yml';
10
11
    protected $extraDataObjects = array(
12
        'SoapModelAccessTest_Comment',
13
        'SoapModelAccessTest_Page',
14
    );
15
16
    public function getTestSoapConnection()
17
    {
18
        // We can't actually test the SOAP server itself because there's not currently a way of putting it into "test mode"
19
        return new SOAPModelAccess();
20
21
        // One day, we should build this facility and then return something more like the item below:
22
        // return new SoapClient(Director::absoluteBaseURL() . 'soap/v1/wsdl');
23
    }
24
25
    public function testApiAccess()
26
    {
27
        $c = $this->getTestSoapConnection();
28
        $soapResponse = $c->getXML(
29
            'SoapModelAccessTest_Comment',
30
            1,
31
            null,
32
            null,
33
            '[email protected]',
34
            'editor'
35
        );
36
37
        $responseArr = Convert::xml2array($soapResponse);
38
        $this->assertEquals($responseArr['ID'], 1);
39
        $this->assertEquals($responseArr['Name'], 'Joe');
40
    }
41
42
    public function testAuthenticatedPUT()
43
    {
44
        $comment1 = $this->objFromFixture('SoapModelAccessTest_Comment', 'comment1');
45
        $comment1ID = $comment1->ID;
46
47
        // test wrong details
48
        $c = $this->getTestSoapConnection();
49
50
        $updateXML = <<<XML
51
<?xml version="1.0" encoding="UTF-8"?>
52
		<SoapModelAccessTest_Comment>
53
			<ID>$comment1ID</ID>
54
			<Name>Jimmy</Name>
55
		</SoapModelAccessTest_Comment>			
56
XML;
57
58
        $soapResponse = $c->putXML(
59
            'SoapModelAccessTest_Comment',
60
            $comment1->ID,
61
            null,
62
            $updateXML,
63
            '[email protected]',
64
            'wrongpassword'
65
        );
66
        $this->assertEquals('<error type="authentication" code="401">Unauthorized</error>', $soapResponse);
67
68
        // Check that the details weren't saved
69
        $c = $this->getTestSoapConnection();
70
        $soapResponse = $c->getXML('SoapModelAccessTest_Comment', $comment1->ID, null, '[email protected]', 'editor');
71
        $responseArr = Convert::xml2array($soapResponse);
72
        $this->assertEquals($comment1->ID, $responseArr['ID']);
73
        $this->assertEquals('Joe', $responseArr['Name']);
74
75
        // Now do an update with the right password
76
        $soapResponse = $c->putXML(
77
            'SoapModelAccessTest_Comment',
78
            $comment1->ID,
79
            null,
80
            $updateXML,
81
            '[email protected]',
82
            'editor'
83
        );
84
85
        // Check that the details were saved
86
        $c = $this->getTestSoapConnection();
87
        $soapResponse = $c->getXML('SoapModelAccessTest_Comment', $comment1->ID, null, '[email protected]', 'editor');
88
        $responseArr = Convert::xml2array($soapResponse);
89
        $this->assertEquals($comment1->ID, $responseArr['ID']);
90
        $this->assertEquals('Jimmy', $responseArr['Name']);
91
    }
92
93
    public function testAuthenticatedPOST()
94
    {
95
        /*
96
        $c = $this->getTestSoapConnection();
97
        $soapResponse = $c->getXML(
98
            "SoapModelAccessTest_Comment", 
99
            null,
100
            null,
101
            '[email protected]',
102
            'editor'
103
        );
104
        Debug::message($soapResponse);
105
        $responseArr = Convert::xml2array($soapResponse);
106
        Debug::show($responseArr);
107
        $this->assertEquals($responseArr['Name'], 'Created Name');
108
        */
109
    }
110
}
111
112
/**
113
 * Everybody can view comments, logged in members in the "users" group can create comments,
114
 * but only "editors" can edit or delete them.
115
 */
116
class SoapModelAccessTest_Comment extends DataObject implements PermissionProvider,TestOnly
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
Expected 1 space before "TestOnly"; 0 found
Loading history...
117
{
118
    public static $api_access = true;
119
120
    public static $db = array(
121
        'Name' => 'Varchar(255)',
122
        'Comment' => 'Text',
123
    );
124
125
    public static $has_many = array();
126
127
    public function providePermissions()
128
    {
129
        return array(
130
            'EDIT_Comment' => 'Edit Comment Objects',
131
            'CREATE_Comment' => 'Create Comment Objects',
132
            'DELETE_Comment' => 'Delete Comment Objects',
133
        );
134
    }
135
136
    public function canView($member = null)
137
    {
138
        return true;
139
    }
140
141
    public function canEdit($member = null)
142
    {
143
        return Permission::checkMember($member, 'EDIT_Comment');
144
    }
145
146
    public function canDelete($member = null)
147
    {
148
        return Permission::checkMember($member, 'DELETE_Comment');
149
    }
150
151
    public function canCreate($member = null)
152
    {
153
        return Permission::checkMember($member, 'CREATE_Comment');
154
    }
155
}
156
157
class SoapModelAccessTest_Page extends DataObject implements TestOnly
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
158
{
159
    public static $api_access = false;
160
161
    public static $db = array(
162
        'Title' => 'Text',
163
        'Content' => 'HTMLText',
164
    );
165
}
166