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.

ContentImport/ImportCoordinatesTest.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
namespace lloc\Msls\ContentImport;
4
5
6
class ImportCoordinatesTest extends \Msls_UnitTestCase {
7
8
	function setUp() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
9
		parent::setUp();
10
		unset(
11
			$_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ],
12
			$_POST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ],
13
			$_GET[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ]
14
		);
15
	}
16
17
	public function testValidate() {
18
		$dest_lang   = 'en_US';
19
		$source_lang = 'de_DE';
20
21
		$obj = new ImportCoordinates();
22
23
		$this->assertFalse( $obj->validate() );
24
25
		$source_blog_id      = $this->factory->blog->create();
26
		$obj->source_blog_id = $source_blog_id;
27
28
		$this->assertFalse( $obj->validate() );
29
30
		switch_to_blog( $source_blog_id );
31
		$source_post    = $this->factory->post->create_and_get();
32
		$source_post_id = $source_post->ID;
33
34
		$obj->source_post_id = $source_post_id;
35
		$obj->source_post    = $source_post;
36
37
		$this->assertFalse( $obj->validate() );
38
39
		$dest_blog_id = $this->factory->blog->create();
40
41
		$obj->dest_blog_id = $dest_blog_id;
42
43
		$this->assertFalse( $obj->validate() );
44
45
		update_option( 'WPLANG', $source_lang );
46
47
		$obj->source_lang = $source_lang;
48
49
		$this->assertFalse( $obj->validate() );
50
51
		switch_to_blog( $dest_blog_id );
52
		$dest_post_id = $this->factory->post->create();
53
54
		$obj->dest_post_id = $dest_post_id;
55
56
		$this->assertFalse( $obj->validate() );
57
58
		update_option( 'WPLANG', $dest_lang );
59
60
		$obj->dest_lang = $dest_lang;
61
62
		$this->assertTrue( $obj->validate() );
63
	}
64
65
	/**
66
	 * Test set_importer_for
67
	 */
68
	public function test_set_importer_for() {
69
		$obj = new ImportCoordinates();
70
71
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
72
73
		$obj->set_importer_for( 'foo', 'bar' );
74
75
		$this->assertEquals( 'bar', $obj->get_importer_for( 'foo' ) );
76
77
		$this->assertEmpty( $obj->get_importer_for( 'baz' ) );
78
	}
79
80
	/**
81
	 * Test parse_importers from REQUEST
82
	 */
83
	public function test_parse_importers_from_REQUEST() {
84
		$obj = new ImportCoordinates();
85
86
		unset( $_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] );
87
88
		$obj->parse_importers_from_request();
89
90
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
91
92
		$_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [];
93
94
		$obj->parse_importers_from_request();
95
96
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
97
98
		$_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [ 'foo' => 'bar' ];
99
100
		$obj->parse_importers_from_request();
101
102
		$this->assertEquals( 'bar', $obj->get_importer_for( 'foo' ) );
103
	}
104
105
	/**
106
	 * Test parse_importers from POST
107
	 */
108
	public function test_parse_importers_from_POST() {
109
		$obj = new ImportCoordinates();
110
111
		unset( $_POST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] );
112
113
		$obj->parse_importers_from_request();
114
115
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
116
117
		$_POST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [];
118
119
		$obj->parse_importers_from_request();
120
121
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
122
123
		$_POST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [ 'foo' => 'bar' ];
124
125
		$obj->parse_importers_from_request();
126
127
		$this->assertEquals( 'bar', $obj->get_importer_for( 'foo' ) );
128
	}
129
130
	/**
131
	 * Test parse_importers from GET
132
	 */
133
	public function test_parse_importers_from_GET() {
134
		$obj = new ImportCoordinates();
135
136
		unset( $_GET[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] );
137
138
		$obj->parse_importers_from_request();
139
140
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
141
142
		$_GET[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [];
143
144
		$obj->parse_importers_from_request();
145
146
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
147
148
		$_GET[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [ 'foo' => 'bar' ];
149
150
		$obj->parse_importers_from_request();
151
152
		$this->assertEquals( 'bar', $obj->get_importer_for( 'foo' ) );
153
	}
154
155
	/**
156
	 * Test parse_importers from REQUEST and POST
157
	 */
158
	public function test_parse_importers_from_REQUEST_and_POST() {
159
		$obj = new ImportCoordinates();
160
161
		unset( $_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] );
162
		unset( $_POST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] );
163
164
		$obj->parse_importers_from_request();
165
166
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
167
168
		$_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [];
169
		$_POST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ]    = [ 'some' => 'baz' ];
170
171
		$obj->parse_importers_from_request();
172
173
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
174
		$this->assertEmpty( $obj->get_importer_for( 'some' ) );
175
176
		$_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [ 'foo' => 'bar' ];
177
		$_POST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ]    = [ 'some' => 'baz' ];
178
179
		$obj->parse_importers_from_request();
180
181
		$this->assertEquals( 'bar', $obj->get_importer_for( 'foo' ) );
182
		$this->assertEmpty( $obj->get_importer_for( 'some' ) );
183
	}
184
185
	/**
186
	 * Test parse_importers from REQUEST and GET
187
	 */
188
	public function test_parse_importers_from_REQUEST_and_GET() {
189
		$obj = new ImportCoordinates();
190
191
		unset( $_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] );
192
		unset( $_GET[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] );
193
194
		$obj->parse_importers_from_request();
195
196
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
197
198
		$_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [];
199
		$_GET[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ]     = [ 'some' => 'baz' ];
200
201
		$obj->parse_importers_from_request();
202
203
		$this->assertEmpty( $obj->get_importer_for( 'foo' ) );
204
		$this->assertEmpty( $obj->get_importer_for( 'some' ) );
205
206
		$_REQUEST[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ] = [ 'foo' => 'bar' ];
207
		$_GET[ ImportCoordinates::IMPORTERS_GLOBAL_KEY ]     = [ 'some' => 'baz' ];
208
209
		$obj->parse_importers_from_request();
210
211
		$this->assertEquals( 'bar', $obj->get_importer_for( 'foo' ) );
212
		$this->assertEmpty( $obj->get_importer_for( 'some' ) );
213
	}
214
}
215