Skip to content

Commit 3aa4e29

Browse files
author
Stephan Brandauer
committed
remove obsolete features
1 parent ed75080 commit 3aa4e29

File tree

1 file changed

+2
-132
lines changed
  • javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling

1 file changed

+2
-132
lines changed

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

Lines changed: 2 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,7 @@ private module FunctionNames {
193193
/** Get a name of a supported generic token-based feature. */
194194
string getASupportedFeatureName() {
195195
// allowlist of vetted features that are permitted in production
196-
result =
197-
any(EndpointFeature f |
198-
f instanceof EnclosingFunctionName or
199-
f instanceof CalleeName or
200-
f instanceof ReceiverName or
201-
f instanceof ArgumentIndex or
202-
f instanceof CalleeApiName or
203-
f instanceof CalleeAccessPath or
204-
f instanceof CalleeAccessPathWithStructuralInfo or
205-
f instanceof EnclosingFunctionBody
206-
).getName()
196+
result = any(EndpointFeature f).getName()
207197
}
208198

209199
/**
@@ -223,12 +213,7 @@ predicate tokenFeatures(DataFlow::Node endpoint, string featureName, string feat
223213
*/
224214
private newtype TEndpointFeature =
225215
TEnclosingFunctionName() or
226-
TCalleeName() or
227216
TReceiverName() or
228-
TArgumentIndex() or
229-
TCalleeApiName() or
230-
TCalleeAccessPath() or
231-
TCalleeAccessPathWithStructuralInfo() or
232217
TEnclosingFunctionBody() or
233218
TFileImports() or
234219
TCalleeImports() or
@@ -241,7 +226,7 @@ private newtype TEndpointFeature =
241226
TStringConcatenatedWith()
242227

243228
/**
244-
* An implementation of an endpoint feature: produces feature names and values for used in ML.
229+
* An implementation of an endpoint feature: produces feature names and values for use in ML.
245230
*/
246231
abstract class EndpointFeature extends TEndpointFeature {
247232
/**
@@ -271,22 +256,6 @@ class EnclosingFunctionName extends EndpointFeature, TEnclosingFunctionName {
271256
}
272257
}
273258

274-
/**
275-
* The feature for the name of the function being called, e.g. in a call `Artist.findOne(...)`, this is `findOne`.
276-
*/
277-
class CalleeName extends EndpointFeature, TCalleeName {
278-
override string getName() { result = "calleeName" }
279-
280-
override string getValue(DataFlow::Node endpoint) {
281-
result =
282-
strictconcat(DataFlow::CallNode call, string component |
283-
endpoint = call.getAnArgument() and component = call.getCalleeName()
284-
|
285-
component, " "
286-
)
287-
}
288-
}
289-
290259
/**
291260
* The feature for the name of the receiver of the call, e.g. in a call `Artist.findOne(...)`, this is `Artist`.
292261
*/
@@ -304,105 +273,6 @@ class ReceiverName extends EndpointFeature, TReceiverName {
304273
}
305274
}
306275

307-
/**
308-
* The feature for the argument index of the endpoint, e.g. in `f(a, endpoint, b)`, this is 1.
309-
*/
310-
class ArgumentIndex extends EndpointFeature, TArgumentIndex {
311-
override string getName() { result = "argumentIndex" }
312-
313-
override string getValue(DataFlow::Node endpoint) {
314-
result =
315-
strictconcat(DataFlow::CallNode call, string component |
316-
endpoint = call.getAnArgument() and
317-
component = any(int argIndex | call.getArgument(argIndex) = endpoint).toString()
318-
|
319-
component, " "
320-
)
321-
}
322-
}
323-
324-
/**
325-
* The feature for the name of the API that the function being called originates from, if the function being
326-
* called originates from an external API. For example, the endpoint here:
327-
*
328-
* ```js
329-
* const mongoose = require('mongoose'),
330-
* User = mongoose.model('User', null);
331-
* User.findOne(ENDPOINT);
332-
* ```
333-
*/
334-
class CalleeApiName extends EndpointFeature, TCalleeApiName {
335-
override string getName() { result = "calleeApiName" }
336-
337-
override string getValue(DataFlow::Node endpoint) {
338-
result =
339-
strictconcat(API::Node apiNode, string component |
340-
endpoint = apiNode.getInducingNode().(DataFlow::CallNode).getAnArgument() and
341-
AccessPaths::accessPaths(apiNode, false, _, component)
342-
|
343-
component, " "
344-
)
345-
}
346-
}
347-
348-
/**
349-
* The access path of the function being called, both without structural info, if the
350-
* function being called originates from an external API. For example, the endpoint here:
351-
*
352-
* ```js
353-
* const mongoose = require('mongoose'),
354-
* User = mongoose.model('User', null);
355-
* User.findOne(ENDPOINT);
356-
* ```
357-
*
358-
* would have a callee access path without structural info of `mongoose model findOne`.
359-
*/
360-
class CalleeAccessPath extends EndpointFeature, TCalleeAccessPath {
361-
override string getName() { result = "calleeAccessPath" }
362-
363-
override string getValue(DataFlow::Node endpoint) {
364-
result =
365-
concat(API::Node node, string accessPath |
366-
node.getInducingNode().(DataFlow::CallNode).getAnArgument() = endpoint and
367-
AccessPaths::accessPaths(node, false, accessPath, _)
368-
|
369-
accessPath, " "
370-
)
371-
}
372-
}
373-
374-
/**
375-
* The access path of the function being called, both with structural info, if the
376-
* function being called originates from an external API. For example, the endpoint here:
377-
*
378-
* ```js
379-
* const mongoose = require('mongoose'),
380-
* User = mongoose.model('User', null);
381-
* User.findOne(ENDPOINT);
382-
* ```
383-
*
384-
* would have a callee access path with structural info of
385-
* `mongoose member model instanceorreturn member findOne instanceorreturn`
386-
*
387-
* These features indicate that the callee comes from (reading the access path backwards) an
388-
* instance of the `findOne` member of an instance of the `model` member of the `mongoose`
389-
* external library.
390-
*/
391-
class CalleeAccessPathWithStructuralInfo extends EndpointFeature,
392-
TCalleeAccessPathWithStructuralInfo {
393-
override string getName() { result = "calleeAccessPathWithStructuralInfo" }
394-
395-
override string getValue(DataFlow::Node endpoint) {
396-
result =
397-
concat(API::Node node, string accessPath |
398-
node.getInducingNode().(DataFlow::CallNode).getAnArgument() = endpoint and
399-
AccessPaths::accessPaths(node, true, accessPath, _)
400-
|
401-
accessPath, " "
402-
)
403-
}
404-
}
405-
406276
/**
407277
* The feature for the natural language tokens from the function that encloses the endpoint in
408278
* the order that they appear in the source code.

0 commit comments

Comments
 (0)