@@ -959,13 +959,18 @@ private module StdlibPrivate {
959
959
}
960
960
}
961
961
962
- /** A call to `os.path.samefile` will raise an exception if an `os.stat()` call on either pathname fails. */
962
+ /**
963
+ * A call to `os.path.samefile` will raise an exception if an `os.stat()` call on either pathname fails.
964
+ *
965
+ * See https://docs.python.org/3.10/library/os.path.html#os.path.samefile
966
+ */
963
967
private class OsPathSamefileCall extends FileSystemAccess:: Range , DataFlow:: CallCfgNode {
964
968
OsPathSamefileCall ( ) { this = OS:: path ( ) .getMember ( "samefile" ) .getACall ( ) }
965
969
966
970
override DataFlow:: Node getAPathArgument ( ) {
967
971
result in [
968
- this .getArg ( 0 ) , this .getArgByName ( "path1" ) , this .getArg ( 1 ) , this .getArgByName ( "path2" )
972
+ // note that the f1/f2 names doesn't match the documentation, but is what actually works (tested on 3.8.10)
973
+ this .getArg ( 0 ) , this .getArgByName ( "f1" ) , this .getArg ( 1 ) , this .getArgByName ( "f2" )
969
974
]
970
975
}
971
976
}
@@ -2534,6 +2539,56 @@ private module StdlibPrivate {
2534
2539
PathLibOpenCall ( ) { attrbuteName = "open" }
2535
2540
}
2536
2541
2542
+ /**
2543
+ * A call to the `link_to`, `hardlink_to`, or `symlink_to` method on a `pathlib.Path` instance.
2544
+ *
2545
+ * See
2546
+ * - https://docs.python.org/3/library/pathlib.html#pathlib.Path.link_to
2547
+ * - https://docs.python.org/3/library/pathlib.html#pathlib.Path.hardlink_to
2548
+ * - https://docs.python.org/3/library/pathlib.html#pathlib.Path.symlink_to
2549
+ */
2550
+ private class PathLibLinkToCall extends PathlibFileAccess , API:: CallNode {
2551
+ PathLibLinkToCall ( ) { attrbuteName in [ "link_to" , "hardlink_to" , "symlink_to" ] }
2552
+
2553
+ override DataFlow:: Node getAPathArgument ( ) {
2554
+ result = super .getAPathArgument ( )
2555
+ or
2556
+ result = this .getParameter ( 0 , "target" ) .getARhs ( )
2557
+ }
2558
+ }
2559
+
2560
+ /**
2561
+ * A call to the `replace` or `rename` method on a `pathlib.Path` instance.
2562
+ *
2563
+ * See
2564
+ * - https://docs.python.org/3/library/pathlib.html#pathlib.Path.replace
2565
+ * - https://docs.python.org/3/library/pathlib.html#pathlib.Path.rename
2566
+ */
2567
+ private class PathLibReplaceCall extends PathlibFileAccess , API:: CallNode {
2568
+ PathLibReplaceCall ( ) { attrbuteName in [ "replace" , "rename" ] }
2569
+
2570
+ override DataFlow:: Node getAPathArgument ( ) {
2571
+ result = super .getAPathArgument ( )
2572
+ or
2573
+ result = this .getParameter ( 0 , "target" ) .getARhs ( )
2574
+ }
2575
+ }
2576
+
2577
+ /**
2578
+ * A call to the `samefile` method on a `pathlib.Path` instance.
2579
+ *
2580
+ * See https://docs.python.org/3/library/pathlib.html#pathlib.Path.samefile
2581
+ */
2582
+ private class PathLibSameFileCall extends PathlibFileAccess , API:: CallNode {
2583
+ PathLibSameFileCall ( ) { attrbuteName = "samefile" }
2584
+
2585
+ override DataFlow:: Node getAPathArgument ( ) {
2586
+ result = super .getAPathArgument ( )
2587
+ or
2588
+ result = this .getParameter ( 0 , "other_path" ) .getARhs ( )
2589
+ }
2590
+ }
2591
+
2537
2592
/** An additional taint steps for objects of type `pathlib.Path` */
2538
2593
private class PathlibPathTaintStep extends TaintTracking:: AdditionalTaintStep {
2539
2594
override predicate step ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
0 commit comments