1
1
describe ( 'security issues' , function ( ) {
2
2
describe ( 'GH-1495: Prevent Remote Code Execution via constructor' , function ( ) {
3
3
it ( 'should not allow constructors to be accessed' , function ( ) {
4
- shouldCompileTo ( '{{constructor.name}}' , { } , '' ) ;
5
- shouldCompileTo ( '{{lookup (lookup this "constructor") "name"}}' , { } , '' ) ;
4
+ expectTemplate ( '{{lookup (lookup this "constructor") "name"}}' )
5
+ . withInput ( { } )
6
+ . toCompileTo ( '' ) ;
7
+
8
+ expectTemplate ( '{{constructor.name}}' )
9
+ . withInput ( { } )
10
+ . toCompileTo ( '' ) ;
6
11
} ) ;
7
12
8
- it ( 'should allow the "constructor" property to be accessed if it is enumerable' , function ( ) {
13
+ it ( 'GH-1603: should not allow constructors to be accessed (lookup via toString)' , function ( ) {
14
+ expectTemplate ( '{{lookup (lookup this (list "constructor")) "name"}}' )
15
+ . withInput ( { } )
16
+ . withHelper ( 'list' , function ( element ) {
17
+ return [ element ] ;
18
+ } )
19
+ . toCompileTo ( '' ) ;
20
+ } ) ;
21
+
22
+
23
+ it ( 'should allow the "constructor" property to be accessed if it is enumerable' , function ( ) {
9
24
shouldCompileTo ( '{{constructor.name}}' , { 'constructor' : {
10
25
'name' : 'here we go'
11
26
} } , 'here we go' ) ;
@@ -14,6 +29,13 @@ describe('security issues', function() {
14
29
} } , 'here we go' ) ;
15
30
} ) ;
16
31
32
+ it ( 'should allow the "constructor" property to be accessed if it is enumerable' , function ( ) {
33
+ shouldCompileTo ( '{{lookup (lookup this "constructor") "name"}}' , { 'constructor' : {
34
+ 'name' : 'here we go'
35
+ } } , 'here we go' ) ;
36
+ } ) ;
37
+
38
+
17
39
it ( 'should allow prototype properties that are not constructors' , function ( ) {
18
40
function TestClass ( ) {
19
41
}
0 commit comments