C#/Java: Exclude summaries using callbacks in fields, properties and synthetic fields.

This commit is contained in:
Michael Nebel
2024-10-29 09:26:01 +01:00
parent 5c389355d0
commit 55cfbccd43
4 changed files with 36 additions and 0 deletions

View File

@@ -206,6 +206,11 @@ signature module ModelGeneratorInputSig<LocationSig Location, InputSig<Location>
*/
predicate isField(Lang::ContentSet c);
/**
* Holds if the content set `c` is callback like.
*/
predicate isCallback(Lang::ContentSet c);
/**
* Gets the MaD synthetic name string representation for the content set `c`, if any.
*/
@@ -618,6 +623,20 @@ module MakeModelGenerator<
isField(ap.getAtIndex(_))
}
/**
* Holds if this access path `ap` mentions a callback.
*/
private predicate mentionsCallback(PropagateContentFlow::AccessPath ap) {
isCallback(ap.getAtIndex(_))
}
/**
* Models as Data currently doesn't support callback logic in fields.
*/
private predicate validateAccessPath(PropagateContentFlow::AccessPath ap) {
not (mentionsField(ap) and mentionsCallback(ap))
}
private predicate apiFlow(
DataFlowSummaryTargetApi api, DataFlow::ParameterNode p,
PropagateContentFlow::AccessPath reads, ReturnNodeExt returnNodeExt,
@@ -859,6 +878,8 @@ module MakeModelGenerator<
input = parameterNodeAsContentInput(p) + printReadAccessPath(reads) and
output = getContentOutput(returnNodeExt) + printStoreAccessPath(stores) and
input != output and
validateAccessPath(reads) and
validateAccessPath(stores) and
(
if mentionsField(reads) or mentionsField(stores)
then lift = false and api.isRelevant()