Skip to content

Commit 67500f8

Browse files
author
Stephan Brandauer
committed
performance fixes
1 parent 96919ee commit 67500f8

File tree

1 file changed

+12
-6
lines changed
  • javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ class EnclosingFunctionBody extends EndpointFeature, TEnclosingFunctionBody {
409409
override string getName() { result = "enclosingFunctionBody" }
410410

411411
override string getValue(DataFlow::Node endpoint) {
412+
endpoint = any(FeaturizationConfig cfg).getAnEndpointToFeaturize() and
412413
result =
413414
FunctionBodyFeatures::getBodyTokensFeature(FunctionBodyFeatures::getRepresentativeFunctionForEndpoint(endpoint))
414415
}
@@ -433,12 +434,7 @@ class FileImports extends EndpointFeature, TFileImports {
433434
override string getName() { result = "fileImports" }
434435

435436
override string getValue(DataFlow::Node endpoint) {
436-
result =
437-
concat(string importPath |
438-
importPath = SyntacticUtilities::getImportPathForFile(endpoint.getFile())
439-
|
440-
importPath, " " order by importPath
441-
)
437+
result = SyntacticUtilities::getImportPathsForFile(endpoint.getFile())
442438
}
443439
}
444440

@@ -539,6 +535,16 @@ class ContextFunctionInterfaces extends EndpointFeature, TContextFunctionInterfa
539535
* Syntactic utilities for feature value computation.
540536
*/
541537
private module SyntacticUtilities {
538+
/** Gets all the imports defined in the file containing the endpoint. */
539+
string getImportPathsForFile(File file) {
540+
result =
541+
concat(string importPath |
542+
importPath = SyntacticUtilities::getImportPathForFile(file)
543+
|
544+
importPath, " " order by importPath
545+
)
546+
}
547+
542548
/** Gets an import located in `file`. */
543549
string getImportPathForFile(File file) {
544550
result = any(Import imp | imp.getFile() = file).getImportedPath().getValue()

0 commit comments

Comments
 (0)