Issues (83)

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.

includes/ContentImport/ImportCoordinates.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
namespace lloc\Msls\ContentImport;
4
5
use lloc\Msls\MslsBlogCollection;
6
7
class ImportCoordinates {
8
9
	const IMPORTERS_GLOBAL_KEY = 'msls_importers';
10
11
	/**
12
	 * @var int
13
	 */
14
	public $source_blog_id;
15
	/**
16
	 * @var int
17
	 */
18
	public $source_post_id;
19
	/**
20
	 * @var int
21
	 */
22
	public $dest_blog_id;
23
	/**
24
	 * @var int
25
	 */
26
	public $dest_post_id;
27
28
	/**
29
	 * @var \WP_Post
30
	 */
31
	public $source_post;
32
33
	/**
34
	 * @var string
35
	 */
36
	public $source_lang;
37
38
	/**
39
	 * @var string
40
	 */
41
	public $dest_lang;
42
43
	/**
44
	 * @var array An array keeping track of which importer (slug) should be used for
45
	 *            a specific import type, shape [ <import-type> => <slug> ]
46
	 */
47
	public $importers = [];
48
49
	/**
50
	 * Validates the coordinates.
51
	 *
52
	 * @return bool
53
	 */
54
	public function validate() {
55
		if ( ! get_blog_post( $this->source_blog_id, $this->source_post_id ) ) {
56
			return false;
57
		}
58
		if ( ! get_blog_post( $this->dest_blog_id, $this->dest_post_id ) ) {
59
			return false;
60
		}
61
		if ( ! $this->source_post instanceof \WP_Post ) {
0 ignored issues
show
The class WP_Post does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
62
			return false;
63
		}
64
65
		if ( $this->source_lang !== MslsBlogCollection::get_blog_language( $this->source_blog_id ) ) {
66
			return false;
67
		}
68
		if ( $this->dest_lang !== MslsBlogCollection::get_blog_language( $this->dest_blog_id ) ) {
69
			return false;
70
		}
71
72
		return true;
73
	}
74
75
	/**
76
	 * Returns the importer (slug) for a specific type of imports.
77
	 *
78
	 * @param string $importer_type
79
	 *
80
	 * @return string|null The import slug if set or `null` if not set.
81
	 */
82
	public function get_importer_for( $importer_type ) {
83
		return isset( $this->importers[ $importer_type ] )
84
			? $this->importers[ $importer_type ]
85
			: null;
86
	}
87
88
	/**
89
	 * Parses the importers from request superglobals.
90
	 */
91
	public function parse_importers_from_request() {
92
		// bitmask
93
		$source = isset( $_REQUEST[ self::IMPORTERS_GLOBAL_KEY ] ) * 100
94
		          + isset( $_POST[ self::IMPORTERS_GLOBAL_KEY ] ) * 10
95
		          + isset( $_GET[ self::IMPORTERS_GLOBAL_KEY ] );
96
97
		switch ( $source ) {
98
			case 100:
99
			case 101;
100
			case 111:
101
			case 110:
102
				$source = $_REQUEST;
103
				break;
104
			case 010:
105
			case 011:
106
			case 000:
107
			default:
108
				$source = $_POST;
109
				break;
110
			case 001:
0 ignored issues
show
case 1: $source = $_GET; break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
111
				$source = $_GET;
112
				break;
113
		}
114
115
		$importers = isset( $source[ self::IMPORTERS_GLOBAL_KEY ] ) && is_array( $source[ self::IMPORTERS_GLOBAL_KEY ] )
116
			? $source[ self::IMPORTERS_GLOBAL_KEY ]
117
			: [];
118
119
		foreach ( $importers as $importer_type => $slug ) {
120
			$this->set_importer_for( $importer_type, $slug );
121
		}
122
	}
123
124
	/**
125
	 * Sets the slug of the importer that should be used for a type of import.
126
	 *
127
	 * @param string $importer_type
128
	 * @param string $slug
129
	 */
130
	public function set_importer_for( $importer_type, $slug ) {
131
		$this->importers[ $importer_type ] = $slug;
132
	}
133
}
134