File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
javascript/ql/src/semmle/javascript/dataflow Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -647,25 +647,24 @@ module DataFlow {
647
647
* writes to the corresponding property.
648
648
*/
649
649
private class ObjectDefinePropertyAsPropWrite extends PropWrite , ValueNode {
650
- CallToObjectDefineProperty odp ;
650
+ override MethodCallExpr astNode ;
651
651
652
- ObjectDefinePropertyAsPropWrite ( ) { odp = this }
652
+ ObjectDefinePropertyAsPropWrite ( ) {
653
+ astNode .getReceiver ( ) .( GlobalVarAccess ) .getName ( ) = "Object" and
654
+ astNode .getMethodName ( ) = "defineProperty"
655
+ }
653
656
654
- override Node getBase ( ) { result = odp . getBaseObject ( ) }
657
+ override Node getBase ( ) { result = astNode . getArgument ( 0 ) . flow ( ) }
655
658
656
- override Expr getPropertyNameExpr ( ) { result = odp .getArgument ( 1 ) . asExpr ( ) }
659
+ override Expr getPropertyNameExpr ( ) { result = astNode .getArgument ( 1 ) }
657
660
658
- override string getPropertyName ( ) { result = odp . getPropertyName ( ) }
661
+ override string getPropertyName ( ) { result = astNode . getArgument ( 1 ) . getStringValue ( ) }
659
662
660
663
override Node getRhs ( ) {
661
- // not using `CallToObjectDefineProperty::getAPropertyAttribute` for performance reasons
662
- exists ( ObjectLiteralNode propdesc |
663
- propdesc .flowsTo ( odp .getPropertyDescriptor ( ) ) and
664
- propdesc .hasPropertyWrite ( "value" , result )
665
- )
664
+ result = astNode .getArgument ( 2 ) .( ObjectExpr ) .getPropertyByName ( "value" ) .getInit ( ) .flow ( )
666
665
}
667
666
668
- override ControlFlowNode getWriteNode ( ) { result = odp . getAstNode ( ) }
667
+ override ControlFlowNode getWriteNode ( ) { result = astNode }
669
668
}
670
669
671
670
/**
You can’t perform that action at this time.
0 commit comments