Replace string kind with boolean preservesValue

This commit is contained in:
Tom Hvitved
2021-09-22 09:28:55 +02:00
parent cdc359527a
commit a37737d065
3 changed files with 13 additions and 12 deletions

View File

@@ -96,7 +96,7 @@ abstract class SummarizedCallable extends LibraryCallable {
* but uses an external (string) representation of the input and output stacks.
*/
pragma[nomagic]
predicate propagatesFlowExt(string input, string output, string kind) { none() }
predicate propagatesFlowExt(string input, string output, boolean preservesValue) { none() }
/**
* Holds if values stored inside `content` are cleared on objects passed as

View File

@@ -45,9 +45,10 @@ DataFlowType getCallbackReturnType(DataFlowType t, ReturnKind rk) { any() }
* `input`, output specification `output`, and kind `kind`.
*/
predicate summaryElement(DataFlowCallable c, string input, string output, string kind) {
exists(FlowSummary::SummarizedCallable sc |
sc.propagatesFlowExt(input, output, kind) and
c.asLibraryCallable() = sc
exists(FlowSummary::SummarizedCallable sc, boolean preservesValue |
sc.propagatesFlowExt(input, output, preservesValue) and
c.asLibraryCallable() = sc and
if preservesValue = true then kind = "value" else kind = "taint"
)
}

View File

@@ -18,10 +18,10 @@ private class SummarizedCallableIdentity extends SummarizedCallable {
override MethodCall getACall() { result.getMethodName() = this }
override predicate propagatesFlowExt(string input, string output, string kind) {
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[0]" and
output = "ReturnValue" and
kind = "value"
preservesValue = true
}
}
@@ -30,14 +30,14 @@ private class SummarizedCallableApplyBlock extends SummarizedCallable {
override MethodCall getACall() { result.getMethodName() = this }
override predicate propagatesFlowExt(string input, string output, string kind) {
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[0]" and
output = "Parameter[0] of BlockArgument" and
kind = "value"
preservesValue = true
or
input = "ReturnValue of BlockArgument" and
output = "ReturnValue" and
kind = "value"
preservesValue = true
}
}
@@ -46,14 +46,14 @@ private class SummarizedCallableApplyLambda extends SummarizedCallable {
override MethodCall getACall() { result.getMethodName() = this }
override predicate propagatesFlowExt(string input, string output, string kind) {
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[1]" and
output = "Parameter[0] of Argument[0]" and
kind = "value"
preservesValue = true
or
input = "ReturnValue of Argument[0]" and
output = "ReturnValue" and
kind = "value"
preservesValue = true
}
}