File tree Expand file tree Collapse file tree 4 files changed +17
-12
lines changed
lib/semmle/python/dataflow/new/internal
experimental/dataflow/fieldflow Expand file tree Collapse file tree 4 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ module syntheticPostUpdateNode {
126
126
* Certain arguments, such as implicit self arguments are already post-update nodes
127
127
* and should not have an extra node synthesised.
128
128
*/
129
- ArgumentNode argumentPreUpdateNode ( ) {
129
+ Node argumentPreUpdateNode ( ) {
130
130
result = any ( FunctionCall c ) .getArg ( _)
131
131
or
132
132
// Avoid argument 0 of method calls as those have read post-update nodes.
@@ -136,6 +136,11 @@ module syntheticPostUpdateNode {
136
136
or
137
137
// Avoid argument 0 of class calls as those have non-synthetic post-update nodes.
138
138
exists ( ClassCall c , int n | n > 0 | result = c .getArg ( n ) )
139
+ or
140
+ // any argument of any call that we have not been able to resolve
141
+ exists ( CallNode call | not call = any ( DataFlowCall c ) .getNode ( ) |
142
+ result .( CfgNode ) .getNode ( ) in [ call .getArg ( _) , call .getArgByName ( _) ]
143
+ )
139
144
}
140
145
141
146
/** An object might have its value changed after a store. */
Original file line number Diff line number Diff line change @@ -101,13 +101,13 @@ def test_getattr():
101
101
def test_setattr ():
102
102
myobj = MyObj (NONSOURCE )
103
103
setattr (myobj , "foo" , SOURCE )
104
- SINK (myobj .foo ) # $ MISSING: flow
104
+ SINK (myobj .foo ) # $ flow="SOURCE, l:-1 -> myobj.foo"
105
105
106
106
107
107
def test_setattr_getattr ():
108
108
myobj = MyObj (NONSOURCE )
109
109
setattr (myobj , "foo" , SOURCE )
110
- SINK (getattr (myobj , "foo" )) # $ MISSING: flow
110
+ SINK (getattr (myobj , "foo" )) # $ flow="SOURCE, l:-1 -> getattr(..)"
111
111
112
112
113
113
def test_setattr_getattr_overwrite ():
Original file line number Diff line number Diff line change @@ -17,22 +17,22 @@ def test():
17
17
18
18
# load/dump with file-like
19
19
tainted_filelike = StringIO ()
20
- simplejson .dump (tainted_obj , tainted_filelike ) # $ encodeFormat=JSON encodeInput=tainted_obj
20
+ simplejson .dump (tainted_obj , tainted_filelike ) # $ encodeFormat=JSON encodeInput=tainted_obj encodeOutput=[post]tainted_filelike
21
21
22
22
tainted_filelike .seek (0 )
23
23
ensure_tainted (
24
- tainted_filelike , # $ MISSING: tainted
25
- simplejson .load (tainted_filelike ), # $ decodeOutput=simplejson.load(..) decodeFormat=JSON decodeInput=tainted_filelike MISSING: tainted
24
+ tainted_filelike , # $ tainted
25
+ simplejson .load (tainted_filelike ), # $ tainted decodeOutput=simplejson.load(..) decodeFormat=JSON decodeInput=tainted_filelike
26
26
)
27
27
28
28
# load/dump with file-like using keyword-args
29
29
tainted_filelike = StringIO ()
30
- simplejson .dump (obj = tainted_obj , fp = tainted_filelike ) # $ encodeFormat=JSON encodeInput=tainted_obj
30
+ simplejson .dump (obj = tainted_obj , fp = tainted_filelike ) # $ encodeFormat=JSON encodeInput=tainted_obj encodeOutput=[post]tainted_filelike
31
31
32
32
tainted_filelike .seek (0 )
33
33
ensure_tainted (
34
- tainted_filelike , # $ MISSING: tainted
35
- simplejson .load (fp = tainted_filelike ), # $ decodeOutput=simplejson.load(..) decodeFormat=JSON decodeInput=tainted_filelike MISSING: tainted
34
+ tainted_filelike , # $ tainted
35
+ simplejson .load (fp = tainted_filelike ), # $ tainted decodeOutput=simplejson.load(..) decodeFormat=JSON decodeInput=tainted_filelike
36
36
)
37
37
38
38
# To make things runable
Original file line number Diff line number Diff line change @@ -22,12 +22,12 @@ def test():
22
22
23
23
# load/dump with file-like
24
24
tainted_filelike = StringIO ()
25
- ujson .dump (tainted_obj , tainted_filelike ) # $ encodeFormat=JSON encodeInput=tainted_obj
25
+ ujson .dump (tainted_obj , tainted_filelike ) # $ encodeFormat=JSON encodeInput=tainted_obj encodeOutput=[post]tainted_filelike
26
26
27
27
tainted_filelike .seek (0 )
28
28
ensure_tainted (
29
- tainted_filelike , # $ MISSING: tainted
30
- ujson .load (tainted_filelike ), # $ decodeOutput=ujson.load(..) decodeFormat=JSON decodeInput=tainted_filelike MISSING: tainted
29
+ tainted_filelike , # $ tainted
30
+ ujson .load (tainted_filelike ), # $ tainted decodeOutput=ujson.load(..) decodeFormat=JSON decodeInput=tainted_filelike
31
31
)
32
32
33
33
# load/dump with file-like using keyword-args does not work in `ujson`
You can’t perform that action at this time.
0 commit comments