Skip to content

Commit dca03d7

Browse files
committed
reinstate the AST node limit to minimize change to feature values
1 parent d5ab119 commit dca03d7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ Function getFeaturizableFunction(Function f) {
144144
* `enclosingFunctionBody` feature for an endpoint.
145145
*/
146146
string getBodyTokensFeature(Function function) {
147+
// Performance optimization: If a function has more than 256 body subtokens, then featurize it as
148+
// absent. This approximates the behavior of the classifer on non-generic body features where
149+
// large body features are replaced by the absent token.
150+
strictcount(ASTNode node |
151+
node = getAnASTNodeToFeaturize(function) and
152+
exists(getTokenizedAstNode(node))
153+
) <= 256 and
147154
// Performance optimization: If a function has more than getMaxChars() characters in its body subtokens,
148155
// then featurize it as absent.
149156
function = getFeaturizableFunction(function) and

0 commit comments

Comments
 (0)