@@ -328,16 +328,18 @@ module Vue {
328
328
result = getAsClassComponent ( ) .getAnInstanceMember ( )
329
329
}
330
330
331
+ /**
332
+ * Gets a reference to `this` inside the component, referring to an instance of the component.
333
+ */
334
+ DataFlow:: SourceNode getASelfRef ( ) {
335
+ result = getABoundFunction ( ) .getReceiver ( )
336
+ }
337
+
331
338
pragma [ noinline]
332
339
private DataFlow:: PropWrite getAPropertyValueWrite ( string name ) {
333
340
result = getData ( ) .getALocalSource ( ) .getAPropertyWrite ( name )
334
341
or
335
- result =
336
- getABoundFunction ( )
337
- .getALocalSource ( )
338
- .( DataFlow:: FunctionNode )
339
- .getReceiver ( )
340
- .getAPropertyWrite ( name )
342
+ result = getASelfRef ( ) .getAPropertyWrite ( name )
341
343
}
342
344
343
345
/**
@@ -547,20 +549,31 @@ module Vue {
547
549
VueFile ( ) { getExtension ( ) = "vue" }
548
550
}
549
551
552
+ pragma [ nomagic]
553
+ private DataFlow:: Node propStepPred ( Component comp , string name ) {
554
+ result = comp .getAPropertyValue ( name )
555
+ }
556
+
557
+ pragma [ nomagic]
558
+ private DataFlow:: Node propStepSucc ( Component comp , string name ) {
559
+ result = comp .getASelfRef ( ) .getAPropertyRead ( name )
560
+ }
561
+
550
562
/**
551
563
* A taint propagating data flow edge through a Vue instance property.
552
564
*/
553
- class InstanceHeapStep extends TaintTracking:: SharedTaintStep {
554
- override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
555
- exists ( Component i , string name , DataFlow:: FunctionNode bound |
556
- bound .flowsTo ( i .getABoundFunction ( ) ) and
557
- not bound .getFunction ( ) instanceof ArrowFunctionExpr and
558
- succ = bound .getReceiver ( ) .getAPropertyRead ( name ) and
559
- pred = i .getAPropertyValue ( name )
565
+ private class PropStep extends TaintTracking:: SharedTaintStep {
566
+ override predicate viewComponentStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
567
+ exists ( Component comp , string name |
568
+ pred = propStepPred ( comp , name ) and
569
+ succ = propStepSucc ( comp , name )
560
570
)
561
571
}
562
572
}
563
573
574
+ /** DEPRECATED. Do not use. */
575
+ deprecated class InstanceHeapStep = PropStep ;
576
+
564
577
/**
565
578
* A Vue `v-html` attribute.
566
579
*/
@@ -585,11 +598,11 @@ module Vue {
585
598
* of `inst = new Vue({ ..., data: { prop: source } })`, if the
586
599
* `div` element is part of the template for `inst`.
587
600
*/
588
- class VHtmlSourceWrite extends TaintTracking:: SharedTaintStep {
589
- override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
590
- exists ( Vue :: Component component , string expr , VHtmlAttribute attr |
601
+ private class VHtmlAttributeStep extends TaintTracking:: SharedTaintStep {
602
+ override predicate viewComponentStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
603
+ exists ( Component component , string expr , VHtmlAttribute attr |
591
604
attr .getAttr ( ) .getRoot ( ) =
592
- component .getTemplateElement ( ) .( Vue :: Template:: HtmlElement ) .getElement ( ) and
605
+ component .getTemplateElement ( ) .( Template:: HtmlElement ) .getElement ( ) and
593
606
expr = attr .getAttr ( ) .getValue ( ) and
594
607
// only support for simple identifier expressions
595
608
expr .regexpMatch ( "(?i)[a-z0-9_]+" ) and
@@ -599,6 +612,11 @@ module Vue {
599
612
}
600
613
}
601
614
615
+ /**
616
+ * DEPRECATED. Do not use.
617
+ */
618
+ deprecated class VHtmlSourceWrite = VHtmlAttributeStep ;
619
+
602
620
/*
603
621
* Provides classes for working with Vue templates.
604
622
*/
0 commit comments