File tree Expand file tree Collapse file tree
javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -469,21 +469,33 @@ private module SyntacticUtilities {
469469 if e instanceof VarAccess
470470 then result = e .( VarAccess ) .getName ( )
471471 else
472- if e instanceof AwaitExpr
473- then result = getSimpleAccessPath ( e . ( AwaitExpr ) . getOperand ( ) . flow ( ) ) + ".then( )"
472+ if e instanceof Import
473+ then result = "import(" + getSimpleImportPath ( e ) + ")"
474474 else
475- if node instanceof DataFlow:: PropRead
476- then
477- result =
478- getSimpleAccessPath ( node .( DataFlow:: PropRead ) .getBase ( ) ) + "." +
479- getPropertyNameOrUnknown ( node )
475+ if e instanceof AwaitExpr
476+ then result = getSimpleAccessPath ( e .( AwaitExpr ) .getOperand ( ) .flow ( ) ) + ".then()"
480477 else
481- if node instanceof DataFlow:: InvokeNode
478+ if node instanceof DataFlow:: PropRead
482479 then
483- result = getSimpleAccessPath ( node .( DataFlow:: InvokeNode ) .getCalleeNode ( ) ) + "()"
484- else result = "?"
480+ result =
481+ getSimpleAccessPath ( node .( DataFlow:: PropRead ) .getBase ( ) ) + "." +
482+ getPropertyNameOrUnknown ( node )
483+ else
484+ if node instanceof DataFlow:: InvokeNode
485+ then
486+ result = getSimpleAccessPath ( node .( DataFlow:: InvokeNode ) .getCalleeNode ( ) ) + "()"
487+ else result = "?"
485488 )
486489 }
490+
491+ string getSimpleImportPath ( Import i ) {
492+ if exists ( i .getImportedPath ( ) .getValue ( ) )
493+ then
494+ exists ( string p | p = i .getImportedPath ( ) .getValue ( ) |
495+ if p .matches ( ".%" ) then result = p else result = "!" // hide absolute imports from the ML training
496+ )
497+ else result = "?"
498+ }
487499}
488500
489501/**
You can’t perform that action at this time.
0 commit comments