Issues (4714)

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/unit/XMLRPC/ContactXMLRPCTest.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
require_once 'Intraface/XMLRPC/Contact/Server.php';
3
4
class ContactXMLRPCTest extends PHPUnit_Framework_TestCase
5
{
6
    protected $server;
7
    protected $db;
8
9
    function setUp()
10
    {
11
        $this->server = new Intraface_XMLRPC_Contact_Server;
12
        $this->db = MDB2::singleton(DB_DSN);
13
    }
14
15
    function tearDown()
16
    {
17
        $this->db->exec('TRUNCATE contact');
18
        $this->db->exec('TRUNCATE address');
19
        unset($this->server);
20
        unset($this->db);
21
    }
22
23
    function getClient()
24
    {
25
        require_once dirname(__FILE__) . '/../../../install/Install.php';
26
27
        if (!defined('SERVER_STATUS')) {
28
            define('SERVER_STATUS', 'TEST');
29
        }
30
31
        $install = new Intraface_Install;
32
        $install->resetServer();
33
        $install->grantModuleAccess('administration', 'contact');
0 ignored issues
show
The call to Intraface_Install::grantModuleAccess() has too many arguments starting with 'contact'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
34
35
        require_once 'XML/RPC2/Client.php';
36
        $debug = false;
37
        $options = array('prefix' => 'contact.', 'debug' => $debug, 'encoding' => 'utf-8');
38
        $client = XML_RPC2_Client::create(XMLRPC_SERVER_URL.'contact', $options);
39
40
        return $client;
41
    }
42
43
    ////////////////////////////////////////////////
44
45
    function testConstruction()
46
    {
47
        $this->markTestIncomplete(
48
            'This test has not been implemented yet.'
49
        );
50
        $this->assertTrue(is_object($this->server));
51
    }
52
53
    function testEmptyCredentialsThrowsException()
54
    {
55
        $this->markTestIncomplete(
56
            'This test has not been implemented yet.'
57
        );
58
        $credentials = array();
59
        $data = array();
60
61
        try {
62
            $this->server->saveContact($credentials, $data);
0 ignored issues
show
$credentials is of type array, but the function expects a object<Struct>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
63
            $this->assertFalse(true, 'Should have thrown an exception');
64
        } catch (XML_RPC2_FaultException $e) {
0 ignored issues
show
The class XML_RPC2_FaultException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
65
            $this->assertTrue(true);
66
        }
67
    }
68
69
    function testInvalidKeyThrowsException()
70
    {
71
        $this->markTestIncomplete(
72
            'This test has not been implemented yet.'
73
        );
74
        $credentials = array('private_key' => 'privatekeyshouldbereplaced', 'session_id' => 'something');
75
        $data = array();
76
        try {
77
            $this->server->saveContact($credentials, $data);
0 ignored issues
show
$credentials is of type array<string,string,{"pr..."session_id":"string"}>, but the function expects a object<Struct>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
78
            $this->assertFalse(true, 'Should have thrown an exception');
79
        } catch (XML_RPC2_FaultException $e) {
0 ignored issues
show
The class XML_RPC2_FaultException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
80
            $this->assertTrue(true);
81
        }
82
    }
83
84
    /**
85
     * @group xmlrpc
86
     */
87
    function testGetContactWithDanishCharactersIsReturnedInUTF8FromTheClient()
88
    {
89
        $this->markTestIncomplete(
90
            'This test has not been implemented yet.'
91
        );
92
        $client = $this->getClient();
93
        $credentials = array('private_key' => 'privatekeyshouldbereplaced', 'session_id' => 'something');
94
95
        $contact = new Contact(new Stub_Kernel);
96
        $data = array('name' => 'Tester æøå');
97
        $res = $contact->save($data);
0 ignored issues
show
Are you sure the assignment to $res is correct as $contact->save($data) (which targets Contact::save()) 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...
98
        $this->assertEquals(1, $res);
99
        $this->assertEquals('Tester æøå', $contact->get('name'));
100
101
        $retrieved = $client->getContact($credentials, $contact->getId());
102
103
        $this->assertEquals('Tester æøå', $retrieved['name']);
104
    }
105
106
    /**
107
     * @group xmlrpc
108
     */
109
    function testSaveContactWorksWithDanishCharacters()
110
    {
111
        $this->markTestIncomplete(
112
            'This test has not been implemented yet.'
113
        );
114
        $client = $this->getClient();
115
        $credentials = array('private_key' => 'privatekeyshouldbereplaced', 'session_id' => 'something');
116
117
        $contact = new Contact(new Stub_Kernel);
118
        $data = array('name' => 'Tester');
119
        $contact->save($data);
120
121
        $new_name = 'Tester æøå';
122
        $data = array('id' => $contact->getId(), 'name' => $new_name);
123
        $this->assertTrue($client->saveContact($credentials, $data));
124
125
        $saved_contact = new Contact(new Stub_Kernel, $contact->getId());
126
        $this->assertEquals($new_name, $saved_contact->get('name'));
127
    }
128
}
129