@@ -193,7 +193,8 @@ abstract private class LateJavaScriptPropertyBinding extends DataFlow::Node {
193193 */
194194private predicate earlyPropertyBinding (
195195 DataFlow:: NewNode newNode , DataFlow:: PropWrite bindingTarget , DataFlow:: Node binding ,
196- DataFlow:: Node bindingPath ) {
196+ DataFlow:: Node bindingPath
197+ ) {
197198 // Property binding via an object literal binding with property `path`.
198199 // This assumes the value assigned to `path` is a binding, even if we cannot
199200 // statically determine it is a binding.
@@ -205,9 +206,10 @@ private predicate earlyPropertyBinding(
205206 if exists ( binding .getALocalSource ( ) )
206207 then binding .getALocalSource ( ) = bindingPath
207208 else binding = bindingPath // e.g., path: "/" + someVar
208- ) and not bindingPath .getStringValue ( ) instanceof BindingString
209+ ) and
210+ not bindingPath .getStringValue ( ) instanceof BindingString
209211 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
211213 // the value written to the property is a binding path.
212214 exists ( DataFlow:: SourceNode objectLiteral |
213215 newNode .getAnArgument ( ) .getALocalSource ( ) = objectLiteral and
@@ -339,9 +341,7 @@ private newtype TBinding =
339341 * with a property `parts` assigned a value, or
340342 * an object literal that is assigned a string value that is a binding path.
341343 */
342- TEarlyJavaScriptPropertyBinding (
343- DataFlow:: PropWrite bindingTarget , DataFlow:: ValueNode binding
344- ) {
344+ TEarlyJavaScriptPropertyBinding ( DataFlow:: PropWrite bindingTarget , DataFlow:: ValueNode binding ) {
345345 earlyPropertyBinding ( _, bindingTarget , binding , _)
346346 } or
347347 // Property binding via a call to `bindProperty` or `bindValue`.
@@ -415,29 +415,34 @@ private newtype TBindingPath =
415415 )
416416 } or
417417 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
434436 not dynamicBinding .mayHaveStringValue ( _)
435437 }
436438
437439/**
438440 * A class representing a binding path.
439441 */
440442class BindingPath extends TBindingPath {
443+ /**
444+ * For debugging purposes (pretty-printing in result table)
445+ */
441446 string toString ( ) {
442447 exists ( BindingStringParser:: BindingPath path |
443448 this = TStaticBindingPath ( _, _, path ) and
@@ -460,6 +465,11 @@ class BindingPath extends TBindingPath {
460465 this = TStaticBindingPath ( _, _, path ) and
461466 result = path .toString ( )
462467 )
468+ or
469+ exists ( DataFlow:: Node pathValue |
470+ this = TDynamicBindingPath ( _, _, pathValue ) and
471+ result = pathValue .asExpr ( ) .( StringLiteral ) .getValue ( ) .regexpCapture ( "\\{(.*)\\}" , 1 )
472+ )
463473 }
464474
465475 Location getLocation ( ) {
@@ -616,8 +626,8 @@ class BindingTarget extends TBindingTarget {
616626 Binding getBinding ( ) {
617627 this = TXmlPropertyBindingTarget ( _, result ) or
618628 this = TXmlContextBindingTarget ( _, result ) or
619- this = TLateJavaScriptBindingTarget ( _, result ) or
620629 this = TEarlyJavaScriptPropertyBindingTarget ( _, result ) or
630+ this = TLateJavaScriptBindingTarget ( _, result ) or
621631 this = TJsonPropertyBindingTarget ( _, _, result )
622632 }
623633}
@@ -650,7 +660,9 @@ class Binding extends TBinding {
650660 or
651661 exists ( DataFlow:: PropWrite bindingTarget , DataFlow:: Node binding |
652662 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
654666 )
655667 or
656668 exists ( LateJavaScriptPropertyBinding lateJavaScriptPropertyBinding , DataFlow:: Node binding |
@@ -710,9 +722,7 @@ class Binding extends TBinding {
710722 )
711723 }
712724
713- BindingPath getBindingPath ( ) {
714- result .getBinding ( ) = this
715- }
725+ BindingPath getBindingPath ( ) { result .getBinding ( ) = this }
716726
717727 BindingTarget getBindingTarget ( ) { result .getBinding ( ) = this }
718728}
0 commit comments