Issues (1)

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.

src/Client.php (1 issue)

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 namespace MaartenStaa\GameAnalytics;
2
3
use Http\Client\HttpClient;
4
use Http\Discovery\HttpClientDiscovery;
5
use Http\Discovery\MessageFactoryDiscovery;
6
use Http\Message\MessageFactory;
7
8
/**
9
 * Main GA client.
10
 *
11
 * @author Maarten Staa
12
 */
13
class Client
14
{
15
    const API_ENDPOINT = 'http://api.gameanalytics.com/';
16
    const API_ENDPOINT_SANDBOX = 'http://sandbox-api.gameanalytics.com/';
17
    const API_VERSION = 'v2';
18
19
    /**
20
     * The game key from GameAnalytics.
21
     *
22
     * @var string
23
     */
24
    protected $key;
25
26
    /**
27
     * The game's secret key from GameAnalytics.
28
     *
29
     * @var string
30
     */
31
    protected $secret;
32
33
    /**
34
     * The HTTP handler that should be used.
35
     *
36
     * @var \Http\Client\HttpClient
37
     */
38
    protected $http;
39
40
    /**
41
     * The HTTP message factory that should be used.
42
     *
43
     * @var \Http\Message\MessageFactory
44
     */
45
    protected $factory;
46
47
    /**
48
     * Whether this client should communicate with the sandbox servers instead
49
     * of the real API endpoints.
50
     *
51
     * @var bool
52
     */
53
    protected $sandbox = false;
54
55
    /**
56
     * Constructor.
57
     *
58
     * @param string $key
59
     * @param string $secret
60
     * @param \Http\Client\HttpClient|null $http
61
     * @param \Http\Message\MessageFactory|null $factory
62
     */
63
    public function __construct($key, $secret, HttpClient $http = null, MessageFactory $factory = null)
64
    {
65
        $this->key = $key;
66
        $this->secret = $secret;
67
        $this->http = $http ?: HttpClientDiscovery::find();
68
        $this->factory = $factory ?: MessageFactoryDiscovery::find();
69
    }
70
71
    /**
72
     * Set whether this client should refer to the sandbox endpoint.
73
     *
74
     * @param bool $value
75
     */
76
    public function sandbox($value)
77
    {
78
        $this->sandbox = $value;
79
    }
80
81
    /**
82
     * Get the configured game's secret key from GameAnalytics.
83
     *
84
     * @return string
85
     */
86
    public function getSecret()
87
    {
88
        return $this->secret;
89
    }
90
91
    /**
92
     * Get the configured HTTP handler.
93
     *
94
     * @return \Http\Client\HttpAdapter
0 ignored issues
show
Should the return type not be HttpClient?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
95
     */
96
    public function getHttp()
97
    {
98
        return $this->http;
99
    }
100
101
    /**
102
     * Get the configured HTTP message factory.
103
     *
104
     * @return \Http\Message\MessageFactory
105
     */
106
    public function getMessageFactory()
107
    {
108
        return $this->factory;
109
    }
110
111
    /**
112
     * Get the URL that events should be posted to.
113
     *
114
     * @return string
115
     */
116
    public function getEndpoint($api)
117
    {
118
        return ($this->sandbox ? self::API_ENDPOINT_SANDBOX : self::API_ENDPOINT) .
119
            self::API_VERSION . '/' . $this->key . '/'. $api;
120
    }
121
122
    /**
123
     * Get a new init message.
124
     *
125
     * @return \MaartenStaa\GameAnalytics\Message
126
     */
127
    public function init()
128
    {
129
        return new Message($this->getEndpoint('init'), $this);
130
    }
131
132
    /**
133
     * Get a new event message for the given category.
134
     *
135
     * @param  string $category
136
     * @return \MaartenStaa\GameAnalytics\Message
137
     */
138
    public function event($category)
139
    {
140
        $message = new Message($this->getEndpoint('events'), $this);
141
        $message->set('category', $category);
142
143
        return $message;
144
    }
145
146
    /**
147
     * Create a "user" event. Shortcut for event('user').
148
     *
149
     * @return \MaartenStaa\GameAnalytics\Message
150
     */
151
    public function user()
152
    {
153
        return $this->event('user');
154
    }
155
156
    /**
157
     * Create a "session_end" event. Shortcut for event('session_end').
158
     *
159
     * @return \MaartenStaa\GameAnalytics\Message
160
     */
161
    public function sessionEnd()
162
    {
163
        return $this->event('session_end');
164
    }
165
166
    /**
167
     * Create a "business" event. Shortcut for event('business').
168
     *
169
     * @return \MaartenStaa\GameAnalytics\Message
170
     */
171
    public function business()
172
    {
173
        return $this->event('business');
174
    }
175
176
    /**
177
     * Create a "resource" event. Shortcut for event('resource').
178
     *
179
     * @return \MaartenStaa\GameAnalytics\Message
180
     */
181
    public function resource()
182
    {
183
        return $this->event('resource');
184
    }
185
186
    /**
187
     * Create a "progression" event. Shortcut for event('progression').
188
     *
189
     * @return \MaartenStaa\GameAnalytics\Message
190
     */
191
    public function progression()
192
    {
193
        return $this->event('progression');
194
    }
195
196
    /**
197
     * Create a "design" event. Shortcut for event('design').
198
     *
199
     * @return \MaartenStaa\GameAnalytics\Message
200
     */
201
    public function design()
202
    {
203
        return $this->event('design');
204
    }
205
206
    /**
207
     * Create a "error" event. Shortcut for event('error').
208
     *
209
     * @return \MaartenStaa\GameAnalytics\Message
210
     */
211
    public function error()
212
    {
213
        return $this->event('error');
214
    }
215
}
216