Skip to content

Commit 402e2df

Browse files
committed
Sync files
1 parent 7f6c0f4 commit 402e2df

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,20 +393,31 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
393393
)
394394
}
395395

396+
pragma[nomagic]
397+
private predicate isTypeMentionedInModel(string type) {
398+
sourceModel(type, _, _, _) or
399+
sinkModel(type, _, _, _) or
400+
summaryModel(type, _, _, _, _, _) or
401+
typeModel(_, type, _)
402+
}
403+
404+
overlay[global]
405+
private predicate isTypeUsedGlobal(string type) {
406+
isTypeMentionedInModel(type) and any(TypeModel tm).isTypeUsed(type)
407+
}
408+
409+
overlay[local]
410+
private predicate isTypeUsedLocal(string type) = forceLocal(isTypeUsedGlobal/1)(type)
411+
396412
/**
397413
* Holds if rows involving `type` might be relevant for the analysis of this database.
398414
*/
399415
predicate isRelevantType(string type) {
400-
(
401-
sourceModel(type, _, _, _) or
402-
sinkModel(type, _, _, _) or
403-
summaryModel(type, _, _, _, _, _) or
404-
typeModel(_, type, _)
405-
) and
416+
isTypeMentionedInModel(type) and
406417
(
407418
Specific::isTypeUsed(type)
408419
or
409-
any(TypeModel model).isTypeUsed(type)
420+
isTypeUsedLocal(type)
410421
or
411422
exists(TestAllModels t)
412423
)

ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,20 +393,31 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
393393
)
394394
}
395395

396+
pragma[nomagic]
397+
private predicate isTypeMentionedInModel(string type) {
398+
sourceModel(type, _, _, _) or
399+
sinkModel(type, _, _, _) or
400+
summaryModel(type, _, _, _, _, _) or
401+
typeModel(_, type, _)
402+
}
403+
404+
overlay[global]
405+
private predicate isTypeUsedGlobal(string type) {
406+
isTypeMentionedInModel(type) and any(TypeModel tm).isTypeUsed(type)
407+
}
408+
409+
overlay[local]
410+
private predicate isTypeUsedLocal(string type) = forceLocal(isTypeUsedGlobal/1)(type)
411+
396412
/**
397413
* Holds if rows involving `type` might be relevant for the analysis of this database.
398414
*/
399415
predicate isRelevantType(string type) {
400-
(
401-
sourceModel(type, _, _, _) or
402-
sinkModel(type, _, _, _) or
403-
summaryModel(type, _, _, _, _, _) or
404-
typeModel(_, type, _)
405-
) and
416+
isTypeMentionedInModel(type) and
406417
(
407418
Specific::isTypeUsed(type)
408419
or
409-
any(TypeModel model).isTypeUsed(type)
420+
isTypeUsedLocal(type)
410421
or
411422
exists(TestAllModels t)
412423
)

0 commit comments

Comments
 (0)