@@ -193,7 +193,8 @@ abstract private class LateJavaScriptPropertyBinding extends DataFlow::Node {
193
193
*/
194
194
private predicate earlyPropertyBinding (
195
195
DataFlow:: NewNode newNode , DataFlow:: PropWrite bindingTarget , DataFlow:: Node binding ,
196
- DataFlow:: Node bindingPath ) {
196
+ DataFlow:: Node bindingPath
197
+ ) {
197
198
// Property binding via an object literal binding with property `path`.
198
199
// This assumes the value assigned to `path` is a binding, even if we cannot
199
200
// statically determine it is a binding.
@@ -205,9 +206,10 @@ private predicate earlyPropertyBinding(
205
206
if exists ( binding .getALocalSource ( ) )
206
207
then binding .getALocalSource ( ) = bindingPath
207
208
else binding = bindingPath // e.g., path: "/" + someVar
208
- ) and not bindingPath .getStringValue ( ) instanceof BindingString
209
+ ) and
210
+ not bindingPath .getStringValue ( ) instanceof BindingString
209
211
or
210
- // Propery binding of an arbitrary property for which we can statically determined
212
+ // Property binding of an arbitrary property for which we can statically determined
211
213
// the value written to the property is a binding path.
212
214
exists ( DataFlow:: SourceNode objectLiteral |
213
215
newNode .getAnArgument ( ) .getALocalSource ( ) = objectLiteral and
@@ -339,9 +341,7 @@ private newtype TBinding =
339
341
* with a property `parts` assigned a value, or
340
342
* an object literal that is assigned a string value that is a binding path.
341
343
*/
342
- TEarlyJavaScriptPropertyBinding (
343
- DataFlow:: PropWrite bindingTarget , DataFlow:: ValueNode binding
344
- ) {
344
+ TEarlyJavaScriptPropertyBinding ( DataFlow:: PropWrite bindingTarget , DataFlow:: ValueNode binding ) {
345
345
earlyPropertyBinding ( _, bindingTarget , binding , _)
346
346
} or
347
347
// Property binding via a call to `bindProperty` or `bindValue`.
@@ -415,29 +415,34 @@ private newtype TBindingPath =
415
415
)
416
416
} or
417
417
TDynamicBindingPath ( Binding binding , DataFlow:: Node dynamicBinding , DataFlow:: Node bindingPath ) {
418
- ( exists ( DataFlow:: PropWrite bindingTarget |
419
- binding = TEarlyJavaScriptPropertyBinding ( bindingTarget , dynamicBinding ) and
420
- earlyPropertyBinding ( _, bindingTarget , dynamicBinding , bindingPath )
421
- )
422
- or
423
- exists ( LateJavaScriptPropertyBinding lateJavaScriptPropertyBinding |
424
- // Property binding via a call to `bindProperty` or `bindValue`.
425
- binding = TLateJavaScriptPropertyBinding ( lateJavaScriptPropertyBinding , dynamicBinding ) and
426
- latePropertyBinding ( lateJavaScriptPropertyBinding , dynamicBinding , bindingPath )
427
- )
428
- or
429
- exists ( BindElementMethodCallNode bindElementMethodCall |
430
- // Element binding via a call to `bindElement`.
431
- binding = TLateJavaScriptContextBinding ( bindElementMethodCall , dynamicBinding ) and
432
- lateContextBinding ( bindElementMethodCall , dynamicBinding , bindingPath )
433
- ) ) and
418
+ (
419
+ exists ( DataFlow:: PropWrite bindingTarget |
420
+ binding = TEarlyJavaScriptPropertyBinding ( bindingTarget , dynamicBinding ) and
421
+ earlyPropertyBinding ( _, bindingTarget , dynamicBinding , bindingPath )
422
+ )
423
+ or
424
+ exists ( LateJavaScriptPropertyBinding lateJavaScriptPropertyBinding |
425
+ // Property binding via a call to `bindProperty` or `bindValue`.
426
+ binding = TLateJavaScriptPropertyBinding ( lateJavaScriptPropertyBinding , dynamicBinding ) and
427
+ latePropertyBinding ( lateJavaScriptPropertyBinding , dynamicBinding , bindingPath )
428
+ )
429
+ or
430
+ exists ( BindElementMethodCallNode bindElementMethodCall |
431
+ // Element binding via a call to `bindElement`.
432
+ binding = TLateJavaScriptContextBinding ( bindElementMethodCall , dynamicBinding ) and
433
+ lateContextBinding ( bindElementMethodCall , dynamicBinding , bindingPath )
434
+ )
435
+ ) and
434
436
not dynamicBinding .mayHaveStringValue ( _)
435
437
}
436
438
437
439
/**
438
440
* A class representing a binding path.
439
441
*/
440
442
class BindingPath extends TBindingPath {
443
+ /**
444
+ * For debugging purposes (pretty-printing in result table)
445
+ */
441
446
string toString ( ) {
442
447
exists ( BindingStringParser:: BindingPath path |
443
448
this = TStaticBindingPath ( _, _, path ) and
@@ -460,6 +465,11 @@ class BindingPath extends TBindingPath {
460
465
this = TStaticBindingPath ( _, _, path ) and
461
466
result = path .toString ( )
462
467
)
468
+ or
469
+ exists ( DataFlow:: Node pathValue |
470
+ this = TDynamicBindingPath ( _, _, pathValue ) and
471
+ result = pathValue .asExpr ( ) .( StringLiteral ) .getValue ( ) .regexpCapture ( "\\{(.*)\\}" , 1 )
472
+ )
463
473
}
464
474
465
475
Location getLocation ( ) {
@@ -616,8 +626,8 @@ class BindingTarget extends TBindingTarget {
616
626
Binding getBinding ( ) {
617
627
this = TXmlPropertyBindingTarget ( _, result ) or
618
628
this = TXmlContextBindingTarget ( _, result ) or
619
- this = TLateJavaScriptBindingTarget ( _, result ) or
620
629
this = TEarlyJavaScriptPropertyBindingTarget ( _, result ) or
630
+ this = TLateJavaScriptBindingTarget ( _, result ) or
621
631
this = TJsonPropertyBindingTarget ( _, _, result )
622
632
}
623
633
}
@@ -650,7 +660,9 @@ class Binding extends TBinding {
650
660
or
651
661
exists ( DataFlow:: PropWrite bindingTarget , DataFlow:: Node binding |
652
662
this = TEarlyJavaScriptPropertyBinding ( bindingTarget , binding ) and
653
- result = "Early JavaScript property binding: " + bindingTarget .getPropertyNameExpr ( ) + " to " + binding
663
+ result =
664
+ "Early JavaScript property binding: " + bindingTarget .getPropertyNameExpr ( ) + " to " +
665
+ binding
654
666
)
655
667
or
656
668
exists ( LateJavaScriptPropertyBinding lateJavaScriptPropertyBinding , DataFlow:: Node binding |
@@ -710,9 +722,7 @@ class Binding extends TBinding {
710
722
)
711
723
}
712
724
713
- BindingPath getBindingPath ( ) {
714
- result .getBinding ( ) = this
715
- }
725
+ BindingPath getBindingPath ( ) { result .getBinding ( ) = this }
716
726
717
727
BindingTarget getBindingTarget ( ) { result .getBinding ( ) = this }
718
728
}
0 commit comments