Issues (71)

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.

code/OpauthResponseHelper.php (2 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
/**
4
 * OpauthResponseHelper
5
 * Utility class for handling responses from Opauth.
6
 * Used in parsing. Can and should be referenced in _config.yml for helping
7
 * parse things for member_mapping.
8
 * @author Will Morgan <@willmorgan>
9
 * @copyright Copyright (c) 2013, Better Brief LLP
10
 */
11
class OpauthResponseHelper {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
13
	/**
14
	 * Take the first part of the name
15
	 * @return string
16
	 */
17
	public static function get_first_name($source) {
18
		$name = explode(' ', self::parse_source_path('info.name', $source));
19
		return array_shift($name);
20
	}
21
22
	/**
23
	 * Take all but the first part of the name
24
	 * @return string
25
	 */
26
	public static function get_last_name($source) {
27
		$name = explode(' ', self::parse_source_path('info.name', $source));
28
		array_shift($name);
29
		return join(' ', $name);
30
	}
31
32
	/**
33
	 * Twitter responds with just a language (also a TZ, but unused for now)
34
	 * If the PECL Locale extension is used it may be possible to combine both
35
	 * the TZ and the language to fine tune a user's location, but a bit OTT.
36
	 * @return string
37
	 */
38
	public static function get_twitter_locale($source) {
39
		$language = self::parse_source_path('raw.lang', $source);
40
		return self::get_smart_locale($language);
41
	}
42
43
	/**
44
	 * Google responds near perfectly for locales, if populated.
45
	 * Fallback otherwise.
46
	 * @return string
47
	 */
48
	public static function get_google_locale($source) {
49
		$locale = self::parse_source_path('raw.locale', $source);
50
		if(!$locale) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $locale of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
51
			return self::get_smart_locale();
52
		}
53
		return str_replace('-', '_', $locale);
54
	}
55
56
	/**
57
	 * Try very hard to get a locale for this user. Helps for i18n etc.
58
	 * @return string
59
	 */
60
	public static function get_smart_locale($language = null) {
61
62
		require_once FRAMEWORK_PATH . '/thirdparty/Zend/Locale.php';
63
		$locale = Zend_Locale::getBrowser();
64
65
		if(!$locale) {
66
			if($language) {
67
				return i18n::get_locale_from_lang($language);
68
			}
69
			else {
70
				return i18n::get_locale();
71
			}
72
		}
73
74
		$locale = array_keys($locale);
75
		$firstPref = array_shift($locale);
76
77
		if(strpos($firstPref, '_') === false) {
78
			return i18n::get_locale_from_lang($language);
79
		}
80
81
		return $firstPref;
82
	}
83
84
	/**
85
	 * Dot notation parser. Looks for an index or fails gracefully if not found.
86
	 * @param string $path The path, dot notated.
87
	 * @param array $source The source in which to search.
88
	 * @return string|null
89
	 */
90
	public static function parse_source_path($path, $source) {
91
		$fragments = explode('.', $path);
92
		$currentFrame = $source;
93
		foreach($fragments as $fragment) {
94
			if(!isset($currentFrame[$fragment])) {
95
				return null;
96
			}
97
			$currentFrame = $currentFrame[$fragment];
98
		}
99
		return $currentFrame;
100
	}
101
102
}
103