@@ -911,25 +911,23 @@ private module Stdlib {
911911 private string pathlibPathMethodExport ( ) { result in [ "as_posix" , "as_uri" ] }
912912
913913 /**
914- * Flow for mehtods that return a `pathlib.Path` object.
914+ * Flow for attributes and methods that return a `pathlib.Path` object.
915915 */
916- private predicate typePreservingCall ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
917- exists ( DataFlow:: AttrRead returnsPath | returnsPath .getAttributeName ( ) = pathlibPathMethod ( ) |
918- nodeTo .( DataFlow:: CallCfgNode ) .getFunction ( ) = returnsPath and
916+ private predicate pathlibPathStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
917+ exists ( DataFlow:: AttrRead returnsPath |
918+ (
919+ // attribute access
920+ returnsPath .getAttributeName ( ) = pathlibPathAttribute ( ) and
921+ nodeTo = returnsPath
922+ or
923+ // method call
924+ returnsPath .getAttributeName ( ) = pathlibPathMethod ( ) and
925+ nodeTo .( DataFlow:: CallCfgNode ) .getFunction ( ) = returnsPath
926+ ) and
919927 nodeFrom = returnsPath .getObject ( )
920928 )
921929 }
922930
923- /**
924- * Flow for attributes that are `pathlib.Path` objects.
925- */
926- private predicate typePreservingAttribute ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
927- exists ( DataFlow:: AttrRead isPath | isPath .getAttributeName ( ) = pathlibPathAttribute ( ) |
928- nodeTo = isPath and
929- nodeFrom = isPath .getObject ( )
930- )
931- }
932-
933931 /**
934932 * Gets a reference to a `pathlib.Path` object.
935933 * This type tracker makes the monomorphic API use assumption.
@@ -939,22 +937,13 @@ private module Stdlib {
939937 t .start ( ) and
940938 result = pathlib ( ) .getMember ( pathlibPathConstructor ( ) ) .getACall ( )
941939 or
942- // Type-preserving call
940+ // Type-preserving step
943941 exists ( DataFlow:: Node nodeFrom , DataFlow:: TypeTracker t2 |
944942 pathlibPath ( t2 ) .flowsTo ( nodeFrom ) and
945943 t2 .end ( )
946944 |
947945 t .start ( ) and
948- typePreservingCall ( nodeFrom , result )
949- )
950- or
951- // Type-preserving attribute access
952- exists ( DataFlow:: Node nodeFrom , DataFlow:: TypeTracker t2 |
953- nodeFrom .getALocalSource ( ) = pathlibPath ( t2 ) and
954- t2 .end ( )
955- |
956- t .start ( ) and
957- typePreservingAttribute ( nodeFrom , result )
946+ pathlibPathStep ( nodeFrom , result )
958947 )
959948 or
960949 // Data injection
@@ -1013,14 +1002,7 @@ private module Stdlib {
10131002 or
10141003 // Type preservation
10151004 pathlibPath ( ) .flowsTo ( nodeFrom ) and
1016- pathlibPath ( ) .flowsTo ( nodeTo ) and
1017- (
1018- // Type-preserving call
1019- typePreservingCall ( nodeFrom , nodeTo )
1020- or
1021- // Type-preserving attribute access
1022- typePreservingAttribute ( nodeFrom , nodeTo )
1023- )
1005+ pathlibPathStep ( nodeFrom , nodeTo )
10241006 or
10251007 // Data injection
10261008 pathlibPath ( ) .flowsTo ( nodeTo ) and
@@ -1053,20 +1035,16 @@ private module Stdlib {
10531035 or
10541036 // Export data from type
10551037 pathlibPath ( ) .flowsTo ( nodeFrom ) and
1056- (
1038+ exists ( DataFlow :: AttrRead exportPath |
10571039 // exporting attribute
1058- exists ( DataFlow:: AttrRead export |
1059- export .getAttributeName ( ) = pathlibPathAttributeExport ( )
1060- |
1061- nodeTo = export and
1062- nodeFrom = export .getObject ( )
1063- )
1040+ exportPath .getAttributeName ( ) = pathlibPathAttributeExport ( ) and
1041+ nodeTo = exportPath
10641042 or
1065- // exporting call
1066- exists ( DataFlow :: AttrRead export | export .getAttributeName ( ) = pathlibPathMethodExport ( ) |
1067- nodeTo .( DataFlow:: CallCfgNode ) .getFunction ( ) = export and
1068- nodeFrom = export . getObject ( )
1069- )
1043+ // exporting method
1044+ exportPath .getAttributeName ( ) = pathlibPathMethodExport ( ) and
1045+ nodeTo .( DataFlow:: CallCfgNode ) .getFunction ( ) = exportPath
1046+ |
1047+ nodeFrom = exportPath . getObject ( )
10701048 )
10711049 }
10721050 }
0 commit comments