mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Python: Support more dictionary read/store steps
The `setdefault` behavior is kinda strange, but no reason not to support it.
This commit is contained in:
@@ -35,24 +35,24 @@ def SINK_F(x):
|
||||
def test_dict_literal():
|
||||
d = {"key": SOURCE}
|
||||
SINK(d["key"]) # $ flow="SOURCE, l:-1 -> d['key']"
|
||||
SINK(d.get("key")) # $ MISSING: flow
|
||||
SINK(d.setdefault("key", NONSOURCE)) # $ MISSING: flow
|
||||
SINK(d.get("key")) # $ flow="SOURCE, l:-2 -> d.get(..)"
|
||||
SINK(d.setdefault("key", NONSOURCE)) # $ flow="SOURCE, l:-3 -> d.setdefault(..)"
|
||||
|
||||
|
||||
@expects(3) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
|
||||
def test_dict_update():
|
||||
d = {}
|
||||
d["key"] = SOURCE
|
||||
SINK(d["key"]) # $ MISSING: flow
|
||||
SINK(d.get("key")) # $ MISSING: flow
|
||||
SINK(d.setdefault("key", NONSOURCE)) # $ MISSING: flow
|
||||
SINK(d["key"]) # $ flow="SOURCE, l:-1 -> d['key']"
|
||||
SINK(d.get("key")) # $ flow="SOURCE, l:-2 -> d.get(..)"
|
||||
SINK(d.setdefault("key", NONSOURCE)) # $ flow="SOURCE, l:-3 -> d.setdefault(..)"
|
||||
|
||||
|
||||
@expects(2) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
|
||||
def test_dict_override():
|
||||
d = {}
|
||||
d["key"] = SOURCE
|
||||
SINK(d["key"]) # $ MISSING: flow
|
||||
SINK(d["key"]) # $ flow="SOURCE, l:-1 -> d['key']"
|
||||
|
||||
d["key"] = NONSOURCE
|
||||
SINK_F(d["key"])
|
||||
@@ -61,7 +61,7 @@ def test_dict_override():
|
||||
def test_dict_setdefault():
|
||||
d = {}
|
||||
d.setdefault("key", SOURCE)
|
||||
SINK(d["key"]) # $ MISSING: flow
|
||||
SINK(d["key"]) # $ flow="SOURCE, l:-1 -> d['key']"
|
||||
|
||||
|
||||
@expects(3) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
|
||||
|
||||
Reference in New Issue
Block a user