Skip to content

Commit 81d02cc

Browse files
author
Stephan Brandauer
committed
optimize performance of a helper-predicate
1 parent cdbab18 commit 81d02cc

File tree

1 file changed

+28
-25
lines changed
  • javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling

1 file changed

+28
-25
lines changed

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

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -515,31 +515,34 @@ private module SyntacticUtilities {
515515
*/
516516
string getSimpleAccessPath(DataFlow::Node node) {
517517
exists(Expr e | e = node.asExpr().getUnderlyingValue() |
518-
if e instanceof SuperAccess
519-
then result = "super"
520-
else
521-
if e instanceof ThisAccess
522-
then result = "this"
523-
else
524-
if e instanceof VarAccess
525-
then result = e.(VarAccess).getName()
526-
else
527-
if e instanceof Import
528-
then result = "import(" + getSimpleImportPath(e) + ")"
529-
else
530-
if e instanceof AwaitExpr
531-
then result = "(await " + getSimpleAccessPath(e.(AwaitExpr).getOperand().flow()) + ")"
532-
else
533-
if node instanceof DataFlow::PropRead
534-
then
535-
result =
536-
getSimpleAccessPath(node.(DataFlow::PropRead).getBase()) + "." +
537-
getPropertyNameOrUnknown(node)
538-
else
539-
if node instanceof DataFlow::InvokeNode
540-
then
541-
result = getSimpleAccessPath(node.(DataFlow::InvokeNode).getCalleeNode()) + "()"
542-
else result = getUnknownSymbol()
518+
if
519+
e instanceof SuperAccess or
520+
e instanceof ThisAccess or
521+
e instanceof VarAccess or
522+
e instanceof Import or
523+
e instanceof AwaitExpr or
524+
node instanceof DataFlow::PropRead or
525+
node instanceof DataFlow::InvokeNode
526+
then
527+
e instanceof SuperAccess and result = "super"
528+
or
529+
e instanceof ThisAccess and result = "this"
530+
or
531+
e instanceof VarAccess and result = e.(VarAccess).getName()
532+
or
533+
e instanceof Import and result = "import(" + getSimpleImportPath(e) + ")"
534+
or
535+
e instanceof AwaitExpr and
536+
result = "(await " + getSimpleAccessPath(e.(AwaitExpr).getOperand().flow()) + ")"
537+
or
538+
node instanceof DataFlow::PropRead and
539+
result =
540+
getSimpleAccessPath(node.(DataFlow::PropRead).getBase()) + "." +
541+
getPropertyNameOrUnknown(node)
542+
or
543+
(node instanceof DataFlow::InvokeNode and not e instanceof Import) and
544+
result = getSimpleAccessPath(node.(DataFlow::InvokeNode).getCalleeNode()) + "()"
545+
else result = getUnknownSymbol()
543546
)
544547
}
545548

0 commit comments

Comments
 (0)