Skip to content

Commit b2fbbc6

Browse files
committed
Python: add a flow summary
we could consider adding non-value-preserving flow from input to output
1 parent f6d807a commit b2fbbc6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Provides classes modeling security-relevant aspects of built-ins.
3+
*/
4+
5+
import python
6+
private import semmle.python.dataflow.new.FlowSummary
7+
private import semmle.python.ApiGraphs
8+
9+
/** A flow summary for `reversed`. */
10+
class ReversedSummary extends SummarizedCallable {
11+
ReversedSummary() { this = "builtins.reversed" }
12+
13+
override CallNode getACall() { result = API::builtin("reversed").getACall().getNode() }
14+
15+
override DataFlow::ArgumentNode getACallback() {
16+
result = API::builtin("reversed").getAValueReachableFromSource()
17+
}
18+
19+
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
20+
input = "Argument[0].ListElement" and
21+
output = "ReturnValue.ListElement" and
22+
preservesValue = true
23+
}
24+
}

0 commit comments

Comments
 (0)