Issues (248)

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.

tests/TranslatableSearchableTest.php (5 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
use SilverStripe\Elastica\ElasticSearcher;
4
5
6
/**
7
 * Test the functionality of the Searchable extension
8
 * @package elastica
9
 */
10
class TranslatableSearchableTest extends ElasticsearchBaseTest {
11
	public static $fixture_file = 'elastica/tests/ElasticaTest.yml';
12
13
14
15
	public function setUpOnce() {
16
		//Add translatable if it exists
17
		if (class_exists('Translatable')) {
18
			SiteTree::add_extension('Translatable');
19
		}
20
		parent::setUpOnce();
21
	}
22
23
24
	public function setUp() {
25
		// this needs to be called in order to create the list of searchable
26
		// classes and fields that are available.  Simulates part of a build
27
		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO',
28
			'FlickrTagTO', 'FlickrAuthorTO', 'FlickrSetTO');
29
		$this->requireDefaultRecordsFrom = $classes;
30
		// load fixtures
31
		parent::setUp();
32
	}
33
34
35
36
	public function testgetFieldValuesAsArrayWithLocale() {
37
		if(!class_exists('Translatable')) {
38
			$this->markTestSkipped('Translatable not installed');
0 ignored issues
show
The method markTestSkipped() does not seem to exist on object<TranslatableSearchableTest>.

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...
39
		}
40
41
		$manyTypes = $this->objFromFixture('ManyTypesPage', 'manytypes0001');
42
		$result = $manyTypes->getFieldValuesAsArray();
43
		$this->generateAssertionsFromArray($result);
44
45
		$expected = array(
46
			'BooleanField' => '1',
47
			'CurrencyField' => '100.25',
48
			'DateField' => '2014-04-15',
49
			'DecimalField' => '0',
50
			'EnumField' => '',
51
			'HTMLTextField' => '',
52
			'HTMLVarcharField' => 'This is some *HTML*varchar field',
53
			'IntField' => '677',
54
			'PercentageField' => '27',
55
			'SS_DatetimeField' => '2014-10-18 08:24:00',
56
			'TextField' => 'This is a text field',
57
			'TimeField' => '17:48:18',
58
			'Title' => 'Many Types Page',
59
			'Content' => 'Many types of fields',
60
		);
61
		$this->assertEquals($expected, $result);
62
63
	}
64
65
66
	/**
67
	 * Test a valid identifier
68
	 */
69
	public function testMappingWithLocale() {
70
		if(!class_exists('Translatable')) {
71
			$this->markTestSkipped('Translatable not installed');
0 ignored issues
show
The method markTestSkipped() does not seem to exist on object<TranslatableSearchableTest>.

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...
72
		}
73
74
		$manyTypes = $this->objFromFixture('ManyTypesPage', 'manytypes0001');
75
		$mapping = $manyTypes->getElasticaMapping();
76
77
		// Only check mapping of locale as that is what has changed
78
		$properties = $mapping->getProperties();
79
		$localeProperties = $properties['Locale'];
80
		$this->assertEquals(array('type' => 'string', 'index' => 'not_analyzed'), $localeProperties);
81
	}
82
83
84
85
	/*
86
	Get a record as an Elastic document and check values
87
	 */
88
	public function testGetElasticaDocumentWithLocale() {
89
		if(!class_exists('Translatable')) {
90
			$this->markTestSkipped('Translatable not installed');
0 ignored issues
show
The method markTestSkipped() does not seem to exist on object<TranslatableSearchableTest>.

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...
91
		}
92
93
		$this->markTestSkipped('Translatable not installed');
0 ignored issues
show
The method markTestSkipped() does not seem to exist on object<TranslatableSearchableTest>.

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...
94
95
		// Need to get something from the SiteTree
96
		$manyTypes = $this->objFromFixture('ManyTypesPage', 'manytypes0001');
97
		$result = $manyTypes->getFieldValuesAsArray();
0 ignored issues
show
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
98
		$doc = $manyTypes->getElasticaDocument()->getData();
99
100
		$expected = array(
101
			'BooleanField' => '1',
102
			'CurrencyField' => '100.25',
103
			'DateField' => '2014-04-15',
104
			'DecimalField' => '0',
105
			'EnumField' => '',
106
			'HTMLTextField' => '',
107
			'HTMLVarcharField' => 'This is some *HTML*varchar field',
108
			'IntField' => '677',
109
			'PercentageField' => '27',
110
			'SS_DatetimeField' => '2014-10-18 08:24:00',
111
			'TextField' => 'This is a text field',
112
			'TimeField' => '17:48:18',
113
			'Title' => 'Many Types Page',
114
			'Content' => 'Many types of fields',
115
			'IsInSiteTree' => '1',
116
			'Link' => 'http://moduletest.silverstripe/many-types-page/',
117
			'Locale' => 'en_US',
118
		);
119
		$this->assertEquals($expected, $doc);
120
	}
121
122
}
123