C#/Java: Invert api filtering logic.

This commit is contained in:
Michael Nebel
2024-05-08 10:25:11 +02:00
parent 5e2e224c9c
commit f00ad7c0e7
6 changed files with 25 additions and 15 deletions

View File

@@ -7,7 +7,7 @@ private import CaptureModelsSpecific
private import CaptureModelsPrinting
class DataFlowTargetApi extends TargetApiSpecific {
DataFlowTargetApi() { isRelevantForDataFlowModels(this) }
DataFlowTargetApi() { not isUninterestingForDataFlowModels(this) }
}
private module Printing implements PrintingSig {

View File

@@ -63,13 +63,20 @@ private predicate hasManualModel(Callable api) {
}
/**
* Holds if it is relevant to generate models for `api` based on data flow analysis.
* Holds if it is irrelevant to generate models for `api` based on data flow analysis.
*
* This serves as an extra filter for the `relevant` predicate.
*/
predicate isRelevantForDataFlowModels(Callable api) {
(not api.getDeclaringType() instanceof J::Interface or exists(api.getBody()))
predicate isUninterestingForDataFlowModels(Callable api) {
api.getDeclaringType() instanceof J::Interface and not exists(api.getBody())
}
predicate isRelevantForTypeBasedFlowModels(Callable api) { any() }
/**
* Holds if it is irrelevant to generate models for `api` based on type-based analysis.
*
* This serves as an extra filter for the `relevant` predicate.
*/
predicate isUninterestingForTypeBasedFlowModels(Callable api) { none() }
/**
* A class of Callables that are relevant for generating summary, source and sinks models for.

View File

@@ -296,7 +296,7 @@ private module ModelPrinting = PrintingImpl<Printing>;
* on the Theorems for Free approach.
*/
class TypeBasedFlowTargetApi extends Specific::TargetApiSpecific {
TypeBasedFlowTargetApi() { Specific::isRelevantForTypeBasedFlowModels(this) }
TypeBasedFlowTargetApi() { not Specific::isUninterestingForTypeBasedFlowModels(this) }
/**
* Gets the string representation of all type based summaries for `this`