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/ImportersBaseFactoryTest.php (8 issues)

Labels
Severity

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\Importers;
4
5
use lloc\Msls\ContentImport\ImportCoordinates;
6
use lloc\Msls\ContentImport\Importers\PostMeta\Duplicating;
7
8
class BadImportersFactory extends ImportersBaseFactory {
9
}
10
11
class DummyImportersBaseFactoryOne extends ImportersBaseFactory {
12
13
	const TYPE = 'one';
14
15
	protected $importers_map = [];
16
}
17
18
class DummyImportersBaseFactoryTwo extends ImportersBaseFactory {
19
20
	const TYPE = 'two';
21
22
	protected $importers_map = [
23
		'some-option' => Duplicating::class,
24
	];
25
}
26
27
class ImportersBaseFactoryTest extends \Msls_UnitTestCase {
28
29
	/**
30
	 * @var ImportCoordinates
31
	 */
32
	protected $import_coordinates;
33
34
	/**
35
	 * Test make will throw if the extending class is not defining its type
36
	 */
37
	public function test_make_will_throw_if_the_extending_class_is_not_defining_its_type() {
38
		$this->expectException( \RuntimeException::class );
39
40
		BadImportersFactory::instance()->make( $this->import_coordinates->reveal() );
0 ignored issues
show
The method reveal() does not seem to exist on object<lloc\Msls\ContentImport\ImportCoordinates>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
	}
42
43
	/**
44
	 * Test will return BaseImporter if map empty
45
	 */
46
	public function test_will_return_base_importer_if_map_empty() {
47
		$this->assertInstanceOf(
48
			BaseImporter::class,
49
			DummyImportersBaseFactoryOne::instance()->make( $this->import_coordinates->reveal() )
0 ignored issues
show
The method reveal() does not seem to exist on object<lloc\Msls\ContentImport\ImportCoordinates>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
50
		);
51
	}
52
53
	/**
54
	 * Test will return BaseImporter if map emptied
55
	 */
56
	public function test_will_return_base_importer_if_map_emptied() {
57
		add_filter( 'msls_content_import_two_importers_map', function () {
58
			return [];
59
		} );
60
61
		$this->assertInstanceOf(
62
			BaseImporter::class,
63
			DummyImportersBaseFactoryTwo::instance()->make( $this->import_coordinates->reveal() )
0 ignored issues
show
The method reveal() does not seem to exist on object<lloc\Msls\ContentImport\ImportCoordinates>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
		);
65
	}
66
67
	/**
68
	 * Test will return filtered importer
69
	 */
70
	public function test_will_return_filtered_importer() {
71
		$importer = $this->prophesize( Importer::class )->reveal();
72
73
		add_filter( 'msls_content_import_one_importer', function () use ( $importer ) {
74
			return $importer;
75
		} );
76
77
		$this->assertSame(
78
			$importer,
79
			DummyImportersBaseFactoryOne::instance()->make( $this->import_coordinates->reveal() )
0 ignored issues
show
The method reveal() does not seem to exist on object<lloc\Msls\ContentImport\ImportCoordinates>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
80
		);
81
	}
82
83
	/**
84
	 * Test will return base importer if slug missing from map
85
	 */
86
	public function test_will_return_base_importer_if_slug_missing_from_map() {
87
		$this->import_coordinates->get_importer_for( 'two' )->willReturn( 'not-there' );
0 ignored issues
show
The method willReturn cannot be called on $this->import_coordinate...get_importer_for('two') (of type string|null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
88
89
		$this->assertInstanceOf(
90
			BaseImporter::class,
91
			DummyImportersBaseFactoryTwo::instance()->make( $this->import_coordinates->reveal() )
0 ignored issues
show
The method reveal() does not seem to exist on object<lloc\Msls\ContentImport\ImportCoordinates>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
92
		);
93
	}
94
95
	/**
96
	 * Test will return the mapped importer
97
	 */
98
	public function test_will_return_the_mapped_importer() {
99
		$this->import_coordinates->get_importer_for( 'two' )->willReturn( 'some-option' );
0 ignored issues
show
The method willReturn cannot be called on $this->import_coordinate...get_importer_for('two') (of type string|null).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
100
101
		$this->assertInstanceOf(
102
			Duplicating::class,
103
			DummyImportersBaseFactoryTwo::instance()->make( $this->import_coordinates->reveal() )
0 ignored issues
show
The method reveal() does not seem to exist on object<lloc\Msls\ContentImport\ImportCoordinates>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
104
		);
105
	}
106
107
	public function setUp() {
108
		parent::setUp();
109
		$this->import_coordinates = $this->prophesize( ImportCoordinates::class );
110
	}
111
}
112