Issues (5)

Security Analysis    no request data  

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/base/PHPushbulletTestBase.php (1 issue)

Labels
Severity

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
use GuzzleHttp\Client;
4
use PHPushbullet\Connection;
5
use PHPushbullet\PHPushbullet;
6
7
class PHPushbulletTestBase extends PHPUnit_Framework_TestCase
8
{
9
    protected $pushbullet;
10
11
    protected $client;
12
13
    protected $history;
14
15
    protected $guzzle_6;
16
17
    protected $mock_handler;
18
19
    public function setUp()
20
    {
21
        $this->guzzle_6 = version_compare(Client::VERSION, 6, '>=');
22
23
        if ($this->guzzle_6) {
24
            $this->mock_handler = new \GuzzleHttp\Handler\MockHandler();
25
            $this->history      = [];
26
27
            $history = \GuzzleHttp\Middleware::history($this->history);
28
            $stack   = \GuzzleHttp\HandlerStack::create($this->mock_handler);
29
            $stack->push($history);
30
            $client  = new Client(['handler' => $stack]);
31
        } else {
32
            $client        = new Client();
33
            $this->history = new \GuzzleHttp\Subscriber\History();
34
            $this->mock_handler = new \GuzzleHttp\Subscriber\Mock();
35
36
            $client->getEmitter()->attach($this->history);
37
            $client->getEmitter()->attach($this->mock_handler);
38
        }
39
40
        $connection = new Connection('random', $client);
41
42
        $this->pushbullet = new PHPushbullet('random', $connection);
43
    }
44
45
    protected function okResponse($body)
46
    {
47
        $body = json_encode($body);
48
49
        if ($this->guzzle_6) {
50
            return new \GuzzleHttp\Psr7\Response(200, ['Content-Length' => strlen($body)], $body);
51
        }
52
53
        $response = [
54
            'HTTP/1.1 200 OK',
55
            'Content-Length: ' . strlen($body),
56
            '',
57
            $body,
58
        ];
59
60
        return implode("\r\n", $response);
61
    }
62
63
    protected function mock(array $mocks)
64
    {
65
        foreach ($mocks as $mock) {
66
            if ($this->guzzle_6) {
67
                $this->mock_handler->append($mock);
68
            } else {
69
                $this->mock_handler->addResponse($mock);
0 ignored issues
show
The method addResponse() does not seem to exist on object<GuzzleHttp\Handler\MockHandler>.

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...
70
            }
71
        }
72
    }
73
74
    protected function pushResponse($vars)
75
    {
76
        $standard = [
77
            'iden'                      => 'ubdpjxxxOK0sKG',
78
            'created'                   => 1399253701.9746201,
79
            'modified'                  => 1399253701.9744401,
80
            'active'                    => true,
81
            'dismissed'                 => false,
82
            'owner_iden'                => 'ubd',
83
            'target_device_iden'        => 'ubddjAy95rgBxc',
84
            'sender_iden'               => 'ubd',
85
            'sender_email'              => '[email protected]',
86
            'sender_email_normalized'   => '[email protected]',
87
            'receiver_iden'             => 'ubd',
88
            'receiver_email'            => '[email protected]',
89
            'receiver_email_normalized' => '[email protected]'
90
        ];
91
92
        return array_merge($vars, $standard);
93
    }
94
95
    protected function getDevice($type)
96
    {
97
        $devices = [
98
            'android' => [
99
                'iden'         => 'u1qSJddxeKwOGuGW',
100
                'push_token'   => 'u1qSJddxeKwOGuGWu1qdxeKwOGuGWu1qSJddxeK',
101
                'app_version'  => 74,
102
                'fingerprint'  => '{"mac_address":"57:2e:5c:38:39:81","android_id":"ao2cdb9gmf485e96"}',
103
                'active'       => true,
104
                'nickname'     => 'Galaxy S4',
105
                'manufacturer' => 'samsung',
106
                'type'         => 'android',
107
                'created'      => 1394748080.0139201,
108
                'modified'     => 1399008037.8487799,
109
                'model'        => 'SCH-I545',
110
                'pushable'     => true
111
            ],
112
            'chrome' => [
113
                'iden'         => 'u1qSJddxeKwOGuG1',
114
                'push_token'   => 'u1qSJddxeKwOGuGWu1qdxeKwOGuGWu1qSJddxe3',
115
                'app_version'  => 74,
116
                'fingerprint'  => '{"mac_address":"57:2e:5c:38:39:81","android_id":"ao2cdb9gmf485e96"}',
117
                'active'       => true,
118
                'nickname'     => 'Chrome',
119
                'manufacturer' => 'google',
120
                'type'         => 'chrome',
121
                'created'      => 1394748080.0139201,
122
                'modified'     => 1399008037.8487799,
123
                'model'        => 'SCH-I745',
124
                'pushable'     => true
125
            ]
126
        ];
127
128
        return $devices[$type];
129
    }
130
131
    protected function getRuquestUrls()
132
    {
133
        if ($this->guzzle_6) {
134
            return array_map(function ($request) {
135
                return (string) $request['request']->getUri();
136
            }, $this->history);
137
        }
138
139
        return array_map(function ($request) {
140
            return $request->getUrl();
141
        }, $this->history->getRequests());
142
    }
143
144
    protected function assertRequestHistory(array $expected)
145
    {
146
        $this->assertSame($expected, $this->getRuquestUrls());
147
    }
148
149
    /** @test **/
150
151
    public function nothing()
152
    {
153
    }
154
}
155