Python: Let the user help us identifying callbacks

This commit is contained in:
yoff
2022-05-23 11:07:47 +00:00
committed by GitHub
parent dac1b6867a
commit 8b9915e372
4 changed files with 33 additions and 4 deletions

View File

@@ -7,6 +7,8 @@ private class SummarizedCallableIdentity extends SummarizedCallable {
override Call getACall() { result.getFunc().(Name).getId() = this }
override DataFlow::ArgumentNode getACallback() { result.asExpr().(Name).getId() = this }
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[0]" and
output = "ReturnValue" and
@@ -20,6 +22,8 @@ private class SummarizedCallableApplyLambda extends SummarizedCallable {
override Call getACall() { result.getFunc().(Name).getId() = this }
override DataFlow::ArgumentNode getACallback() { result.asExpr().(Name).getId() = this }
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[1]" and
output = "Argument[0].Parameter[0]" and
@@ -36,6 +40,8 @@ private class SummarizedCallableReversed extends SummarizedCallable {
override Call getACall() { result.getFunc().(Name).getId() = this }
override DataFlow::ArgumentNode getACallback() { result.asExpr().(Name).getId() = this }
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[0].ListElement" and
output = "ReturnValue.ListElement" and
@@ -48,6 +54,8 @@ private class SummarizedCallableMap extends SummarizedCallable {
override Call getACall() { result.getFunc().(Name).getId() = this }
override DataFlow::ArgumentNode getACallback() { result.asExpr().(Name).getId() = this }
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[1].ListElement" and
output = "Argument[0].Parameter[0]" and
@@ -68,6 +76,10 @@ private class SummarizedCallableJsonLoads extends SummarizedCallable {
result = API::moduleImport("json").getMember("loads").getACall().asExpr()
}
override DataFlow::ArgumentNode getACallback() {
result = API::moduleImport("json").getMember("loads").getAUse()
}
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
input = "Argument[0]" and
output = "ReturnValue.ListElement" and