mirror of
https://github.com/github/codeql.git
synced 2025-12-22 03:36:30 +01:00
ruby/python: remove predicates from interface
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Provides the implementation of a summary type tracker, that is type tracking through flow summaries.
|
||||
* Provides the implementation of type tracking steps through flow summaries.
|
||||
* To use this, you must implement the `Input` signature. You can then use the predicates in the `Output`
|
||||
* signature to implement the predicates of the same names inside `TypeTrackerSpecific.qll`.
|
||||
*/
|
||||
|
||||
/** The classes and predicates needed to generate a summary type tracker. */
|
||||
/** The classes and predicates needed to generate type-tracking steps from summaries. */
|
||||
signature module Input {
|
||||
// Dataflow nodes
|
||||
class Node;
|
||||
@@ -80,13 +80,6 @@ signature module Input {
|
||||
/** Gets a dataflow node respresenting the return of `callable` indicated by `return`. */
|
||||
Node returnOf(Node callable, SummaryComponent return);
|
||||
|
||||
// Specific summary handling
|
||||
/** Holds if component should be treated as a level step by type tracking. */
|
||||
predicate componentLevelStep(SummaryComponent component);
|
||||
|
||||
/** Holds if the given component can't be evaluated by `evaluateSummaryComponentStackLocal`. */
|
||||
predicate isNonLocal(SummaryComponent component);
|
||||
|
||||
// Relating callables to nodes
|
||||
/** Gets a dataflow node respresenting a call to `callable`. */
|
||||
Node callTo(SummarizedCallable callable);
|
||||
@@ -146,8 +139,8 @@ module SummaryFlow<Input I> implements Output<I> {
|
||||
I::SummaryComponentStack output
|
||||
) {
|
||||
callable.propagatesFlow(I::push(I::content(contents), input), output, true) and
|
||||
not I::isNonLocal(input.head()) and
|
||||
not I::isNonLocal(output.head())
|
||||
not isNonLocal(input.head()) and
|
||||
not isNonLocal(output.head())
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
@@ -155,8 +148,8 @@ module SummaryFlow<Input I> implements Output<I> {
|
||||
I::SummarizedCallable callable, I::TypeTrackerContent contents, I::SummaryComponentStack input,
|
||||
I::SummaryComponentStack output
|
||||
) {
|
||||
not I::isNonLocal(input.head()) and
|
||||
not I::isNonLocal(output.head()) and
|
||||
not isNonLocal(input.head()) and
|
||||
not isNonLocal(output.head()) and
|
||||
(
|
||||
callable.propagatesFlow(input, I::push(I::content(contents), output), true)
|
||||
or
|
||||
@@ -178,8 +171,8 @@ module SummaryFlow<Input I> implements Output<I> {
|
||||
callable
|
||||
.propagatesFlow(I::push(I::content(loadContents), input),
|
||||
I::push(I::content(storeContents), output), true) and
|
||||
not I::isNonLocal(input.head()) and
|
||||
not I::isNonLocal(output.head())
|
||||
not isNonLocal(input.head()) and
|
||||
not isNonLocal(output.head())
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
@@ -190,8 +183,8 @@ module SummaryFlow<Input I> implements Output<I> {
|
||||
exists(I::TypeTrackerContent content |
|
||||
callable.propagatesFlow(I::push(I::withoutContent(content), input), output, true) and
|
||||
filter = I::getFilterFromWithoutContentStep(content) and
|
||||
not I::isNonLocal(input.head()) and
|
||||
not I::isNonLocal(output.head()) and
|
||||
not isNonLocal(input.head()) and
|
||||
not isNonLocal(output.head()) and
|
||||
input != output
|
||||
)
|
||||
}
|
||||
@@ -204,12 +197,26 @@ module SummaryFlow<Input I> implements Output<I> {
|
||||
exists(I::TypeTrackerContent content |
|
||||
callable.propagatesFlow(I::push(I::withContent(content), input), output, true) and
|
||||
filter = I::getFilterFromWithContentStep(content) and
|
||||
not I::isNonLocal(input.head()) and
|
||||
not I::isNonLocal(output.head()) and
|
||||
not isNonLocal(input.head()) and
|
||||
not isNonLocal(output.head()) and
|
||||
input != output
|
||||
)
|
||||
}
|
||||
|
||||
private predicate componentLevelStep(I::SummaryComponent component) {
|
||||
exists(I::TypeTrackerContent content |
|
||||
component = I::withoutContent(content) and
|
||||
not exists(I::getFilterFromWithoutContentStep(content))
|
||||
)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate isNonLocal(I::SummaryComponent component) {
|
||||
component = I::content(_)
|
||||
or
|
||||
component = I::withContent(_)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a data flow I::Node corresponding an argument or return value of `call`,
|
||||
* as specified by `component`.
|
||||
@@ -255,7 +262,7 @@ module SummaryFlow<Input I> implements Output<I> {
|
||||
I::SummarizedCallable callable, I::SummaryComponent head, I::SummaryComponentStack tail
|
||||
) {
|
||||
dependsOnSummaryComponentStackCons(callable, head, tail) and
|
||||
not I::isNonLocal(head)
|
||||
not isNonLocal(head)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
@@ -290,7 +297,7 @@ module SummaryFlow<Input I> implements Output<I> {
|
||||
or
|
||||
result = I::returnOf(prev, head)
|
||||
or
|
||||
I::componentLevelStep(head) and
|
||||
componentLevelStep(head) and
|
||||
result = prev
|
||||
)
|
||||
}
|
||||
|
||||
@@ -255,14 +255,6 @@ module SummaryTypeTrackerInput implements SummaryTypeTracker::Input {
|
||||
callable.getALocalSource().asExpr().(CallableExpr).getInnerScope().getAReturnValueFlowNode()
|
||||
}
|
||||
|
||||
// Specific summary handling
|
||||
predicate componentLevelStep(SummaryComponent component) { none() }
|
||||
|
||||
pragma[nomagic]
|
||||
predicate isNonLocal(SummaryComponent component) {
|
||||
component = FlowSummary::SummaryComponent::content(_)
|
||||
}
|
||||
|
||||
// Relating callables to nodes
|
||||
Node callTo(SummarizedCallable callable) { result = callable.getACallSimple() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user