Issues (5)

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/Exception/FailedToInstantiateObject.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
2
/**
3
 * Bright Nucleus Shortcode Component.
4
 *
5
 * @package   BrightNucleus\Shortcode
6
 * @author    Alain Schlesser <[email protected]>
7
 * @license   MIT
8
 * @link      http://www.brightnucleus.com/
9
 * @copyright 2015-2016 Alain Schlesser, Bright Nucleus
10
 */
11
12
namespace BrightNucleus\Shortcode\Exception;
13
14
use BrightNucleus\Exception\RuntimeException;
15
use Exception;
16
17
/**
18
 * Class FailedToInstantiateObject.
19
 *
20
 * @since   0.3.0
21
 *
22
 * @package BrightNucleus\Shortcode\Exception
23
 * @author  Alain Schlesser <[email protected]>
24
 */
25
class FailedToInstantiateObject extends RuntimeException implements ShortcodeException {
26
27
	/**
28
	 * Create a new instance from a passed-in class name or factory callable.
29
	 *
30
	 * @since 0.3.0
31
	 *
32
	 * @param mixed     $factory   Class name or factory callable.
33
	 * @param string    $interface Interface name that the object should have
34
	 *                             implemented.
35
	 * @param Exception $exception Exception that was caught.
0 ignored issues
show
Should the type for parameter $exception not be Exception|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
36
	 * @return static Instance of an exception.
37
	 */
38
	public static function fromFactory( $factory, $interface, $exception = null ) {
39
		$reason = $exception instanceof Exception
40
			? " Reason: {$exception->getMessage()}"
41
			: '';
42
43
		if ( is_callable( $factory ) ) {
44
			$message = sprintf(
45
				'Could not instantiate object of type "%1$s" from factory of type: "%2$s".%3$s',
46
				$interface,
47
				gettype( $factory ),
48
				$reason
49
			);
50
		} elseif ( is_string( $factory ) ) {
51
			$message = sprintf(
52
				'Could not instantiate object of type "%1$s" from class name: "%2$s".%3$s',
53
				$interface,
54
				$factory,
55
				$reason
56
			);
57
		} else {
58
			$message = sprintf(
59
				'Could not instantiate object of type "%1$s" from invalid argument of type: "%2$s".%3$s',
60
				$interface,
61
				$factory,
62
				$reason
63
			);
64
		}
65
66
		return new static( $message, 0, $exception );
67
	}
68
69
	/**
70
	 * Create a new instance from a passed-in object that does not implement the
71
	 * correct interface.
72
	 *
73
	 * @since 0.3.0
74
	 *
75
	 * @param mixed  $factory   Class name or factory callable.
76
	 * @param string $interface Interface name that the object should have
77
	 *                          implemented.
78
	 * @return static Instance of an exception.
79
	 */
80
	public static function fromInvalidObject( $factory, $interface ) {
81
		$message = sprintf(
82
			'Could not instantiate object of type "%1$s", got "%2$s" instead.',
83
			$interface,
84
			$factory
85
		);
86
		return new static( $message );
87
	}
88
}
89