GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (4)

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/Bay.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 namespace Myth\Bay;
2
3
/**
4
 * Class Bay
5
 *
6
 * @package Myth\Bay
7
 */
8
class Bay {
9
10
	/**
11
	 * Instance of our customized class loader.
12
	 *
13
	 * @var LibraryFinderInterface|null
14
	 */
15
	protected $finder = null;
16
17
	/**
18
	 * Instance of our cache access library.
19
	 *
20
	 * @var CacheInterface|null
21
	 */
22
	protected $cache = null;
23
24
	//--------------------------------------------------------------------
25
26
	public function __construct(LibraryFinderInterface $finder = null, CacheInterface $cache = null)
27
	{
28
		if (is_object($finder))
29
		{
30
			$this->finder = $finder;
31
		}
32
33
		if (is_object($cache))
34
		{
35
			$this->cache = $cache;
36
		}
37
	}
38
39
	//--------------------------------------------------------------------
40
41
42
	/**
43
	 * The primary method used. Will attempt to locate the library, run
44
	 * the requested method, and return the rendered HTML.
45
	 *
46
	 * @param string        $library
47
	 * @param string|array  $params
48
	 * @param string        $cache_name
49
	 * @param int           $cache_ttl      // Time in _minutes_
50
	 *
51
	 * @return null|string
52
	 */
53
	public function display($library, $params=null, $cache_name=null, $cache_ttl=0)
54
	{
55
		list($class, $method) = $this->determineClass($library);
56
57
		// Is it cached?
58
		$cache_name = ! empty($cache_name) ? $cache_name : $class . $method . md5(serialize($params));
59
60
		if (! empty($this->cache) && $output = $this->cache->get($cache_name))
61
		{
62
			return $output;
63
		}
64
65
		// Not cached - so grab it...
66
		$instance = new $class();
67
68
		if (!method_exists($instance, $method))
69
		{
70
			throw new \InvalidArgumentException("{$class}::{$method} is not a valid method.");
71
		}
72
73
		$params_array = $this->prepareParams($params);
74
		$ref_method = new \ReflectionMethod($instance, $method);
75
		$num_of_params = $ref_method->getNumberOfParameters();
76
		$ref_params = $ref_method->getParameters();
77
78
		if ($num_of_params === 0)
79
		{
80
			if ($params_array !== null)
81
			{
82
				throw new \InvalidArgumentException("{$class}::{$method} has no params.");
83
			}
84
85
			$output = $instance->{$method}();
86
		}
87
		elseif (
88
			($num_of_params === 1)
89
			&& (
90
				(! array_key_exists($ref_params[0]->name, $params_array))
91
				|| (
92
					array_key_exists($ref_params[0]->name, $params_array)
93
					&& count($params_array) !== 1
94
				)
95
			)
96
		)
97
		{
98
			$output = $instance->{$method}($params_array);
99
		}
100
		else
101
		{
102
			$fire_args = [];
103
			$method_params = [];
104
105
			foreach($ref_params as $arg)
106
			{
107
				$method_params[$arg->name] = true;
108
				if (array_key_exists($arg->name, $params_array))
109
				{
110
					$fire_args[$arg->name] = $params_array[$arg->name];
111
				}
112
			}
113
114
			foreach ($params_array as $key => $val)
0 ignored issues
show
The expression $params_array of type null|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
115
			{
116
				if (! isset($method_params[$key]))
117
				{
118
					throw new \InvalidArgumentException("{$key} is not a valid param name.");
119
				}
120
			}
121
122
			$output = call_user_func_array([$instance, $method], $fire_args);
123
		}
124
125
		// Can we cache it?
126
		if (! empty($this->cache) && $cache_ttl !== 0)
127
		{
128
			$this->cache->set($cache_name, $output, $cache_ttl);
129
		}
130
131
		return $output;
132
	}
133
134
	//--------------------------------------------------------------------
135
136
	//--------------------------------------------------------------------
137
	// Utility Methods
138
	//--------------------------------------------------------------------
139
140
	/**
141
	 * Attempts to locate and load the class passed in the library
142
	 * portion of the display() method.
143
	 *
144
	 * First, we will try to autoload the file. If it cannot be found there,
145
	 * we will try to run a framework-specific loader, if the user provided
146
	 * one in __construct();
147
	 *
148
	 * @param $library
149
	 * @return array
150
	 */
151
	public function determineClass($library)
152
	{
153
		$found = false;
154
155
		// We don't want to actually call static methods
156
		// by default, so convert any double colons.
157
		$library = str_replace('::', ':', $library);
158
159
		list($class, $method) = explode(':', $library);
160
161
		if (empty($class))
162
		{
163
			throw new \InvalidArgumentException('No class provided to Bay::display().');
164
		}
165
166
		if (!class_exists($class, true))
167
		{
168
			// Try the Finder to see if it can find it...
169
			if (!is_null($this->finder))
170
			{
171
				if ($this->finder->find($class))
172
				{
173
					$found = true;
174
				}
175
			}
176
		}
177
		else
178
		{
179
			$found = true;
180
		}
181
182
		if (!$found)
183
		{
184
			throw new \InvalidArgumentException('Unable to locate class '.$class.', provided to Bay::display().');
185
		}
186
187
		if (empty($method))
188
		{
189
			$method = 'index';
190
		}
191
192
		return [ $class, $method ];
193
	}
194
195
	//--------------------------------------------------------------------
196
197
	/**
198
	 * Parses the params attribute. If an array, returns untouched.
199
	 * If a string, it should be in the format "key1=value key2=value".
200
	 * It will be split and returned as an array.
201
	 *
202
	 * @param $params
203
	 * @return array|null
204
	 */
205
	public function prepareParams($params)
206
	{
207
		if (!is_string($params) && !is_array($params))
208
		{
209
			return null;
210
		}
211
212
		if (is_string($params))
213
		{
214
			if (empty($params))
215
			{
216
				return null;
217
			}
218
219
			$new_params = [ ];
220
221
			$separator = ' ';
222
			if (strpos($params, ',') !== false)
223
			{
224
				$separator = ',';
225
			}
226
227
			$params = explode($separator, $params);
228
			unset($separator);
229
230
			foreach ($params as $p)
231
			{
232
				list($key, $val) = explode('=', $p);
233
234
				$new_params[ trim($key) ] = trim($val, ', ');
235
			}
236
237
			$params = $new_params;
238
			unset($new_params);
239
		}
240
241
		if (is_array($params) && !count($params))
242
		{
243
			return null;
244
		}
245
246
		return $params;
247
	}
248
249
	//--------------------------------------------------------------------
250
251
}
252