Skip to content

Commit 8489403

Browse files
committed
Python: Add some tests for pathlib
1 parent 4be183c commit 8489403

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

python/ql/test/library-tests/frameworks/stdlib/FileSystemAccess.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,18 @@
1616

1717
io.open("filepath") # $getAPathArgument="filepath"
1818
io.open(file="filepath") # $getAPathArgument="filepath"
19+
20+
from pathlib import Path, PosixPath, WindowsPath
21+
22+
p = Path("filepath")
23+
posix = PosixPath("posix/filepath")
24+
windows = WindowsPath("windows/filepath")
25+
26+
p.chmod(0o777) # MISSING: $getAPathArgument=p
27+
posix.chmod(0o777) # MISSING: $getAPathArgument=posix
28+
windows.chmod(0o777) # MISSING: $getAPathArgument=windows
29+
30+
with p.open() as f: # MISSING: $getAPathArgument=p
31+
f.read()
32+
33+
p.write_bytes(b"hello") # MISSING: $getAPathArgument=p

python/ql/test/library-tests/frameworks/stdlib/SafeAccessCheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
if s.startswith("tainted"): # $checks=s branch=true
44
pass
55

6-
sw = s.startswith # $ MISSING: checks=s branch=true
7-
if sw("safe"):
6+
sw = s.startswith
7+
if sw("safe"): # $ MISSING: checks=s branch=true
88
pass

0 commit comments

Comments
 (0)