Issues (1752)

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.

func/array.test.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
 * Test - array function
4
 * @package     fwolflib
5
 * @subpackage	func.test
6
 * @copyright   Copyright 2010, Fwolf
7
 * @author      Fwolf <[email protected]>
8
 * @since		2010-01-25
9
 */
10
11
// Define like this, so test can run both under eclipse and web alone.
12
// {{{
13
if (! defined('SIMPLE_TEST')) {
14
	define('SIMPLE_TEST', 'simpletest/');
15
	require_once(SIMPLE_TEST . 'autorun.php');
16
}
17
// Then set output encoding
18
//header('Content-Type: text/html; charset=utf-8');
19
// }}}
20
21
22
// Require library define file which need test
23
require_once(dirname(__FILE__) . '/../fwolflib.php');
24
require_once(FWOLFLIB . 'func/array.php');
25
require_once(FWOLFLIB . 'func/request.php');
26
27
28
class TestFuncArray extends UnitTestCase {
29
30
    function TestArrayAdd () {
31
		$ar = array();
32
		ArrayAdd($ar, 'a', 3);
33
		ArrayAdd($ar, 'a', 4);
34
		$this->assertEqual($ar['a'], 7);
35
36
		ArrayAdd($ar, 'b', 3);
37
		ArrayAdd($ar, 'b', '4');
38
		$this->assertEqual($ar['b'], '34');
39
40
    } // end of func TestArrayAdd
41
42
43
    function TestArrayEval () {
44
		$ar = array('a' => 'string');
45
		$s_eval = 'substr("{a}", 1, 2) == "tr"';
46
		$this->assertEqual(true, ArrayEval($s_eval, $ar));
47
48
		$s_eval = 'substr("string", 1, 2) == "tr"';
49
		$this->assertEqual(true, ArrayEval($s_eval));
50
51
		$s_eval = 'substr("{a}", 1, 2) == "tr"; return false;';
52
		$this->assertEqual(false, ArrayEval($s_eval, array()));
53
	} // end of func TestArrayEval
54
55
56
    function TestArrayInsert () {
57
		// Pos not exists, number indexed
58
		$ar_srce = array('a', 'b', 'c');
59
		$x = $ar_srce;
60
		$x = ArrayInsert($x, 'd', array('d'));
61
		$this->assertEqual(var_export($x, true)
62
			, var_export(array('a', 'b', 'c', 'd'), true));
63
64
		// Pos not exists, assoc indexed
65
		$ar_srce = array(
66
			'a' => 1,
67
			'b' => 2,
68
			'c' => 3,
69
		);
70
		$x = $ar_srce;
71
		$x = ArrayInsert($x, 'd', array('d'));
72
		$this->assertEqual(var_export($x, true), var_export(array(
73
			'a' => 1,
74
			'b' => 2,
75
			'c' => 3,
76
			0 => 'd',
77
		), true));
78
79
		// Assoc indexed, normal
80
		$ar_srce = array(
81
			'a' => 1,
82
			'b' => 2,
83
			'c' => 3,
84
			'd' => 4,
85
			'e' => 5,
86
		);
87
		$ar_ins = array(
88
			'ins1'	=> 'ins1',
89
			'ins2'	=> 'ins2',
90
		);
91
		// Insert before a key
92
		$x = $ar_srce;
93
		ArrayInsert($x, 'c', $ar_ins, -2);
94
		$this->assertEqual(var_export($x, true), var_export(array(
95
			'a' => 1,
96
			'ins1'	=> 'ins1',
97
			'ins2'	=> 'ins2',
98
			'b' => 2,
99
			'c' => 3,
100
			'd' => 4,
101
			'e' => 5,
102
		), true));
103
104
		// Insert after a key
105
		$x = $ar_srce;
106
		ArrayInsert($x, 'c', $ar_ins, 2);
107
		$this->assertEqual(var_export($x, true), var_export(array(
108
			'a' => 1,
109
			'b' => 2,
110
			'c' => 3,
111
			'd' => 4,
112
			'ins1'	=> 'ins1',
113
			'ins2'	=> 'ins2',
114
			'e' => 5,
115
		), true));
116
117
		// Replace
118
		$x = $ar_srce;
119
		ArrayInsert($x, 'a', $ar_ins, 0);
120
		$this->assertEqual(var_export($x, true), var_export(array(
121
			'ins1'	=> 'ins1',
122
			'ins2'	=> 'ins2',
123
			'b' => 2,
124
			'c' => 3,
125
			'd' => 4,
126
			'e' => 5,
127
		), true));
128
129
		// Replace & not exist = append
130
		$x = $ar_srce;
131
		ArrayInsert($x, 'f', $ar_ins, 0);
132
		$this->assertEqual(var_export($x, true), var_export(array(
133
			'a' => 1,
134
			'b' => 2,
135
			'c' => 3,
136
			'd' => 4,
137
			'e' => 5,
138
			'ins1'	=> 'ins1',
139
			'ins2'	=> 'ins2',
140
		), true));
141
142
		// Insert far before
143
		$x = $ar_srce;
144
		ArrayInsert($x, 'a', $ar_ins, -10);
145
		$this->assertEqual(var_export($x, true), var_export(array(
146
			'ins1'	=> 'ins1',
147
			'ins2'	=> 'ins2',
148
			'a' => 1,
149
			'b' => 2,
150
			'c' => 3,
151
			'd' => 4,
152
			'e' => 5,
153
		), true));
154
155
		// Insert far after
156
		$x = $ar_srce;
157
		ArrayInsert($x, 'e', $ar_ins, 10);
158
		$this->assertEqual(var_export($x, true), var_export(array(
159
			'a' => 1,
160
			'b' => 2,
161
			'c' => 3,
162
			'd' => 4,
163
			'e' => 5,
164
			'ins1'	=> 'ins1',
165
			'ins2'	=> 'ins2',
166
		), true));
167
	} // end of func TestTestArrayInsert
168
169
170 View Code Duplication
    function TestArrayRead() {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
171
		$ar = array('a' => 1);
172
		$x = ArrayRead($ar, 'a', '2');
173
		$this->assertEqual($x, 1);
174
		$x = ArrayRead($ar, 'b', '2');
175
		$this->assertEqual($x, 2);
176
		$x = ArrayRead($ar, 3);
177
		$this->assertEqual($x, null);
178
    } // end of func TestArrayRead
179
180
181
    function TestFilterWildcard() {
182
		$rule = 'a*, -*b, -??c, +?d*';
183
		$ar_srce = array(
184
			'ab',
185
			'abc',
186
			'adc',
187
		);
188
		$ar = FilterWildcard($ar_srce, $rule);
189
		$this->assertEqual($ar, array('adc'));
190
	} // end of func TestFilterWildcard
191
192
193
} // end of class TestFuncArray
194
195
196
// Change output charset in this way.
197
// {{{
198
$s_url = GetSelfUrl(false);
199
$s_url = substr($s_url, strrpos($s_url, '/') + 1);
200
if ('array.test.php' == $s_url) {
201
	$test = new TestFuncArray();
202
	$test->run(new HtmlReporter('utf-8'));
203
}
204
// }}}
205
?>
206