@@ -911,7 +911,7 @@ private module Stdlib {
911
911
private string pathlibPathMethodExport ( ) { result in [ "as_posix" , "as_uri" ] }
912
912
913
913
/**
914
- * Flow for type presering mehtods .
914
+ * Flow for mehtods that return a `pathlib.Path` object .
915
915
*/
916
916
private predicate typePreservingCall ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
917
917
exists ( DataFlow:: AttrRead returnsPath | returnsPath .getAttributeName ( ) = pathlibPathMethod ( ) |
@@ -921,7 +921,7 @@ private module Stdlib {
921
921
}
922
922
923
923
/**
924
- * Flow for type presering attributes .
924
+ * Flow for attributes that are `pathlib.Path` objects .
925
925
*/
926
926
private predicate typePreservingAttribute ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
927
927
exists ( DataFlow:: AttrRead isPath | isPath .getAttributeName ( ) = pathlibPathAttribute ( ) |
@@ -1018,32 +1018,22 @@ private module Stdlib {
1018
1018
// Type-preserving call
1019
1019
typePreservingCall ( nodeFrom , nodeTo )
1020
1020
or
1021
- // Type-preserving attribute
1021
+ // Type-preserving attribute access
1022
1022
typePreservingAttribute ( nodeFrom , nodeTo )
1023
1023
)
1024
1024
or
1025
1025
// Data injection
1026
1026
nodeTo .getALocalSource ( ) = pathlibPath ( ) and
1027
1027
(
1028
1028
// Special handling of the `/` operator
1029
- exists ( BinaryExprNode slash , DataFlow:: Node pathOperand , DataFlow :: Node dataOperand |
1029
+ exists ( BinaryExprNode slash , DataFlow:: Node pathOperand |
1030
1030
slash .getOp ( ) instanceof Div and
1031
- (
1032
- pathOperand .asCfgNode ( ) = slash .getLeft ( ) and
1033
- dataOperand .asCfgNode ( ) = slash .getRight ( )
1034
- or
1035
- pathOperand .asCfgNode ( ) = slash .getRight ( ) and
1036
- dataOperand .asCfgNode ( ) = slash .getLeft ( )
1037
- ) and
1031
+ pathOperand .asCfgNode ( ) = slash .getAnOperand ( ) and
1038
1032
pathOperand .getALocalSource ( ) = pathlibPath ( )
1039
1033
|
1040
1034
nodeTo .asCfgNode ( ) = slash and
1041
- nodeFrom in [
1042
- // type-preserving call
1043
- pathOperand ,
1044
- // data injection
1045
- dataOperand
1046
- ]
1035
+ // Taint can flow either from the left or the right operand as long as one of them is a path.
1036
+ nodeFrom .asCfgNode ( ) = slash .getAnOperand ( )
1047
1037
)
1048
1038
or
1049
1039
// standard case
0 commit comments