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 (10)

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/Escaper/CEscaper.php (9 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
3
namespace Scelus\Escaper;
4
5
/*
6
* All functions are based on the recommendations in the 
7
* XSS (Cross Site Scripting) Prevention Cheat Sheet:
8
* https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet
9
* 
10
*/
11
class CEscaper
12
{
13
	private $CHARSET;
14
15 9
	public function __construct($encoding = 'UTF-8') {
0 ignored issues
show
__construct uses the super-global variable $_SESSION which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
16 9
		isset($_SESSION['escaper_charset']) 
17 9
			? $this->CHARSET = $_SESSION['escaper_charset'] 
18 9
			: $_SESSION['escaper_charset'] = $encoding;
19
			
20 9
		$this->CHARSET = $_SESSION['escaper_charset'];
21 9
	}
22
23
	/** Sets the used charset for the esacpeHTML and escapeXML function.
24
	*
25
	* @param $value, the string/value to escape.
26
	*
27
	*/
28 1
	public function setEncoding($value) {
0 ignored issues
show
setEncoding uses the super-global variable $_SESSION which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
29 1
		$_SESSION['escaper_charset'] = strip_tags($value);
30 1
		$this->CHARSET = $_SESSION['escaper_charset'];
31 1
	}
32
33
	/** Returns the used charset for the esacpeHTML and escapeXML function.
34
	*
35
	* @return the current charset as a string.
36
	*/
37 2
	public function getEncoding() {
38 2
		return $this->CHARSET;
39
	}
40
41
	/** Escapes HTML string using htmlspecialchars().
42
	*
43
	* @param $string, the untrusted string to escape.
44
	*
45
	* @return $result, escaped string.
0 ignored issues
show
The doc-type $result, could not be parsed: Unknown type name "$result" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
46
	*/
47 2
	public function escapeHTML($value) {
48 2
		$result = htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, $this->CHARSET);
49 2
		$result = preg_replace('/[\/]/', '&#x2F;', $result);
50
		
51 2
		return $result;
52
	}
53
54
	/** Escapes non-alphanumeric characters in an untrusted string for HTML attribute values.
55
	*
56
	* @param $string, the untrusted string to escape.
57
	*
58
	* @return $result, escaped string.
0 ignored issues
show
The doc-type $result, could not be parsed: Unknown type name "$result" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
59
	*/
60 2 View Code Duplication
	public function escapeHTMLattr($value) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
		$result = preg_replace_callback("/[\W]/", function($matches) {
62 2
			return "&#x" . bin2hex($matches[0]) . ";";
63 2
		}, 
64 2
		$value);
65 2
		return $result;
66
	}
67
68
	/** Escapes non-alphanumeric characters in an untrusted string for JS input values.
69
	*
70
	* @param $string, the untrusted string to escape.
71
	*
72
	* @return $result, escaped string.
0 ignored issues
show
The doc-type $result, could not be parsed: Unknown type name "$result" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
73
	*/
74 1 View Code Duplication
	public function escapeJs($value) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
		$result = preg_replace_callback("/[\W]/", function($matches) {
76 1
			return "\\x" . bin2hex($matches[0]);
77 1
		}, 
78 1
		$value);
79
80 1
		return $result;
81
	}
82
83
	/** Escapes non-alphanumeric characters in an untrusted string for CSS input values.
84
	*
85
	* @param $string, the untrusted string to escape.
86
	*
87
	* @return $result, escaped string.
0 ignored issues
show
The doc-type $result, could not be parsed: Unknown type name "$result" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
88
	*/
89 View Code Duplication
	public function escapeCSS($value) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90 1
		$result = preg_replace_callback("/[\W]/", function($matches) {
91 1
			return "\\" . bin2hex($matches[0]) . " ";
92 1
		}, 
93 1
		$value);
94
95 1
		return $result;
96
	}
97
98
	/** Escapes data that is to be inserted in a URL not the whole URL itself.
99
	* 
100
	* @param $string, the untrusted string to escape.
101
	*
102
	* @return, escaped string.
103
	*/
104 1
	public function escapeUrl($value) {
105 1
		return rawurlencode($value);
106
	}
107
108
	/**
109
	* Aliases to HTML functions for semantic value.
110
	* XML escaping is identical to HTML escaping.
111
	*/
112 1
	public function escapeXml($value) {
113 1
		return $this->escapeHTML($value);
114
	}
115
116 1
	public function escapeXmlAttr($value) {
117 1
		return $this->escapeHTMLattr($value);
118
	}
119
}
120