@@ -18,6 +18,7 @@ import semmle.python.dataflow.new.internal.DataFlowPublic
1818import semmle.python.ApiGraphs
1919import DataFlow:: PathGraph
2020import semmle.python.dataflow.new.TaintTracking
21+ import semmle.python.frameworks.Stdlib
2122
2223class UnsafeUnpackingConfig extends TaintTracking:: Configuration {
2324 UnsafeUnpackingConfig ( ) { this = "UnsafeUnpackingConfig" }
@@ -34,24 +35,25 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
3435
3536 override predicate isAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
3637 // Writing the response data to the archive
37- ( exists ( API:: CallNode call , MethodCallNode mc , Node f |
38- mc .getMethodName ( ) = "write" and
39- f = mc .getObject ( ) and
40- nodeTo = mc .getArg ( 0 ) and
41- call = API:: builtin ( "open" ) .getACall ( ) and
42- call .flowsTo ( f ) and
43- nodeFrom = call .getArg ( 0 )
38+ (
39+ exists ( Stdlib:: FileLikeObject:: InstanceSource is , Node f , MethodCallNode mc |
40+ is .flowsTo ( f ) and
41+ mc .getMethodName ( ) = "write" and
42+ f = mc .getObject ( ) and
43+ nodeFrom = mc .getArg ( 0 ) and
44+ nodeTo = is .( CallCfgNode ) .getArg ( 0 )
45+ )
46+ or
47+ // Reading the response
48+ exists ( MethodCallNode mc |
49+ nodeFrom = mc .getObject ( ) and
50+ mc .getMethodName ( ) = "read" and
51+ nodeTo = mc
52+ )
53+ or
54+ // Accessing the name
55+ exists ( AttrRead ar | ar .accesses ( nodeFrom , "name" ) and nodeTo = ar )
4456 )
45- or
46- // Reading the response
47- exists ( MethodCallNode mc |
48- nodeFrom = mc .getObject ( ) and
49- mc .getMethodName ( ) = "read" and
50- nodeTo = mc
51- )
52- or
53- // Accessing the name
54- exists ( AttrRead ar | ar .accesses ( nodeFrom , "name" ) and nodeTo = ar ) )
5557 }
5658}
5759
0 commit comments