Skip to content

Commit 1893b9f

Browse files
authored
Merge pull request #7376 from github/henrymercer/js-atm-absent-features-optimization
JS: Update featurization for absent features optimization
2 parents c41ec1f + 144ec8c commit 1893b9f

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ private module FunctionNames {
284284
}
285285

286286
/** Get a name of a supported generic token-based feature. */
287-
private string getASupportedFeatureName() {
287+
string getASupportedFeatureName() {
288288
result =
289289
[
290290
"enclosingFunctionName", "calleeName", "receiverName", "argumentIndex", "calleeApiName",
@@ -301,12 +301,5 @@ private string getASupportedFeatureName() {
301301
predicate tokenFeatures(DataFlow::Node endpoint, string featureName, string featureValue) {
302302
// Performance optimization: Restrict feature extraction to endpoints we've explicitly asked to featurize.
303303
endpoint = any(FeaturizationConfig cfg).getAnEndpointToFeaturize() and
304-
(
305-
if strictcount(getTokenFeature(endpoint, featureName)) = 1
306-
then featureValue = getTokenFeature(endpoint, featureName)
307-
else (
308-
// Performance note: this is a Cartesian product between all endpoints and feature names.
309-
featureValue = "" and featureName = getASupportedFeatureName()
310-
)
311-
)
304+
featureValue = getTokenFeature(endpoint, featureName)
312305
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ module ModelScoring {
3636
private int getARequestedEndpointType() { result = any(EndpointType type).getEncoding() }
3737

3838
predicate endpointScores(DataFlow::Node endpoint, int encodedEndpointType, float score) =
39-
scoreEndpoints(getARequestedEndpoint/0, getARequestedEndpointType/0,
40-
EndpointFeatures::tokenFeatures/3, getACompatibleModelChecksum/0)(endpoint,
41-
encodedEndpointType, score)
39+
scoreEndpoints(getARequestedEndpoint/0, EndpointFeatures::tokenFeatures/3,
40+
EndpointFeatures::getASupportedFeatureName/0, getARequestedEndpointType/0,
41+
getACompatibleModelChecksum/0)(endpoint, encodedEndpointType, score)
4242
}
4343

4444
/**

0 commit comments

Comments
 (0)