Issues (438)

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.

classes/pageCache.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
class pageCache extends \Slim\Middleware
3
{
4
	public function call()
5
	{
6
		global $theme;
7
		if(User::isLoggedIn())
8
		{
9
			$this->next->call();
10
			return;
11
		}
12
13
		$pageURL = $this->app->request()->getResourceUri();
14
		$md5 = md5($pageURL . $theme);
15
		$fileCache = new FileCache();
16
17
		// Pages to cache
18
		$pages = array(
19
			"/kill/" => 60*60*24, // Kill detail pages can easily be cached for many hours since they rarely change..
20
			"/system/" => 60*60, // 1 hour cache on the system page
21
			"/region/" => 60*60, // 1 hour cache on the region page
22
			"/group/" => 60*60, // 1 hour cache on the groups view
23
			"/ship/" => 60*15, // 15 minutes on ship view
24
			"/character/" => 60*5, // 5 minutes on character view
25
			"/corporation/" => 60*5, // 5 minutes on corporation view
26
			"/alliance/" => 60*5, // 5 minutes on alliance view
27
			"/faction/" => 60*15, // 15 minutes on faction view
28
			"/item/" => 60*60*24, // 1 Day on item view, shit barely changes..
29
			"/information/" => 60*5, // 5 minutes on information, tho it's probably not needed tbh
30
		);
31
32
		// Default cachetime is 0seconds
33
		$cacheTime = 0;
34
		foreach($pages as $page => $cTime)
35
		{
36
			if(stristr($pageURL, $page)) // Only do shit on the kill page for now... Shou
37
			{
38
				$cacheTime = $cTime;
39
			}
40
		}
41
42
		// Default headers
43
		header("X-PageCache: false");
44
		header("X-PageCache-Time: {$cacheTime}");
45
46
		// Application response
47
		$rsp = $this->app->response();
48
49
		// Get the cached result if it exists
50
		$data = $fileCache->get($md5);
51
		if (isset($data) && !empty($data["body"]))
52
		{
53
			// cache hit... return the cached content
54
			header("X-PageCache: true");
55
			$rsp["Content-Type"] = $data["content_type"];
56
			$rsp->body($data["body"]);
0 ignored issues
show
The method body cannot be called on $rsp (of type array<string,?,{"Content-Type":"?"}>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
57
			return;
58
		}
59
60
		// cache miss... continue on to generate the page
61
		$this->next->call();
62
63
		// cache result for future look up
64
		if ($rsp->status() == 200) {
65
			if($cacheTime > 0)
66
				$fileCache->set($md5, array("key" => $pageURL, "content_type" => $rsp["Content-Type"], "body" => $rsp->body()), $cacheTime);
67
		}
68
	}
69
}
70