|
@@ -24,32 +24,32 @@ discard block |
|
|
block discarded – undo |
|
24
|
24
|
* \remarks To run this script as CLI: phpunit filename.php |
|
25
|
25
|
*/ |
|
26
|
26
|
|
|
27
|
|
-global $conf,$user,$langs,$db; |
|
|
27
|
+global $conf, $user, $langs, $db; |
|
28
|
28
|
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
|
29
|
29
|
//require_once 'PHPUnit/Autoload.php'; |
|
30
|
30
|
|
|
31
|
|
-if (! defined('NOREQUIRESOC')) { |
|
|
31
|
+if (!defined('NOREQUIRESOC')) { |
|
32
|
32
|
define('NOREQUIRESOC', '1'); |
|
33
|
33
|
} |
|
34
|
|
-if (! defined('NOCSRFCHECK')) { |
|
|
34
|
+if (!defined('NOCSRFCHECK')) { |
|
35
|
35
|
define('NOCSRFCHECK', '1'); |
|
36
|
36
|
} |
|
37
|
|
-if (! defined('NOTOKENRENEWAL')) { |
|
|
37
|
+if (!defined('NOTOKENRENEWAL')) { |
|
38
|
38
|
define('NOTOKENRENEWAL', '1'); |
|
39
|
39
|
} |
|
40
|
|
-if (! defined('NOREQUIREMENU')) { |
|
|
40
|
+if (!defined('NOREQUIREMENU')) { |
|
41
|
41
|
define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
42
|
42
|
} |
|
43
|
|
-if (! defined('NOREQUIREHTML')) { |
|
|
43
|
+if (!defined('NOREQUIREHTML')) { |
|
44
|
44
|
define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
45
|
45
|
} |
|
46
|
|
-if (! defined('NOREQUIREAJAX')) { |
|
|
46
|
+if (!defined('NOREQUIREAJAX')) { |
|
47
|
47
|
define('NOREQUIREAJAX', '1'); |
|
48
|
48
|
} |
|
49
|
|
-if (! defined("NOLOGIN")) { |
|
50
|
|
- define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
|
49
|
+if (!defined("NOLOGIN")) { |
|
|
50
|
+ define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
51
|
51
|
} |
|
52
|
|
-if (! defined("NOSESSION")) { |
|
|
52
|
+if (!defined("NOSESSION")) { |
|
53
|
53
|
define("NOSESSION", '1'); |
|
54
|
54
|
} |
|
55
|
55
|
|
|
@@ -63,7 +63,7 @@ discard block |
|
|
block discarded – undo |
|
63
|
63
|
$user->fetch(1); |
|
64
|
64
|
$user->getrights(); |
|
65
|
65
|
} |
|
66
|
|
-$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
|
66
|
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
67
|
67
|
|
|
68
|
68
|
|
|
69
|
69
|
/** |
|
@@ -92,11 +92,11 @@ discard block |
|
|
block discarded – undo |
|
92
|
92
|
parent::__construct($name); |
|
93
|
93
|
|
|
94
|
94
|
//$this->sharedFixture |
|
95
|
|
- global $conf,$user,$langs,$db; |
|
96
|
|
- $this->savconf=$conf; |
|
97
|
|
- $this->savuser=$user; |
|
98
|
|
- $this->savlangs=$langs; |
|
99
|
|
- $this->savdb=$db; |
|
|
95
|
+ global $conf, $user, $langs, $db; |
|
|
96
|
+ $this->savconf = $conf; |
|
|
97
|
+ $this->savuser = $user; |
|
|
98
|
+ $this->savlangs = $langs; |
|
|
99
|
+ $this->savdb = $db; |
|
100
|
100
|
|
|
101
|
101
|
print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
|
102
|
102
|
//print " - db ".$db->db; |
|
@@ -110,8 +110,8 @@ discard block |
|
|
block discarded – undo |
|
110
|
110
|
*/ |
|
111
|
111
|
public static function setUpBeforeClass(): void |
|
112
|
112
|
{ |
|
113
|
|
- global $conf,$user,$langs,$db; |
|
114
|
|
- $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
|
113
|
+ global $conf, $user, $langs, $db; |
|
|
114
|
+ $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
115
|
115
|
|
|
116
|
116
|
print __METHOD__."\n"; |
|
117
|
117
|
} |
|
@@ -123,7 +123,7 @@ discard block |
|
|
block discarded – undo |
|
123
|
123
|
*/ |
|
124
|
124
|
public static function tearDownAfterClass(): void |
|
125
|
125
|
{ |
|
126
|
|
- global $conf,$user,$langs,$db; |
|
|
126
|
+ global $conf, $user, $langs, $db; |
|
127
|
127
|
$db->rollback(); |
|
128
|
128
|
|
|
129
|
129
|
// Restore value to a neutral value (it was set to a test value by some tests) |
|
@@ -139,11 +139,11 @@ discard block |
|
|
block discarded – undo |
|
139
|
139
|
*/ |
|
140
|
140
|
protected function setUp(): void |
|
141
|
141
|
{ |
|
142
|
|
- global $conf,$user,$langs,$db; |
|
143
|
|
- $conf=$this->savconf; |
|
144
|
|
- $user=$this->savuser; |
|
145
|
|
- $langs=$this->savlangs; |
|
146
|
|
- $db=$this->savdb; |
|
|
142
|
+ global $conf, $user, $langs, $db; |
|
|
143
|
+ $conf = $this->savconf; |
|
|
144
|
+ $user = $this->savuser; |
|
|
145
|
+ $langs = $this->savlangs; |
|
|
146
|
+ $db = $this->savdb; |
|
147
|
147
|
|
|
148
|
148
|
print __METHOD__."\n"; |
|
149
|
149
|
} |
|
@@ -166,7 +166,7 @@ discard block |
|
|
block discarded – undo |
|
166
|
166
|
public function testSetLang() |
|
167
|
167
|
{ |
|
168
|
168
|
global $conf; |
|
169
|
|
- $conf=$this->savconf; |
|
|
169
|
+ $conf = $this->savconf; |
|
170
|
170
|
|
|
171
|
171
|
$tmplangs = new Translate('', $conf); |
|
172
|
172
|
|
|
@@ -188,7 +188,7 @@ discard block |
|
|
block discarded – undo |
|
188
|
188
|
// More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet |
|
189
|
189
|
|
|
190
|
190
|
// Should be OK |
|
191
|
|
- $expectedresult=0; |
|
|
191
|
+ $expectedresult = 0; |
|
192
|
192
|
|
|
193
|
193
|
/* |
|
194
|
194
|
$test = ''; |
|
@@ -196,107 +196,107 @@ discard block |
|
|
block discarded – undo |
|
196
|
196
|
$this->assertGreaterThanOrEqual(0, $result, 'Error on testSqlAndScriptInject kkk'); |
|
197
|
197
|
*/ |
|
198
|
198
|
|
|
199
|
|
- $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php'; |
|
200
|
|
- $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
|
199
|
+ $_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php'; |
|
|
200
|
+ $result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
201
|
201
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should be ok'); |
|
202
|
202
|
|
|
203
|
203
|
$test = 'This is a < inside string with < and > also and tag like <a> before the >'; |
|
204
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
204
|
+ $result = testSqlAndScriptInject($test, 0); |
|
205
|
205
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0b'); |
|
206
|
206
|
|
|
207
|
207
|
$test = 'This is the union of all for the selection of the best'; |
|
208
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
208
|
+ $result = testSqlAndScriptInject($test, 0); |
|
209
|
209
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0c'); |
|
210
|
210
|
|
|
211
|
|
- $test='/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking'; |
|
212
|
|
- $result=testSqlAndScriptInject($test, 1); |
|
|
211
|
+ $test = '/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking'; |
|
|
212
|
+ $result = testSqlAndScriptInject($test, 1); |
|
213
|
213
|
print "test=".$test." result=".$result."\n"; |
|
214
|
214
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject with a valid url'); |
|
215
|
215
|
|
|
216
|
216
|
// Should detect attack |
|
217
|
|
- $expectedresult=1; |
|
|
217
|
+ $expectedresult = 1; |
|
218
|
218
|
|
|
219
|
|
- $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php/<svg>'; |
|
220
|
|
- $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
|
219
|
+ $_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php/<svg>'; |
|
|
220
|
+ $result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
221
|
221
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should detect XSS'); |
|
222
|
222
|
|
|
223
|
223
|
$test = 'select @@version'; |
|
224
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
224
|
+ $result = testSqlAndScriptInject($test, 0); |
|
225
|
225
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1a. Should find an attack on POST param and did not.'); |
|
226
|
226
|
|
|
227
|
227
|
$test = 'select @@version'; |
|
228
|
|
- $result=testSqlAndScriptInject($test, 1); |
|
|
228
|
+ $result = testSqlAndScriptInject($test, 1); |
|
229
|
229
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1b. Should find an attack on GET param and did not.'); |
|
230
|
230
|
|
|
231
|
231
|
$test = '... update ... set ... ='; |
|
232
|
|
- $result=testSqlAndScriptInject($test, 1); |
|
|
232
|
+ $result = testSqlAndScriptInject($test, 1); |
|
233
|
233
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2a. Should find an attack on GET param and did not.'); |
|
234
|
234
|
|
|
235
|
235
|
$test = "delete\nfrom"; |
|
236
|
|
- $result=testSqlAndScriptInject($test, 1); |
|
|
236
|
+ $result = testSqlAndScriptInject($test, 1); |
|
237
|
237
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2b. Should find an attack on GET param and did not.'); |
|
238
|
238
|
|
|
239
|
239
|
$test = 'action=update& ... set ... ='; |
|
240
|
|
- $result=testSqlAndScriptInject($test, 1); |
|
|
240
|
+ $result = testSqlAndScriptInject($test, 1); |
|
241
|
241
|
$this->assertEquals(0, $result, 'Error on testSqlAndScriptInject for SQL2b. Should not find an attack on GET param and did.'); |
|
242
|
242
|
|
|
243
|
243
|
$test = '... union ... selection '; |
|
244
|
|
- $result=testSqlAndScriptInject($test, 1); |
|
|
244
|
+ $result = testSqlAndScriptInject($test, 1); |
|
245
|
245
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2c. Should find an attack on GET param and did not.'); |
|
246
|
246
|
|
|
247
|
247
|
$test = 'javascript:'; |
|
248
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
248
|
+ $result = testSqlAndScriptInject($test, 0); |
|
249
|
249
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript1. Should find an attack and did not.'); |
|
250
|
250
|
|
|
251
|
251
|
$test = 'javascript:'; |
|
252
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
252
|
+ $result = testSqlAndScriptInject($test, 0); |
|
253
|
253
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2. Should find an attack and did not.'); |
|
254
|
254
|
|
|
255
|
255
|
$test = 'javascript&colon;alert(1)'; |
|
256
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
256
|
+ $result = testSqlAndScriptInject($test, 0); |
|
257
|
257
|
$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2'); |
|
258
|
258
|
|
|
259
|
|
- $test="<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
260
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
259
|
+ $test = "<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
|
260
|
+ $result = testSqlAndScriptInject($test, 0); |
|
261
|
261
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa1'); |
|
262
|
262
|
|
|
263
|
|
- $test="<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
264
|
|
- $result=testSqlAndScriptInject($test, 2); |
|
|
263
|
+ $test = "<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
|
264
|
+ $result = testSqlAndScriptInject($test, 2); |
|
265
|
265
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa2'); |
|
266
|
266
|
|
|
267
|
|
- $test='<IMG SRC=# onmouseover="alert(1)">'; |
|
268
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
267
|
+ $test = '<IMG SRC=# onmouseover="alert(1)">'; |
|
|
268
|
+ $result = testSqlAndScriptInject($test, 0); |
|
269
|
269
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa3'); |
|
270
|
|
- $test='<IMG SRC onmouseover="alert(1)">'; |
|
271
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
270
|
+ $test = '<IMG SRC onmouseover="alert(1)">'; |
|
|
271
|
+ $result = testSqlAndScriptInject($test, 0); |
|
272
|
272
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa4'); |
|
273
|
|
- $test='<IMG onmouseover="alert(1)">'; |
|
274
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
273
|
+ $test = '<IMG onmouseover="alert(1)">'; |
|
|
274
|
+ $result = testSqlAndScriptInject($test, 0); |
|
275
|
275
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa5'); |
|
276
|
|
- $test='<IMG SRC=/ onerror="alert(1)">'; |
|
277
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
276
|
+ $test = '<IMG SRC=/ onerror="alert(1)">'; |
|
|
277
|
+ $result = testSqlAndScriptInject($test, 0); |
|
278
|
278
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa6'); |
|
279
|
|
- $test='<IMG SRC="  javascript:alert(1);">'; |
|
280
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
279
|
+ $test = '<IMG SRC="  javascript:alert(1);">'; |
|
|
280
|
+ $result = testSqlAndScriptInject($test, 0); |
|
281
|
281
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7'); |
|
282
|
282
|
|
|
283
|
|
- $test='<IMG SRC=javascript:alert('XSS')>'; |
|
284
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
283
|
+ $test = '<IMG SRC=javascript:alert('XSS')>'; |
|
|
284
|
+ $result = testSqlAndScriptInject($test, 0); |
|
285
|
285
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb'); |
|
286
|
286
|
|
|
287
|
|
- $test='<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>'; |
|
288
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
287
|
+ $test = '<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>'; |
|
|
288
|
+ $result = testSqlAndScriptInject($test, 0); |
|
289
|
289
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ccc'); |
|
290
|
290
|
|
|
291
|
|
- $test='<IMG SRC="javascript:alert(\'XSS\');">'; |
|
292
|
|
- $result=testSqlAndScriptInject($test, 1); |
|
|
291
|
+ $test = '<IMG SRC="javascript:alert(\'XSS\');">'; |
|
|
292
|
+ $result = testSqlAndScriptInject($test, 1); |
|
293
|
293
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ddd'); |
|
294
|
294
|
|
|
295
|
|
- $test='<IMG """><SCRIPT>alert("XSS")</SCRIPT>">'; |
|
296
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
295
|
+ $test = '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">'; |
|
|
296
|
+ $result = testSqlAndScriptInject($test, 0); |
|
297
|
297
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); |
|
298
|
298
|
|
|
299
|
|
- $test='<!-- Google analytics --> |
|
|
299
|
+ $test = '<!-- Google analytics --> |
|
300
|
300
|
<script> |
|
301
|
301
|
(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){ |
|
302
|
302
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
|
@@ -307,60 +307,60 @@ discard block |
|
|
block discarded – undo |
|
307
|
307
|
ga(\'send\', \'pageview\'); |
|
308
|
308
|
|
|
309
|
309
|
</script>'; |
|
310
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
310
|
+ $result = testSqlAndScriptInject($test, 0); |
|
311
|
311
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); |
|
312
|
312
|
|
|
313
|
|
- $test="<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. |
|
314
|
|
- $test="<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same |
|
|
313
|
+ $test = "<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. |
|
|
314
|
+ $test = "<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same |
|
315
|
315
|
|
|
316
|
|
- $test='<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
317
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
316
|
+ $test = '<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
|
317
|
+ $result = testSqlAndScriptInject($test, 0); |
|
318
|
318
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff1'); |
|
319
|
|
- $test='<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
320
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
319
|
+ $test = '<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
|
320
|
+ $result = testSqlAndScriptInject($test, 0); |
|
321
|
321
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff2'); |
|
322
|
322
|
|
|
323
|
323
|
// This case seems to be filtered by browsers now. |
|
324
|
|
- $test='<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>'; |
|
|
324
|
+ $test = '<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>'; |
|
325
|
325
|
//$result=testSqlAndScriptInject($test, 0); |
|
326
|
326
|
//$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ggg'); |
|
327
|
327
|
|
|
328
|
|
- $test='<iframe src=http://xss.rocks/scriptlet.html <'; |
|
329
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
328
|
+ $test = '<iframe src=http://xss.rocks/scriptlet.html <'; |
|
|
329
|
+ $result = testSqlAndScriptInject($test, 0); |
|
330
|
330
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject hhh'); |
|
331
|
331
|
|
|
332
|
|
- $test='Set.constructor`alert\x281\x29```'; |
|
333
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
332
|
+ $test = 'Set.constructor`alert\x281\x29```'; |
|
|
333
|
+ $result = testSqlAndScriptInject($test, 0); |
|
334
|
334
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject iii'); |
|
335
|
335
|
|
|
336
|
|
- $test="on<!-- ab\nc -->error=alert(1)"; |
|
337
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
336
|
+ $test = "on<!-- ab\nc -->error=alert(1)"; |
|
|
337
|
+ $result = testSqlAndScriptInject($test, 0); |
|
338
|
338
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject jjj'); |
|
339
|
339
|
|
|
340
|
|
- $test="<img src=x one<a>rror=alert(document.location)"; |
|
341
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
340
|
+ $test = "<img src=x one<a>rror=alert(document.location)"; |
|
|
341
|
+ $result = testSqlAndScriptInject($test, 0); |
|
342
|
342
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject kkk'); |
|
343
|
343
|
|
|
344
|
|
- $test="<a onpointerdown=alert(document.domain)>XSS</a>"; |
|
345
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
344
|
+ $test = "<a onpointerdown=alert(document.domain)>XSS</a>"; |
|
|
345
|
+ $result = testSqlAndScriptInject($test, 0); |
|
346
|
346
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject lll'); |
|
347
|
347
|
|
|
348
|
|
- $test='<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable |
|
349
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
348
|
+ $test = '<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable |
|
|
349
|
+ $result = testSqlAndScriptInject($test, 0); |
|
350
|
350
|
//print "test=".$test." result=".$result."\n"; |
|
351
|
351
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject mmm'); |
|
352
|
352
|
|
|
353
|
353
|
|
|
354
|
|
- $test="Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
355
|
|
- $result=testSqlAndScriptInject($test, 0); // result must be 0 |
|
|
354
|
+ $test = "Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
|
355
|
+ $result = testSqlAndScriptInject($test, 0); // result must be 0 |
|
356
|
356
|
$this->assertEquals(0, $result, 'Error on testSqlAndScriptInject mmm, result should be 0 and is not'); |
|
357
|
357
|
|
|
358
|
|
- $test ='<a href="j	a	v	asc
ri	pt:(a	l	e	r	t	(document.cookie))">XSS</a>'; |
|
359
|
|
- $result=testSqlAndScriptInject($test, 0); |
|
|
358
|
+ $test = '<a href="j	a	v	asc
ri	pt:(a	l	e	r	t	(document.cookie))">XSS</a>'; |
|
|
359
|
+ $result = testSqlAndScriptInject($test, 0); |
|
360
|
360
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject nnn, result should be >= 1 and is not'); |
|
361
|
361
|
|
|
362
|
|
- $test="/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable |
|
363
|
|
- $result=testSqlAndScriptInject($test, 2); |
|
|
362
|
+ $test = "/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable |
|
|
363
|
+ $result = testSqlAndScriptInject($test, 2); |
|
364
|
364
|
//print "test=".$test." result=".$result."\n"; |
|
365
|
365
|
$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject with a non valid UTF8 char'); |
|
366
|
366
|
} |
|
@@ -372,217 +372,217 @@ discard block |
|
|
block discarded – undo |
|
372
|
372
|
*/ |
|
373
|
373
|
public function testGETPOST() |
|
374
|
374
|
{ |
|
375
|
|
- global $conf,$user,$langs,$db; |
|
376
|
|
- $conf=$this->savconf; |
|
377
|
|
- $user=$this->savuser; |
|
378
|
|
- $langs=$this->savlangs; |
|
379
|
|
- $db=$this->savdb; |
|
|
375
|
+ global $conf, $user, $langs, $db; |
|
|
376
|
+ $conf = $this->savconf; |
|
|
377
|
+ $user = $this->savuser; |
|
|
378
|
+ $langs = $this->savlangs; |
|
|
379
|
+ $db = $this->savdb; |
|
380
|
380
|
|
|
381
|
381
|
// Force default mode |
|
382
|
382
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; |
|
383
|
383
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0; |
|
384
|
384
|
$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; |
|
385
|
385
|
|
|
386
|
|
- $_COOKIE["id"]=111; |
|
387
|
|
- $_POST["param0"]='A real string with <a href="rrr" title="aa"bb">aaa</a> and " and \' and & inside content'; |
|
388
|
|
- $_GET["param1"]="222"; |
|
389
|
|
- $_POST["param1"]="333"; |
|
390
|
|
- $_GET["param2"]='a/b#e(pr)qq-rr\cc'; |
|
391
|
|
- $_GET["param3"]='"na/b#e(pr)qq-rr\cc'; // Same than param2 + " and n |
|
392
|
|
- $_GET["param4a"]='../../dir'; |
|
393
|
|
- $_GET["param4b"]='..\..\dirwindows'; |
|
394
|
|
- $_GET["param5"]="a_1-b"; |
|
395
|
|
- $_POST["param6"]=""><svg onload='console.log("123")'>"; |
|
396
|
|
- $_POST["param6b"]='<<<../>../>../svg><<<../>../>../animate =alert(1)>abc'; |
|
397
|
|
- $_GET["param7"]='"c:\this is a path~1\aaan &#x110;" abc<bad>def</bad>'; |
|
398
|
|
- $_POST["param8a"]="Hacker<svg onload='console.log("123")'"; // html tag is not closed so it is not detected as html tag but is still harmfull |
|
399
|
|
- $_POST['param8b']='<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag |
|
400
|
|
- $_POST['param8c']='< with space after is ok'; |
|
401
|
|
- $_POST['param8d']='<abc123 is html to clean'; |
|
402
|
|
- $_POST['param8e']='<123abc is not html to clean'; // other similar case: '<2021-12-12' |
|
403
|
|
- $_POST['param8f']='abc<<svg <><<animate onbegin=alert(document.domain) a'; |
|
404
|
|
- $_POST["param9"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\''; |
|
405
|
|
- $_POST["param10"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\''; |
|
406
|
|
- $_POST["param11"]=' Name <[email protected]> '; |
|
407
|
|
- $_POST["param12"]='<!DOCTYPE html><html>aaa</html>'; |
|
408
|
|
- $_POST["param13"]='n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
409
|
|
- $_POST["param13b"]='n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
410
|
|
- $_POST["param14"]="Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
411
|
|
- $_POST["param15"]="<img onerror<=alert(document.domain)> src=>0xbeefed"; |
|
|
386
|
+ $_COOKIE["id"] = 111; |
|
|
387
|
+ $_POST["param0"] = 'A real string with <a href="rrr" title="aa"bb">aaa</a> and " and \' and & inside content'; |
|
|
388
|
+ $_GET["param1"] = "222"; |
|
|
389
|
+ $_POST["param1"] = "333"; |
|
|
390
|
+ $_GET["param2"] = 'a/b#e(pr)qq-rr\cc'; |
|
|
391
|
+ $_GET["param3"] = '"na/b#e(pr)qq-rr\cc'; // Same than param2 + " and n |
|
|
392
|
+ $_GET["param4a"] = '../../dir'; |
|
|
393
|
+ $_GET["param4b"] = '..\..\dirwindows'; |
|
|
394
|
+ $_GET["param5"] = "a_1-b"; |
|
|
395
|
+ $_POST["param6"] = ""><svg onload='console.log("123")'>"; |
|
|
396
|
+ $_POST["param6b"] = '<<<../>../>../svg><<<../>../>../animate =alert(1)>abc'; |
|
|
397
|
+ $_GET["param7"] = '"c:\this is a path~1\aaan &#x110;" abc<bad>def</bad>'; |
|
|
398
|
+ $_POST["param8a"] = "Hacker<svg onload='console.log("123")'"; // html tag is not closed so it is not detected as html tag but is still harmfull |
|
|
399
|
+ $_POST['param8b'] = '<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag |
|
|
400
|
+ $_POST['param8c'] = '< with space after is ok'; |
|
|
401
|
+ $_POST['param8d'] = '<abc123 is html to clean'; |
|
|
402
|
+ $_POST['param8e'] = '<123abc is not html to clean'; // other similar case: '<2021-12-12' |
|
|
403
|
+ $_POST['param8f'] = 'abc<<svg <><<animate onbegin=alert(document.domain) a'; |
|
|
404
|
+ $_POST["param9"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\''; |
|
|
405
|
+ $_POST["param10"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\''; |
|
|
406
|
+ $_POST["param11"] = ' Name <[email protected]> '; |
|
|
407
|
+ $_POST["param12"] = '<!DOCTYPE html><html>aaa</html>'; |
|
|
408
|
+ $_POST["param13"] = 'n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
|
409
|
+ $_POST["param13b"] = 'n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
|
410
|
+ $_POST["param14"] = "Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
|
411
|
+ $_POST["param15"] = "<img onerror<=alert(document.domain)> src=>0xbeefed"; |
|
412
|
412
|
//$_POST["param15b"]="<html><head><title>Example HTML</title></head><body><div><p>This is a paragraph.</div><ul><li>Item 1</li><li>Item 2</li></ol></body><html>"; |
|
413
|
|
- $_POST["param16"]='<a style="z-index: 1000">abc</a>'; |
|
414
|
|
- $_POST["param17"]='<span style="background-image: url(logout.php)">abc</span>'; |
|
415
|
|
- $_POST["param18"]='<span style="background-image: url(...?...action=aaa)">abc</span>'; |
|
416
|
|
- $_POST["param19"]='<a href="j	a	v	asc
ri	pt:(alert(document.cookie))">XSS</a>'; |
|
|
413
|
+ $_POST["param16"] = '<a style="z-index: 1000">abc</a>'; |
|
|
414
|
+ $_POST["param17"] = '<span style="background-image: url(logout.php)">abc</span>'; |
|
|
415
|
+ $_POST["param18"] = '<span style="background-image: url(...?...action=aaa)">abc</span>'; |
|
|
416
|
+ $_POST["param19"] = '<a href="j	a	v	asc
ri	pt:(alert(document.cookie))">XSS</a>'; |
|
417
|
417
|
//$_POST["param19"]='<a href="javascript:alert(document.cookie)">XSS</a>'; |
|
418
|
418
|
|
|
419
|
419
|
|
|
420
|
420
|
|
|
421
|
|
- $result=GETPOST('id', 'int'); // Must return nothing |
|
|
421
|
+ $result = GETPOST('id', 'int'); // Must return nothing |
|
422
|
422
|
print __METHOD__." result=".$result."\n"; |
|
423
|
423
|
$this->assertEquals('', $result); |
|
424
|
424
|
|
|
425
|
|
- $result=GETPOST("param1", 'int'); |
|
|
425
|
+ $result = GETPOST("param1", 'int'); |
|
426
|
426
|
print __METHOD__." result=".$result."\n"; |
|
427
|
427
|
$this->assertEquals(222, $result, 'Test on param1 with no 3rd param'); |
|
428
|
428
|
|
|
429
|
|
- $result=GETPOST("param1", 'int', 2); |
|
|
429
|
+ $result = GETPOST("param1", 'int', 2); |
|
430
|
430
|
print __METHOD__." result=".$result."\n"; |
|
431
|
431
|
$this->assertEquals(333, $result, 'Test on param1 with 3rd param = 2'); |
|
432
|
432
|
|
|
433
|
433
|
// Test with alpha |
|
434
|
434
|
|
|
435
|
|
- $result=GETPOST("param0", 'alpha'); // a simple format, so " completely removed |
|
|
435
|
+ $result = GETPOST("param0", 'alpha'); // a simple format, so " completely removed |
|
436
|
436
|
$resultexpected = 'A real string with aaa and and \' and & inside content'; |
|
437
|
437
|
print __METHOD__." result=".$result."\n"; |
|
438
|
438
|
$this->assertEquals($resultexpected, $result, 'Test on param0'); |
|
439
|
439
|
|
|
440
|
|
- $result=GETPOST("param2", 'alpha'); |
|
|
440
|
+ $result = GETPOST("param2", 'alpha'); |
|
441
|
441
|
print __METHOD__." result=".$result."\n"; |
|
442
|
442
|
$this->assertEquals($result, $_GET["param2"], 'Test on param2'); |
|
443
|
443
|
|
|
444
|
|
- $result=GETPOST("param3", 'alpha'); // Must return string sanitized from char " |
|
|
444
|
+ $result = GETPOST("param3", 'alpha'); // Must return string sanitized from char " |
|
445
|
445
|
print __METHOD__." result=".$result."\n"; |
|
446
|
446
|
$this->assertEquals($result, 'na/b#e(pr)qq-rr\cc', 'Test on param3'); |
|
447
|
447
|
|
|
448
|
|
- $result=GETPOST("param4a", 'alpha'); // Must return string sanitized from ../ |
|
|
448
|
+ $result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../ |
|
449
|
449
|
print __METHOD__." result=".$result."\n"; |
|
450
|
450
|
$this->assertEquals($result, 'dir'); |
|
451
|
451
|
|
|
452
|
|
- $result=GETPOST("param4b", 'alpha'); // Must return string sanitized from ../ |
|
|
452
|
+ $result = GETPOST("param4b", 'alpha'); // Must return string sanitized from ../ |
|
453
|
453
|
print __METHOD__." result=".$result."\n"; |
|
454
|
454
|
$this->assertEquals($result, 'dirwindows'); |
|
455
|
455
|
|
|
456
|
456
|
// Test with aZ09 |
|
457
|
457
|
|
|
458
|
|
- $result=GETPOST("param1", 'aZ09'); |
|
|
458
|
+ $result = GETPOST("param1", 'aZ09'); |
|
459
|
459
|
print __METHOD__." result=".$result."\n"; |
|
460
|
460
|
$this->assertEquals($result, $_GET["param1"]); |
|
461
|
461
|
|
|
462
|
|
- $result=GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
|
462
|
+ $result = GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
463
|
463
|
print __METHOD__." result=".$result."\n"; |
|
464
|
464
|
$this->assertEquals($result, ''); |
|
465
|
465
|
|
|
466
|
|
- $result=GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
|
466
|
+ $result = GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
467
|
467
|
print __METHOD__." result=".$result."\n"; |
|
468
|
468
|
$this->assertEquals($result, ''); |
|
469
|
469
|
|
|
470
|
|
- $result=GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
|
470
|
+ $result = GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
471
|
471
|
print __METHOD__." result=".$result."\n"; |
|
472
|
472
|
$this->assertEquals('', $result); |
|
473
|
473
|
|
|
474
|
|
- $result=GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
|
474
|
+ $result = GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
475
|
475
|
print __METHOD__." result=".$result."\n"; |
|
476
|
476
|
$this->assertEquals('', $result); |
|
477
|
477
|
|
|
478
|
|
- $result=GETPOST("param5", 'aZ09'); |
|
|
478
|
+ $result = GETPOST("param5", 'aZ09'); |
|
479
|
479
|
print __METHOD__." result=".$result."\n"; |
|
480
|
480
|
$this->assertEquals($_GET["param5"], $result); |
|
481
|
481
|
|
|
482
|
482
|
// Test with nohtml |
|
483
|
483
|
|
|
484
|
|
- $result=GETPOST("param6", 'nohtml'); |
|
|
484
|
+ $result = GETPOST("param6", 'nohtml'); |
|
485
|
485
|
print __METHOD__." result6=".$result."\n"; |
|
486
|
486
|
$this->assertEquals('">', $result); |
|
487
|
487
|
|
|
488
|
488
|
// Test with alpha = alphanohtml. We must convert the html entities like n and disable all entities |
|
489
|
489
|
|
|
490
|
|
- $result=GETPOST("param6", 'alphanohtml'); |
|
|
490
|
+ $result = GETPOST("param6", 'alphanohtml'); |
|
491
|
491
|
print __METHOD__." result=".$result."\n"; |
|
492
|
492
|
$this->assertEquals('>', $result); |
|
493
|
493
|
|
|
494
|
|
- $result=GETPOST("param6b", 'alphanohtml'); |
|
|
494
|
+ $result = GETPOST("param6b", 'alphanohtml'); |
|
495
|
495
|
print __METHOD__." result=".$result."\n"; |
|
496
|
496
|
$this->assertEquals('abc', $result); |
|
497
|
497
|
|
|
498
|
|
- $result=GETPOST("param8a", 'alphanohtml'); |
|
|
498
|
+ $result = GETPOST("param8a", 'alphanohtml'); |
|
499
|
499
|
print __METHOD__." result=".$result."\n"; |
|
500
|
500
|
$this->assertEquals("Hackersvg onload='console.log(123)'", $result); |
|
501
|
501
|
|
|
502
|
|
- $result=GETPOST("param8b", 'alphanohtml'); |
|
|
502
|
+ $result = GETPOST("param8b", 'alphanohtml'); |
|
503
|
503
|
print __METHOD__." result=".$result."\n"; |
|
504
|
504
|
$this->assertEquals('img src=x onerror=alert(document.location) t=', $result, 'Test a string with non closing html tag with alphanohtml'); |
|
505
|
505
|
|
|
506
|
|
- $result=GETPOST("param8c", 'alphanohtml'); |
|
|
506
|
+ $result = GETPOST("param8c", 'alphanohtml'); |
|
507
|
507
|
print __METHOD__." result=".$result."\n"; |
|
508
|
508
|
$this->assertEquals($_POST['param8c'], $result, 'Test a string with non closing html tag with alphanohtml'); |
|
509
|
509
|
|
|
510
|
|
- $result=GETPOST("param8d", 'alphanohtml'); |
|
|
510
|
+ $result = GETPOST("param8d", 'alphanohtml'); |
|
511
|
511
|
print __METHOD__." result=".$result."\n"; |
|
512
|
512
|
$this->assertEquals('abc123 is html to clean', $result, 'Test a string with non closing html tag with alphanohtml'); |
|
513
|
513
|
|
|
514
|
|
- $result=GETPOST("param8e", 'alphanohtml'); |
|
|
514
|
+ $result = GETPOST("param8e", 'alphanohtml'); |
|
515
|
515
|
print __METHOD__." result=".$result."\n"; |
|
516
|
516
|
$this->assertEquals($_POST['param8e'], $result, 'Test a string with non closing html tag with alphanohtml'); |
|
517
|
517
|
|
|
518
|
|
- $result=GETPOST("param8f", 'alphanohtml'); |
|
|
518
|
+ $result = GETPOST("param8f", 'alphanohtml'); |
|
519
|
519
|
print __METHOD__." result=".$result."\n"; |
|
520
|
520
|
$this->assertEquals('abcsvg animate onbegin=alert(document.domain) a', $result, 'Test a string with html tag open with several <'); |
|
521
|
521
|
|
|
522
|
|
- $result=GETPOST("param9", 'alphanohtml'); |
|
|
522
|
+ $result = GETPOST("param9", 'alphanohtml'); |
|
523
|
523
|
print __METHOD__." result=".$result."\n"; |
|
524
|
524
|
$this->assertEquals($_POST["param9"], $result); |
|
525
|
525
|
|
|
526
|
|
- $result=GETPOST("param10", 'alphanohtml'); |
|
|
526
|
+ $result = GETPOST("param10", 'alphanohtml'); |
|
527
|
527
|
print __METHOD__." result=".$result."\n"; |
|
528
|
528
|
$this->assertEquals($_POST["param9"], $result, 'We should get param9 after processing param10'); |
|
529
|
529
|
|
|
530
|
|
- $result=GETPOST("param11", 'alphanohtml'); |
|
|
530
|
+ $result = GETPOST("param11", 'alphanohtml'); |
|
531
|
531
|
print __METHOD__." result=".$result."\n"; |
|
532
|
532
|
$this->assertEquals("Name", $result, 'Test an email string with alphanohtml'); |
|
533
|
533
|
|
|
534
|
|
- $result=GETPOST("param13", 'alphanohtml'); |
|
|
534
|
+ $result = GETPOST("param13", 'alphanohtml'); |
|
535
|
535
|
print __METHOD__." result=".$result."\n"; |
|
536
|
536
|
$this->assertEquals('n n > < XSS', $result, 'Test that html entities are decoded with alpha'); |
|
537
|
537
|
|
|
538
|
538
|
|
|
539
|
539
|
// Test with alphawithlgt |
|
540
|
540
|
|
|
541
|
|
- $result=GETPOST("param11", 'alphawithlgt'); |
|
|
541
|
+ $result = GETPOST("param11", 'alphawithlgt'); |
|
542
|
542
|
print __METHOD__." result=".$result."\n"; |
|
543
|
543
|
$this->assertEquals(trim($_POST["param11"]), $result, 'Test an email string with alphawithlgt'); |
|
544
|
544
|
|
|
545
|
545
|
|
|
546
|
546
|
// Test with restricthtml: we must remove html open/close tag and content but not htmlentities (we can decode html entities for ascii chars like n) |
|
547
|
547
|
|
|
548
|
|
- $result=GETPOST("param0", 'restricthtml'); |
|
|
548
|
+ $result = GETPOST("param0", 'restricthtml'); |
|
549
|
549
|
$resultexpected = 'A real string with <a href="rrr" title="aa"bb">aaa</a> and " and \' and & inside content'; |
|
550
|
550
|
print __METHOD__." result=".$result."\n"; |
|
551
|
551
|
$this->assertEquals($resultexpected, $result, 'Test on param0'); |
|
552
|
552
|
|
|
553
|
|
- $result=GETPOST("param6", 'restricthtml'); |
|
|
553
|
+ $result = GETPOST("param6", 'restricthtml'); |
|
554
|
554
|
print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
|
555
|
555
|
$this->assertEquals('">', $result); |
|
556
|
556
|
|
|
557
|
|
- $result=GETPOST("param7", 'restricthtml'); |
|
|
557
|
+ $result = GETPOST("param7", 'restricthtml'); |
|
558
|
558
|
print __METHOD__." result param7 = ".$result."\n"; |
|
559
|
559
|
$this->assertEquals('"c:\this is a path~1\aaan &#x;;;;" abcdef', $result); |
|
560
|
560
|
|
|
561
|
|
- $result=GETPOST("param8e", 'restricthtml'); |
|
|
561
|
+ $result = GETPOST("param8e", 'restricthtml'); |
|
562
|
562
|
print __METHOD__." result param8e = ".$result."\n"; |
|
563
|
563
|
$this->assertEquals('', $result); |
|
564
|
564
|
|
|
565
|
|
- $result=GETPOST("param12", 'restricthtml'); |
|
|
565
|
+ $result = GETPOST("param12", 'restricthtml'); |
|
566
|
566
|
print __METHOD__." result=".$result."\n"; |
|
567
|
567
|
$this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml'); |
|
568
|
568
|
|
|
569
|
|
- $result=GETPOST("param13", 'restricthtml'); |
|
|
569
|
+ $result = GETPOST("param13", 'restricthtml'); |
|
570
|
570
|
print __METHOD__." result=".$result."\n"; |
|
571
|
571
|
$this->assertEquals('n n > < " <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13 that HTML entities are decoded with restricthtml, but only for common alpha chars'); |
|
572
|
572
|
|
|
573
|
|
- $result=GETPOST("param13b", 'restricthtml'); |
|
|
573
|
+ $result = GETPOST("param13b", 'restricthtml'); |
|
574
|
574
|
print __METHOD__." result=".$result."\n"; |
|
575
|
575
|
$this->assertEquals('n n > < " <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13b that HTML entities are decoded with restricthtml, but only for common alpha chars'); |
|
576
|
576
|
|
|
577
|
|
- $result=GETPOST("param14", 'restricthtml'); |
|
|
577
|
+ $result = GETPOST("param14", 'restricthtml'); |
|
578
|
578
|
print __METHOD__." result=".$result."\n"; |
|
579
|
579
|
$this->assertEquals("Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)", $result, 'Test 14'); |
|
580
|
580
|
|
|
581
|
|
- $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
|
581
|
+ $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
582
|
582
|
print __METHOD__." result=".$result."\n"; |
|
583
|
|
- $this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string |
|
|
583
|
+ $this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string |
|
584
|
584
|
|
|
585
|
|
- $result=GETPOST("param19", 'restricthtml'); |
|
|
585
|
+ $result = GETPOST("param19", 'restricthtml'); |
|
586
|
586
|
print __METHOD__." result=".$result."\n"; |
|
587
|
587
|
$this->assertEquals('<a href="(alert(document.cookie))">XSS</a>', $result, 'Test 19'); |
|
588
|
588
|
|
|
@@ -593,22 +593,22 @@ discard block |
|
|
block discarded – undo |
|
593
|
593
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0; |
|
594
|
594
|
|
|
595
|
595
|
//$_POST["param0"] = 'A real string with <a href="rrr" title="aabb">aaa</a> and " inside content'; |
|
596
|
|
- $result=GETPOST("param0", 'restricthtml'); |
|
|
596
|
+ $result = GETPOST("param0", 'restricthtml'); |
|
597
|
597
|
$resultexpected = 'A real string with <a href="rrr" title=\'aa"bb\'>aaa</a> and " and \' and & inside content'; |
|
598
|
598
|
print __METHOD__." result for param0=".$result."\n"; |
|
599
|
599
|
$this->assertEquals($resultexpected, $result, 'Test on param0'); |
|
600
|
600
|
|
|
601
|
|
- $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
|
601
|
+ $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
602
|
602
|
print __METHOD__." result for param15=".$result."\n"; |
|
603
|
603
|
//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
|
604
|
604
|
//$this->assertEquals('<img onerror> src=>0xbeefed', $result, 'Test 15b'); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
|
605
|
605
|
|
|
606
|
|
- $result=GETPOST("param6", 'restricthtml'); // param6 = ""><svg onload='console.log("123")'>" |
|
|
606
|
+ $result = GETPOST("param6", 'restricthtml'); // param6 = ""><svg onload='console.log("123")'>" |
|
607
|
607
|
print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
|
608
|
608
|
//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
|
609
|
609
|
//$this->assertEquals('">', $result); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
|
610
|
610
|
|
|
611
|
|
- $result=GETPOST("param7", 'restricthtml'); // param7 = "c:\this is a path~1\aaan &#x110;" abc<bad>def</bad> |
|
|
611
|
+ $result = GETPOST("param7", 'restricthtml'); // param7 = "c:\this is a path~1\aaan &#x110;" abc<bad>def</bad> |
|
612
|
612
|
print __METHOD__." result param7 = ".$result."\n"; |
|
613
|
613
|
//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
|
614
|
614
|
//$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
|
@@ -620,19 +620,19 @@ discard block |
|
|
block discarded – undo |
|
620
|
620
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; |
|
621
|
621
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; |
|
622
|
622
|
|
|
623
|
|
- $result=GETPOST("param0", 'restricthtml'); |
|
|
623
|
+ $result = GETPOST("param0", 'restricthtml'); |
|
624
|
624
|
$resultexpected = 'A real string with <a href="rrr" title="aa"bb">aaa</a> and " and \' and & inside content'; |
|
625
|
625
|
print __METHOD__." result for param0=".$result."\n"; |
|
626
|
626
|
$this->assertEquals($resultexpected, $result, 'Test on param0'); |
|
627
|
627
|
|
|
628
|
|
- $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
|
628
|
+ $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
629
|
629
|
print __METHOD__." result=".$result."\n"; |
|
630
|
630
|
|
|
631
|
|
- $result=GETPOST("param6", 'restricthtml'); |
|
|
631
|
+ $result = GETPOST("param6", 'restricthtml'); |
|
632
|
632
|
print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
|
633
|
633
|
$this->assertEquals('">', $result); |
|
634
|
634
|
|
|
635
|
|
- $result=GETPOST("param7", 'restricthtml'); |
|
|
635
|
+ $result = GETPOST("param7", 'restricthtml'); |
|
636
|
636
|
print __METHOD__." result param7 = ".$result."\n"; |
|
637
|
637
|
$this->assertEquals('"c:\this is a path~1\aaan &#x110;" abcdef', $result); |
|
638
|
638
|
} |
|
@@ -644,19 +644,19 @@ discard block |
|
|
block discarded – undo |
|
644
|
644
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1; |
|
645
|
645
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; |
|
646
|
646
|
|
|
647
|
|
- $result=GETPOST("param0", 'restricthtml'); |
|
|
647
|
+ $result = GETPOST("param0", 'restricthtml'); |
|
648
|
648
|
$resultexpected = 'A real string with <a href="rrr" title=\'aa"bb\'>aaa</a> and " and \' and & inside content'; |
|
649
|
649
|
print __METHOD__." result for param0=".$result."\n"; |
|
650
|
650
|
$this->assertEquals($resultexpected, $result, 'Test on param0'); |
|
651
|
651
|
|
|
652
|
|
- $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
|
652
|
+ $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
653
|
653
|
print __METHOD__." result=".$result."\n"; |
|
654
|
654
|
|
|
655
|
|
- $result=GETPOST("param6", 'restricthtml'); |
|
|
655
|
+ $result = GETPOST("param6", 'restricthtml'); |
|
656
|
656
|
print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
|
657
|
657
|
$this->assertEquals('">', $result); |
|
658
|
658
|
|
|
659
|
|
- $result=GETPOST("param7", 'restricthtml'); |
|
|
659
|
+ $result = GETPOST("param7", 'restricthtml'); |
|
660
|
660
|
print __METHOD__." result param7 = ".$result."\n"; |
|
661
|
661
|
$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result); |
|
662
|
662
|
} |
|
@@ -668,19 +668,19 @@ discard block |
|
|
block discarded – undo |
|
668
|
668
|
unset($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY); |
|
669
|
669
|
$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1; |
|
670
|
670
|
|
|
671
|
|
- $result=GETPOST("param15", 'restricthtml'); |
|
|
671
|
+ $result = GETPOST("param15", 'restricthtml'); |
|
672
|
672
|
print __METHOD__." result=".$result."\n"; |
|
673
|
673
|
$this->assertEquals('<img src="">0xbeefed', $result, 'Test 15c'); |
|
674
|
674
|
|
|
675
|
|
- $result=GETPOST('param16', 'restricthtml'); |
|
|
675
|
+ $result = GETPOST('param16', 'restricthtml'); |
|
676
|
676
|
print __METHOD__." result=".$result."\n"; |
|
677
|
677
|
$this->assertEquals('<a style=" 1000">abc</a>', $result, 'Test tag a with forbidden attribute z-index'); |
|
678
|
678
|
|
|
679
|
|
- $result=GETPOST('param17', 'restricthtml'); |
|
|
679
|
+ $result = GETPOST('param17', 'restricthtml'); |
|
680
|
680
|
print __METHOD__." result=".$result."\n"; |
|
681
|
681
|
$this->assertEquals('<span style="background-image: url()">abc</span>', $result, 'Test anytag with a forbidden value for attribute'); |
|
682
|
682
|
|
|
683
|
|
- $result=GETPOST('param18', 'restricthtml'); |
|
|
683
|
+ $result = GETPOST('param18', 'restricthtml'); |
|
684
|
684
|
print __METHOD__." result=".$result."\n"; |
|
685
|
685
|
$this->assertEquals('<span style="background-image: url(...?...aaa)">abc</span>', $result, 'Test anytag with a forbidden value for attribute'); |
|
686
|
686
|
|
|
@@ -689,54 +689,54 @@ discard block |
|
|
block discarded – undo |
|
689
|
689
|
|
|
690
|
690
|
// Special test for GETPOST of backtopage, backtolist or backtourl parameter |
|
691
|
691
|
|
|
692
|
|
- $_POST["backtopage"]='//www.google.com'; |
|
693
|
|
- $result=GETPOST("backtopage"); |
|
|
692
|
+ $_POST["backtopage"] = '//www.google.com'; |
|
|
693
|
+ $result = GETPOST("backtopage"); |
|
694
|
694
|
print __METHOD__." result=".$result."\n"; |
|
695
|
695
|
$this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
|
696
|
696
|
|
|
697
|
|
- $_POST["backtopage"]='https:https://www.google.com'; |
|
698
|
|
- $result=GETPOST("backtopage"); |
|
|
697
|
+ $_POST["backtopage"] = 'https:https://www.google.com'; |
|
|
698
|
+ $result = GETPOST("backtopage"); |
|
699
|
699
|
print __METHOD__." result=".$result."\n"; |
|
700
|
700
|
$this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
|
701
|
701
|
|
|
702
|
|
- $_POST["backtolist"]='::HTTPS://www.google.com'; |
|
703
|
|
- $result=GETPOST("backtolist"); |
|
|
702
|
+ $_POST["backtolist"] = '::HTTPS://www.google.com'; |
|
|
703
|
+ $result = GETPOST("backtolist"); |
|
704
|
704
|
print __METHOD__." result=".$result."\n"; |
|
705
|
705
|
$this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
|
706
|
706
|
|
|
707
|
|
- $_POST["backtopage"]='http:www.google.com'; |
|
708
|
|
- $result=GETPOST("backtopage"); |
|
|
707
|
+ $_POST["backtopage"] = 'http:www.google.com'; |
|
|
708
|
+ $result = GETPOST("backtopage"); |
|
709
|
709
|
print __METHOD__." result=".$result."\n"; |
|
710
|
710
|
$this->assertEquals('httpwww.google.com', $result, 'Test for backtopage param'); |
|
711
|
711
|
|
|
712
|
|
- $_POST["backtopage"]='/mydir/mypage.php?aa=a%10a'; |
|
713
|
|
- $result=GETPOST("backtopage"); |
|
|
712
|
+ $_POST["backtopage"] = '/mydir/mypage.php?aa=a%10a'; |
|
|
713
|
+ $result = GETPOST("backtopage"); |
|
714
|
714
|
print __METHOD__." result=".$result."\n"; |
|
715
|
715
|
$this->assertEquals('/mydir/mypage.php?aa=a%10a', $result, 'Test for backtopage param'); |
|
716
|
716
|
|
|
717
|
|
- $_POST["backtopage"]='javascripT&javascript#javascriptxjavascript3a alert(1)'; |
|
718
|
|
- $result=GETPOST("backtopage"); |
|
|
717
|
+ $_POST["backtopage"] = 'javascripT&javascript#javascriptxjavascript3a alert(1)'; |
|
|
718
|
+ $result = GETPOST("backtopage"); |
|
719
|
719
|
print __METHOD__." result=".$result."\n"; |
|
720
|
720
|
$this->assertEquals('x3aalert(1)', $result, 'Test for backtopage param'); |
|
721
|
721
|
|
|
722
|
722
|
|
|
723
|
723
|
$conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3; |
|
724
|
|
- $_POST["pagecontentwithlinks"]='<img src="aaa"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>'; |
|
725
|
|
- $result=GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
|
724
|
+ $_POST["pagecontentwithlinks"] = '<img src="aaa"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>'; |
|
|
725
|
+ $result = GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
726
|
726
|
print __METHOD__." result=".$result."\n"; |
|
727
|
727
|
$this->assertEquals('ErrorTooManyLinksIntoHTMLString', $result, 'Test on limit on GETPOST fails'); |
|
728
|
728
|
|
|
729
|
729
|
// Test that img src="data:..." is excluded from the count of external links |
|
730
|
730
|
$conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3; |
|
731
|
|
- $_POST["pagecontentwithlinks"]='<img src="data:abc"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>'; |
|
732
|
|
- $result=GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
|
731
|
+ $_POST["pagecontentwithlinks"] = '<img src="data:abc"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>'; |
|
|
732
|
+ $result = GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
733
|
733
|
print __METHOD__." result=".$result."\n"; |
|
734
|
734
|
$this->assertEquals('<img src="data:abc"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>', $result, 'Test on limit on GETPOST fails'); |
|
735
|
735
|
|
|
736
|
736
|
// Test that no links is allowed |
|
737
|
737
|
$conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1; |
|
738
|
|
- $_POST["pagecontentwithlinks"]='<img src="data:abc"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>'; |
|
739
|
|
- $result=GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
|
738
|
+ $_POST["pagecontentwithlinks"] = '<img src="data:abc"><img src="bbb"><img src="ccc"><span style="background: url(/ddd)"></span>'; |
|
|
739
|
+ $result = GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
740
|
740
|
print __METHOD__." result=".$result."\n"; |
|
741
|
741
|
$this->assertEquals('ErrorHTMLLinksNotAllowed', $result, 'Test on limit on GETPOST fails'); |
|
742
|
742
|
|
|
@@ -751,15 +751,15 @@ discard block |
|
|
block discarded – undo |
|
751
|
751
|
*/ |
|
752
|
752
|
public function testEncodeDecode() |
|
753
|
753
|
{ |
|
754
|
|
- $stringtotest="This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode."; |
|
|
754
|
+ $stringtotest = "This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode."; |
|
755
|
755
|
|
|
756
|
|
- $encodedstring=dol_encode($stringtotest); |
|
757
|
|
- $decodedstring=dol_decode($encodedstring); |
|
|
756
|
+ $encodedstring = dol_encode($stringtotest); |
|
|
757
|
+ $decodedstring = dol_decode($encodedstring); |
|
758
|
758
|
print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; |
|
759
|
759
|
$this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with no parameter'); |
|
760
|
760
|
|
|
761
|
|
- $encodedstring=dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
762
|
|
- $decodedstring=dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
|
761
|
+ $encodedstring = dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
|
762
|
+ $decodedstring = dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
763
|
763
|
print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; |
|
764
|
764
|
$this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with a key parameter'); |
|
765
|
765
|
|
|
@@ -778,7 +778,7 @@ discard block |
|
|
block discarded – undo |
|
778
|
778
|
$this->assertEquals('a : b " c \' d ' e é', $decodedstring, 'Function did not sanitize correclty'); |
|
779
|
779
|
|
|
780
|
780
|
$stringtotest = 'a : b " c ' d ' e é'; |
|
781
|
|
- $decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES|ENT_HTML5); |
|
|
781
|
+ $decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES | ENT_HTML5); |
|
782
|
782
|
$this->assertEquals('a : b " c \' d \' e é', $decodedstring, 'Function did not sanitize correclty'); |
|
783
|
783
|
|
|
784
|
784
|
return 0; |
|
@@ -842,21 +842,21 @@ discard block |
|
|
block discarded – undo |
|
842
|
842
|
{ |
|
843
|
843
|
global $conf; |
|
844
|
844
|
|
|
845
|
|
- $genpass1=getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5) |
|
|
845
|
+ $genpass1 = getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5) |
|
846
|
846
|
print __METHOD__." genpass1=".$genpass1."\n"; |
|
847
|
847
|
$this->assertEquals(strlen($genpass1), 32); |
|
848
|
848
|
|
|
849
|
|
- $genpass1=getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5) |
|
|
849
|
+ $genpass1 = getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5) |
|
850
|
850
|
print __METHOD__." genpass1=".$genpass1."\n"; |
|
851
|
851
|
$this->assertEquals(strlen($genpass1), 32); |
|
852
|
852
|
|
|
853
|
|
- $conf->global->USER_PASSWORD_GENERATED='None'; |
|
854
|
|
- $genpass2=getRandomPassword(false); // Should return an empty string |
|
|
853
|
+ $conf->global->USER_PASSWORD_GENERATED = 'None'; |
|
|
854
|
+ $genpass2 = getRandomPassword(false); // Should return an empty string |
|
855
|
855
|
print __METHOD__." genpass2=".$genpass2."\n"; |
|
856
|
856
|
$this->assertEquals($genpass2, ''); |
|
857
|
857
|
|
|
858
|
|
- $conf->global->USER_PASSWORD_GENERATED='Standard'; |
|
859
|
|
- $genpass3=getRandomPassword(false); // Should return a password of 12 chars |
|
|
858
|
+ $conf->global->USER_PASSWORD_GENERATED = 'Standard'; |
|
|
859
|
+ $genpass3 = getRandomPassword(false); // Should return a password of 12 chars |
|
860
|
860
|
print __METHOD__." genpass3=".$genpass3."\n"; |
|
861
|
861
|
$this->assertEquals(strlen($genpass3), 12); |
|
862
|
862
|
|
|
@@ -870,16 +870,16 @@ discard block |
|
|
block discarded – undo |
|
870
|
870
|
*/ |
|
871
|
871
|
public function testRestrictedArea() |
|
872
|
872
|
{ |
|
873
|
|
- global $conf,$user,$langs,$db; |
|
874
|
|
- $conf=$this->savconf; |
|
875
|
|
- $user=$this->savuser; |
|
876
|
|
- $langs=$this->savlangs; |
|
877
|
|
- $db=$this->savdb; |
|
|
873
|
+ global $conf, $user, $langs, $db; |
|
|
874
|
+ $conf = $this->savconf; |
|
|
875
|
+ $user = $this->savuser; |
|
|
876
|
+ $langs = $this->savlangs; |
|
|
877
|
+ $db = $this->savdb; |
|
878
|
878
|
|
|
879
|
879
|
//$dummyuser=new User($db); |
|
880
|
880
|
//$result=restrictedArea($dummyuser,'societe'); |
|
881
|
881
|
|
|
882
|
|
- $result=restrictedArea($user, 'societe'); |
|
|
882
|
+ $result = restrictedArea($user, 'societe'); |
|
883
|
883
|
$this->assertEquals(1, $result); |
|
884
|
884
|
} |
|
885
|
885
|
|
|
@@ -897,42 +897,42 @@ discard block |
|
|
block discarded – undo |
|
897
|
897
|
$url = 'ftp://mydomain.com'; |
|
898
|
898
|
$tmp = getURLContent($url); |
|
899
|
899
|
print __METHOD__." url=".$url."\n"; |
|
900
|
|
- $this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported')); // Test error if return does not contains 'not supported' |
|
|
900
|
+ $this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported')); // Test error if return does not contains 'not supported' |
|
901
|
901
|
|
|
902
|
|
- $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
903
|
|
- $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow |
|
|
902
|
+ $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
|
903
|
+ $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow |
|
904
|
904
|
print __METHOD__." url=".$url."\n"; |
|
905
|
905
|
$this->assertEquals(301, $tmp['http_code'], 'Should GET url 301 response and stop here'); |
|
906
|
906
|
|
|
907
|
|
- $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
908
|
|
- $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 |
|
|
907
|
+ $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
|
908
|
+ $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 |
|
909
|
909
|
print __METHOD__." url=".$url."\n"; |
|
910
|
910
|
$this->assertEquals(200, $tmp['http_code'], 'Should GET url 301 with a follow -> 200 but we get '.$tmp['http_code']); |
|
911
|
911
|
|
|
912
|
912
|
$url = 'http://localhost'; |
|
913
|
|
- $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
|
913
|
+ $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
914
|
914
|
print __METHOD__." url=".$url."\n"; |
|
915
|
|
- $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL |
|
|
915
|
+ $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL |
|
916
|
916
|
|
|
917
|
917
|
$url = 'http://127.0.0.1'; |
|
918
|
|
- $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
|
918
|
+ $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
919
|
919
|
print __METHOD__." url=".$url."\n"; |
|
920
|
|
- $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL |
|
|
920
|
+ $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL |
|
921
|
921
|
|
|
922
|
922
|
$url = 'http://127.0.2.1'; |
|
923
|
|
- $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
|
923
|
+ $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
924
|
924
|
print __METHOD__." url=".$url."\n"; |
|
925
|
|
- $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL |
|
|
925
|
+ $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL |
|
926
|
926
|
|
|
927
|
927
|
$url = 'https://169.254.0.1'; |
|
928
|
|
- $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
|
928
|
+ $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
929
|
929
|
print __METHOD__." url=".$url."\n"; |
|
930
|
|
- $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL |
|
|
930
|
+ $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL |
|
931
|
931
|
|
|
932
|
932
|
$url = 'http://[::1]'; |
|
933
|
|
- $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
|
933
|
+ $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
934
|
934
|
print __METHOD__." url=".$url."\n"; |
|
935
|
|
- $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL |
|
|
935
|
+ $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL |
|
936
|
936
|
|
|
937
|
937
|
/*$url = 'localtest.me'; |
|
938
|
938
|
$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
@@ -941,9 +941,9 @@ discard block |
|
|
block discarded – undo |
|
941
|
941
|
*/ |
|
942
|
942
|
|
|
943
|
943
|
$url = 'http://192.0.0.192'; |
|
944
|
|
- $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist |
|
|
944
|
+ $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist |
|
945
|
945
|
print __METHOD__." url=".$url." tmp['http_code'] = ".$tmp['http_code']."\n"; |
|
946
|
|
- $this->assertEquals(400, $tmp['http_code'], 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist |
|
|
946
|
+ $this->assertEquals(400, $tmp['http_code'], 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist |
|
947
|
947
|
|
|
948
|
948
|
return 0; |
|
949
|
949
|
} |
|
@@ -955,22 +955,22 @@ discard block |
|
|
block discarded – undo |
|
955
|
955
|
*/ |
|
956
|
956
|
public function testDolSanitizeUrl() |
|
957
|
957
|
{ |
|
958
|
|
- global $conf,$user,$langs,$db; |
|
959
|
|
- $conf=$this->savconf; |
|
960
|
|
- $user=$this->savuser; |
|
961
|
|
- $langs=$this->savlangs; |
|
962
|
|
- $db=$this->savdb; |
|
|
958
|
+ global $conf, $user, $langs, $db; |
|
|
959
|
+ $conf = $this->savconf; |
|
|
960
|
+ $user = $this->savuser; |
|
|
961
|
+ $langs = $this->savlangs; |
|
|
962
|
+ $db = $this->savdb; |
|
963
|
963
|
|
|
964
|
964
|
$test = 'javascripT&javascript#x3a alert(1)'; |
|
965
|
|
- $result=dol_sanitizeUrl($test); |
|
|
965
|
+ $result = dol_sanitizeUrl($test); |
|
966
|
966
|
$this->assertEquals('x3a alert(1)', $result, 'Test on dol_sanitizeUrl A'); |
|
967
|
967
|
|
|
968
|
968
|
$test = 'javajavascriptscript&cjavascriptolon;alert(1)'; |
|
969
|
|
- $result=dol_sanitizeUrl($test); |
|
|
969
|
+ $result = dol_sanitizeUrl($test); |
|
970
|
970
|
$this->assertEquals('alert(1)', $result, 'Test on dol_sanitizeUrl B'); |
|
971
|
971
|
|
|
972
|
972
|
$test = '/javas:cript/google.com'; |
|
973
|
|
- $result=dol_sanitizeUrl($test); |
|
|
973
|
+ $result = dol_sanitizeUrl($test); |
|
974
|
974
|
$this->assertEquals('google.com', $result, 'Test on dol_sanitizeUrl C'); |
|
975
|
975
|
} |
|
976
|
976
|
|
|
@@ -981,26 +981,26 @@ discard block |
|
|
block discarded – undo |
|
981
|
981
|
*/ |
|
982
|
982
|
public function testDolSanitizeEmail() |
|
983
|
983
|
{ |
|
984
|
|
- global $conf,$user,$langs,$db; |
|
985
|
|
- $conf=$this->savconf; |
|
986
|
|
- $user=$this->savuser; |
|
987
|
|
- $langs=$this->savlangs; |
|
988
|
|
- $db=$this->savdb; |
|
|
984
|
+ global $conf, $user, $langs, $db; |
|
|
985
|
+ $conf = $this->savconf; |
|
|
986
|
+ $user = $this->savuser; |
|
|
987
|
+ $langs = $this->savlangs; |
|
|
988
|
+ $db = $this->savdb; |
|
989
|
989
|
|
|
990
|
990
|
$test = '[email protected] <My name>, [email protected] <Another name>'; |
|
991
|
|
- $result=dol_sanitizeEmail($test); |
|
|
991
|
+ $result = dol_sanitizeEmail($test); |
|
992
|
992
|
$this->assertEquals($test, $result, 'Test on dol_sanitizeEmail A'); |
|
993
|
993
|
|
|
994
|
994
|
$test = "[email protected] <My name>,\[email protected] <Another name>"; |
|
995
|
|
- $result=dol_sanitizeEmail($test); |
|
|
995
|
+ $result = dol_sanitizeEmail($test); |
|
996
|
996
|
$this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail B'); |
|
997
|
997
|
|
|
998
|
998
|
$test = '[email protected] <My name>,\[email protected] <Another name>'; |
|
999
|
|
- $result=dol_sanitizeEmail($test); |
|
|
999
|
+ $result = dol_sanitizeEmail($test); |
|
1000
|
1000
|
$this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail C'); |
|
1001
|
1001
|
|
|
1002
|
1002
|
$test = '[email protected] <My name>, "bcc:bbb"@mycompany.com <Another name>'; |
|
1003
|
|
- $result=dol_sanitizeEmail($test); |
|
|
1003
|
+ $result = dol_sanitizeEmail($test); |
|
1004
|
1004
|
$this->assertEquals('[email protected] <My name>, [email protected] <Another name>', $result, 'Test on dol_sanitizeEmail D'); |
|
1005
|
1005
|
} |
|
1006
|
1006
|
|
|
@@ -1011,19 +1011,19 @@ discard block |
|
|
block discarded – undo |
|
1011
|
1011
|
*/ |
|
1012
|
1012
|
public function testDolSanitizeFileName() |
|
1013
|
1013
|
{ |
|
1014
|
|
- global $conf,$user,$langs,$db; |
|
1015
|
|
- $conf=$this->savconf; |
|
1016
|
|
- $user=$this->savuser; |
|
1017
|
|
- $langs=$this->savlangs; |
|
1018
|
|
- $db=$this->savdb; |
|
|
1014
|
+ global $conf, $user, $langs, $db; |
|
|
1015
|
+ $conf = $this->savconf; |
|
|
1016
|
+ $user = $this->savuser; |
|
|
1017
|
+ $langs = $this->savlangs; |
|
|
1018
|
+ $db = $this->savdb; |
|
1019
|
1019
|
|
|
1020
|
1020
|
//$dummyuser=new User($db); |
|
1021
|
1021
|
//$result=restrictedArea($dummyuser,'societe'); |
|
1022
|
1022
|
|
|
1023
|
|
- $result=dol_sanitizeFileName('bad file | evilaction'); |
|
|
1023
|
+ $result = dol_sanitizeFileName('bad file | evilaction'); |
|
1024
|
1024
|
$this->assertEquals('bad file _ evilaction', $result); |
|
1025
|
1025
|
|
|
1026
|
|
- $result=dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam'); |
|
|
1026
|
+ $result = dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam'); |
|
1027
|
1027
|
$this->assertEquals('bad file _evilparam _evilparam _evilparam _evilparam', $result); |
|
1028
|
1028
|
} |
|
1029
|
1029
|
|
|
@@ -1034,17 +1034,17 @@ discard block |
|
|
block discarded – undo |
|
1034
|
1034
|
*/ |
|
1035
|
1035
|
public function testDolEval() |
|
1036
|
1036
|
{ |
|
1037
|
|
- global $conf,$user,$langs,$db; |
|
1038
|
|
- $conf=$this->savconf; |
|
1039
|
|
- $user=$this->savuser; |
|
1040
|
|
- $langs=$this->savlangs; |
|
1041
|
|
- $db=$this->savdb; |
|
|
1037
|
+ global $conf, $user, $langs, $db; |
|
|
1038
|
+ $conf = $this->savconf; |
|
|
1039
|
+ $user = $this->savuser; |
|
|
1040
|
+ $langs = $this->savlangs; |
|
|
1041
|
+ $db = $this->savdb; |
|
1042
|
1042
|
|
|
1043
|
|
- $result=dol_eval('1==1', 1, 0); |
|
|
1043
|
+ $result = dol_eval('1==1', 1, 0); |
|
1044
|
1044
|
print "result1 = ".$result."\n"; |
|
1045
|
1045
|
$this->assertTrue($result); |
|
1046
|
1046
|
|
|
1047
|
|
- $result=dol_eval('1==2', 1, 0); |
|
|
1047
|
+ $result = dol_eval('1==2', 1, 0); |
|
1048
|
1048
|
print "result2 = ".$result."\n"; |
|
1049
|
1049
|
$this->assertFalse($result); |
|
1050
|
1050
|
|
|
@@ -1052,7 +1052,7 @@ discard block |
|
|
block discarded – undo |
|
1052
|
1052
|
include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
|
1053
|
1053
|
|
|
1054
|
1054
|
$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"'; |
|
1055
|
|
- $result=dol_eval($s, 1, 1, '2'); |
|
|
1055
|
+ $result = dol_eval($s, 1, 1, '2'); |
|
1056
|
1056
|
print "result3 = ".$result."\n"; |
|
1057
|
1057
|
$this->assertEquals('Parent project not found', $result); |
|
1058
|
1058
|
|
|
@@ -1093,48 +1093,48 @@ discard block |
|
|
block discarded – undo |
|
1093
|
1093
|
print "result12 = ".$result."\n"; |
|
1094
|
1094
|
$this->assertStringContainsString('Bad string syntax to evaluate', $result); |
|
1095
|
1095
|
|
|
1096
|
|
- $result=dol_eval("90402.38+267678+0", 1, 1, 1); |
|
|
1096
|
+ $result = dol_eval("90402.38+267678+0", 1, 1, 1); |
|
1097
|
1097
|
print "result13 = ".$result."\n"; |
|
1098
|
1098
|
$this->assertEquals('358080.38', $result); |
|
1099
|
1099
|
|
|
1100
|
|
- global $leftmenu; // Used into strings to eval |
|
|
1100
|
+ global $leftmenu; // Used into strings to eval |
|
1101
|
1101
|
|
|
1102
|
1102
|
$leftmenu = 'AAA'; |
|
1103
|
|
- $result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
|
1103
|
+ $result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1104
|
1104
|
print "result = ".$result."\n"; |
|
1105
|
1105
|
$this->assertTrue($result); |
|
1106
|
1106
|
|
|
1107
|
1107
|
// Same with a value that does not match |
|
1108
|
1108
|
$leftmenu = 'XXX'; |
|
1109
|
|
- $result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
|
1109
|
+ $result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1110
|
1110
|
print "result14 = ".$result."\n"; |
|
1111
|
1111
|
$this->assertFalse($result); |
|
1112
|
1112
|
|
|
1113
|
1113
|
$leftmenu = 'AAA'; |
|
1114
|
|
- $result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
|
1114
|
+ $result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1115
|
1115
|
print "result15 = ".$result."\n"; |
|
1116
|
1116
|
$this->assertTrue($result); |
|
1117
|
1117
|
|
|
1118
|
1118
|
$leftmenu = 'XXX'; |
|
1119
|
|
- $result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
|
1119
|
+ $result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1120
|
1120
|
print "result16 = ".$result."\n"; |
|
1121
|
1121
|
$this->assertFalse($result); |
|
1122
|
1122
|
|
|
1123
|
1123
|
$string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)'; |
|
1124
|
|
- $result=dol_eval($string, 1, 1, '1'); |
|
|
1124
|
+ $result = dol_eval($string, 1, 1, '1'); |
|
1125
|
1125
|
print "result17 = ".$result."\n"; |
|
1126
|
1126
|
$this->assertTrue($result); |
|
1127
|
1127
|
|
|
1128
|
|
- $result=dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...' |
|
|
1128
|
+ $result = dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...' |
|
1129
|
1129
|
print "result18 = ".$result."\n"; |
|
1130
|
1130
|
$this->assertFalse($result); |
|
1131
|
1131
|
|
|
1132
|
|
- $a='ab'; |
|
|
1132
|
+ $a = 'ab'; |
|
1133
|
1133
|
$result = (string) dol_eval("(\$a.'s')", 1, 0); |
|
1134
|
1134
|
print "result19 = ".$result."\n"; |
|
1135
|
1135
|
$this->assertStringContainsString('Bad string syntax to evaluate', $result); |
|
1136
|
1136
|
|
|
1137
|
|
- $leftmenu='abs'; |
|
|
1137
|
+ $leftmenu = 'abs'; |
|
1138
|
1138
|
$result = (string) dol_eval('$leftmenu(-5)', 1, 0); |
|
1139
|
1139
|
print "result20 = ".$result."\n"; |
|
1140
|
1140
|
$this->assertStringContainsString('Bad string syntax to evaluate', $result); |
|
@@ -1152,12 +1152,12 @@ discard block |
|
|
block discarded – undo |
|
1152
|
1152
|
global $conf; |
|
1153
|
1153
|
|
|
1154
|
1154
|
// Set options for cleaning data |
|
1155
|
|
- $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; // disabled, does not work on HTML5 and some libxml versions |
|
|
1155
|
+ $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; // disabled, does not work on HTML5 and some libxml versions |
|
1156
|
1156
|
// Enabled option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY if possible |
|
1157
|
1157
|
if (extension_loaded('tidy') && class_exists("tidy")) { |
|
1158
|
1158
|
$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; |
|
1159
|
1159
|
} |
|
1160
|
|
- $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; // disabled, does not work on HTML5 and some libxml versions |
|
|
1160
|
+ $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; // disabled, does not work on HTML5 and some libxml versions |
|
1161
|
1161
|
|
|
1162
|
1162
|
|
|
1163
|
1163
|
|
|
@@ -1170,7 +1170,7 @@ discard block |
|
|
block discarded – undo |
|
1170
|
1170
|
//$result = dol_escape_htmltag(dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr($stringtotest), 1, 1, 1, 0)), 1, 1, 'common', 0, 1); |
|
1171
|
1171
|
$result = dolPrintHTML($stringtotest); |
|
1172
|
1172
|
print __METHOD__." result=".$result."\n"; |
|
1173
|
|
- $this->assertEquals($stringfixed, $result, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
|
1173
|
+ $this->assertEquals($stringfixed, $result, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
1174
|
1174
|
|
|
1175
|
1175
|
|
|
1176
|
1176
|
// For a string that is already HTML (contains HTML tags) with special tags but badly formated |
|
@@ -1219,24 +1219,24 @@ discard block |
|
|
block discarded – undo |
|
1219
|
1219
|
*/ |
|
1220
|
1220
|
public function testCheckLoginPassEntity() |
|
1221
|
1221
|
{ |
|
1222
|
|
- $login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); |
|
|
1222
|
+ $login = checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); |
|
1223
|
1223
|
print __METHOD__." login=".$login."\n"; |
|
1224
|
1224
|
$this->assertEquals($login, ''); |
|
1225
|
1225
|
|
|
1226
|
|
- $login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); |
|
|
1226
|
+ $login = checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); |
|
1227
|
1227
|
print __METHOD__." login=".$login."\n"; |
|
1228
|
1228
|
$this->assertEquals($login, ''); |
|
1229
|
1229
|
|
|
1230
|
|
- $login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists |
|
|
1230
|
+ $login = checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists |
|
1231
|
1231
|
print __METHOD__." login=".$login."\n"; |
|
1232
|
1232
|
$this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed'); |
|
1233
|
1233
|
|
|
1234
|
|
- $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method |
|
|
1234
|
+ $login = checkLoginPassEntity('admin', 'admin', 1, array('http', 'dolibarr')); // Should work because of second authentication method |
|
1235
|
1235
|
print __METHOD__." login=".$login."\n"; |
|
1236
|
1236
|
$this->assertEquals($login, 'admin'); |
|
1237
|
1237
|
|
|
1238
|
|
- $login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); |
|
|
1238
|
+ $login = checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); |
|
1239
|
1239
|
print __METHOD__." login=".$login."\n"; |
|
1240
|
|
- $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
|
1240
|
+ $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
1241
|
1241
|
} |
|
1242
|
1242
|
} |