Skip to content

Commit ad97b6d

Browse files
committed
Use access path for str.join model
1 parent b384404 commit ad97b6d

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

python/ql/lib/semmle/python/dataflow/new/internal/TaintTrackingPrivate.qll

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ predicate stringManipulation(DataFlow::CfgNode nodeFrom, DataFlow::CfgNode nodeT
150150
nodeFrom.getNode() = object and
151151
method_name in ["partition", "rpartition", "rsplit", "split", "splitlines"]
152152
or
153-
// Iterable[str] -> str
154-
// TODO: check if these should be handled differently in regards to content
155-
method_name = "join" and
156-
nodeFrom.getNode() = call.getArg(0)
157-
or
158153
// Mapping[str, Any] -> str
159154
method_name = "format_map" and
160155
nodeFrom.getNode() = call.getArg(0)

python/ql/lib/semmle/python/frameworks/Stdlib.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4976,6 +4976,23 @@ module StdlibPrivate {
49764976
}
49774977
}
49784978

4979+
/** A flow summary for `str.join`. */
4980+
class StrJoinSummary extends SummarizedCallable::Range {
4981+
StrJoinSummary() { this = "str.join" }
4982+
4983+
override DataFlow::CallCfgNode getACall() { result.(DataFlow::MethodCallNode).calls(_, "join") }
4984+
4985+
override DataFlow::ArgumentNode getACallback() {
4986+
result.(DataFlow::AttrRead).getAttributeName() = "join"
4987+
}
4988+
4989+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
4990+
input = ["Argument[0,iterable:]", "Argument[0,iterable:].ListElement"] and
4991+
output = "ReturnValue" and
4992+
preservesValue = false
4993+
}
4994+
}
4995+
49794996
// ---------------------------------------------------------------------------
49804997
// asyncio
49814998
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)