Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,14 @@ private module Cached {
none() and
// We want to prune irrelevant models before materialising data flow nodes, so types contributed
// directly from CodeQL must expose their pruning info without depending on data flow nodes.
(any(ModelInput::TypeModel tm).isTypeUsed("") implies any())
(isTypeUsedLocal() implies any())
}

overlay[global]
private predicate isTypeUsedGlobal() { any(ModelInput::TypeModel tm).isTypeUsed("") }

private predicate isTypeUsedLocal() = forceLocal(isTypeUsedGlobal/0)()

cached
private module Backref {
cached
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,20 +393,31 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
)
}

pragma[nomagic]
private predicate isTypeMentionedInModel(string type) {
sourceModel(type, _, _, _) or
sinkModel(type, _, _, _) or
summaryModel(type, _, _, _, _, _) or
typeModel(_, type, _)
}

overlay[global]
private predicate isTypeUsedGlobal(string type) {
isTypeMentionedInModel(type) and any(TypeModel tm).isTypeUsed(type)
}

overlay[local]
private predicate isTypeUsedLocal(string type) = forceLocal(isTypeUsedGlobal/1)(type)

/**
* Holds if rows involving `type` might be relevant for the analysis of this database.
*/
predicate isRelevantType(string type) {
(
sourceModel(type, _, _, _) or
sinkModel(type, _, _, _) or
summaryModel(type, _, _, _, _, _) or
typeModel(_, type, _)
) and
isTypeMentionedInModel(type) and
(
Specific::isTypeUsed(type)
or
any(TypeModel model).isTypeUsed(type)
isTypeUsedLocal(type)
or
exists(TestAllModels t)
)
Expand Down
1 change: 0 additions & 1 deletion javascript/ql/test/library-tests/frameworks/data/test.ql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import javascript
deprecated import utils.test.ConsistencyChecking
import semmle.javascript.frameworks.data.internal.ApiGraphModels as ApiGraphModels

overlay[local]
class TypeModelFromCodeQL extends ModelInput::TypeModel {
override predicate isTypeUsed(string type) { type = "danger-constant" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,20 +393,31 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
)
}

pragma[nomagic]
private predicate isTypeMentionedInModel(string type) {
sourceModel(type, _, _, _) or
sinkModel(type, _, _, _) or
summaryModel(type, _, _, _, _, _) or
typeModel(_, type, _)
}

overlay[global]
private predicate isTypeUsedGlobal(string type) {
isTypeMentionedInModel(type) and any(TypeModel tm).isTypeUsed(type)
}

overlay[local]
private predicate isTypeUsedLocal(string type) = forceLocal(isTypeUsedGlobal/1)(type)

/**
* Holds if rows involving `type` might be relevant for the analysis of this database.
*/
predicate isRelevantType(string type) {
(
sourceModel(type, _, _, _) or
sinkModel(type, _, _, _) or
summaryModel(type, _, _, _, _, _) or
typeModel(_, type, _)
) and
isTypeMentionedInModel(type) and
(
Specific::isTypeUsed(type)
or
any(TypeModel model).isTypeUsed(type)
isTypeUsedLocal(type)
or
exists(TestAllModels t)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,20 +393,31 @@ predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) {
)
}

pragma[nomagic]
private predicate isTypeMentionedInModel(string type) {
sourceModel(type, _, _, _) or
sinkModel(type, _, _, _) or
summaryModel(type, _, _, _, _, _) or
typeModel(_, type, _)
}

overlay[global]
private predicate isTypeUsedGlobal(string type) {
isTypeMentionedInModel(type) and any(TypeModel tm).isTypeUsed(type)
}

overlay[local]
private predicate isTypeUsedLocal(string type) = forceLocal(isTypeUsedGlobal/1)(type)

/**
* Holds if rows involving `type` might be relevant for the analysis of this database.
*/
predicate isRelevantType(string type) {
(
sourceModel(type, _, _, _) or
sinkModel(type, _, _, _) or
summaryModel(type, _, _, _, _, _) or
typeModel(_, type, _)
) and
isTypeMentionedInModel(type) and
(
Specific::isTypeUsed(type)
or
any(TypeModel model).isTypeUsed(type)
isTypeUsedLocal(type)
or
exists(TestAllModels t)
)
Expand Down
Loading