Skip to content

Commit e7de6cb

Browse files
esbenaStephan Brandauer
authored andcommitted
support await in getSimpleAccessPath
1 parent 1db2117 commit e7de6cb

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

  • javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/EndpointFeatures.qll

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -459,24 +459,30 @@ private module SyntacticUtilities {
459459
* Unknown cases and property names results in `?`.
460460
*/
461461
string getSimpleAccessPath(DataFlow::Node node) {
462-
if node.asExpr() instanceof SuperAccess
463-
then result = "super"
464-
else
465-
if node.asExpr() instanceof ThisAccess
466-
then result = "this"
462+
exists(Expr e | e = node.asExpr().getUnderlyingValue() |
463+
if e instanceof SuperAccess
464+
then result = "super"
467465
else
468-
if node.asExpr() instanceof VarAccess
469-
then result = node.asExpr().(VarAccess).getName()
466+
if e instanceof ThisAccess
467+
then result = "this"
470468
else
471-
if node instanceof DataFlow::PropRead
472-
then
473-
result =
474-
getSimpleAccessPath(node.(DataFlow::PropRead).getBase()) + "." +
475-
getPropertyNameOrUnknown(node)
469+
if e instanceof VarAccess
470+
then result = e.(VarAccess).getName()
476471
else
477-
if node instanceof DataFlow::InvokeNode
478-
then result = getSimpleAccessPath(node.(DataFlow::InvokeNode).getCalleeNode()) + "()"
479-
else result = "?"
472+
if e instanceof AwaitExpr
473+
then result = getSimpleAccessPath(e.(AwaitExpr).getOperand().flow()) + ".then()"
474+
else
475+
if node instanceof DataFlow::PropRead
476+
then
477+
result =
478+
getSimpleAccessPath(node.(DataFlow::PropRead).getBase()) + "." +
479+
getPropertyNameOrUnknown(node)
480+
else
481+
if node instanceof DataFlow::InvokeNode
482+
then
483+
result = getSimpleAccessPath(node.(DataFlow::InvokeNode).getCalleeNode()) + "()"
484+
else result = "?"
485+
)
480486
}
481487
}
482488

@@ -500,7 +506,11 @@ class CalleeAccessPathSimpleFromArgumentTraversal extends EndpointFeature,
500506

501507
override string getValue(DataFlow::Node endpoint) {
502508
exists(DataFlow::InvokeNode invk |
503-
result = SyntacticUtilities::getSimpleAccessPath(invk.getCalleeNode()) and
509+
exists(string path |
510+
path = SyntacticUtilities::getSimpleAccessPath(invk.getCalleeNode()) and
511+
// collapse the unknown path to the empty string, as is convention for old features
512+
if path = "?" then result = "" else result = path
513+
) and
504514
(
505515
invk.getAnArgument() = endpoint or
506516
SyntacticUtilities::getANestedInitializerValue(invk.getAnArgument()

0 commit comments

Comments
 (0)