Merge pull request #5681 from yoff/python-support-pathlib

Approved by tausbn
This commit is contained in:
CodeQL CI
2021-05-04 09:20:24 -07:00
committed by GitHub
6 changed files with 226 additions and 15 deletions

View File

@@ -13,7 +13,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = Path(__file__).resolve().parent.parent #$ getAPathArgument=Path()
# Quick-start development settings - unsuitable for production

View File

@@ -16,3 +16,24 @@ builtins.open(file="filepath") # $getAPathArgument="filepath"
io.open("filepath") # $getAPathArgument="filepath"
io.open(file="filepath") # $getAPathArgument="filepath"
from pathlib import Path, PosixPath, WindowsPath
p = Path("filepath")
posix = PosixPath("posix/filepath")
windows = WindowsPath("windows/filepath")
p.chmod(0o777) # $getAPathArgument=p
posix.chmod(0o777) # $getAPathArgument=posix
windows.chmod(0o777) # $getAPathArgument=windows
with p.open() as f: # $getAPathArgument=p
f.read()
p.write_bytes(b"hello") # $getAPathArgument=p
name = windows.parent.name
o(name) # $getAPathArgument=name
wb = p.write_bytes
wb(b"hello") # $getAPathArgument=p

View File

@@ -3,6 +3,6 @@ s = "taintedString"
if s.startswith("tainted"): # $checks=s branch=true
pass
sw = s.startswith # $ MISSING: checks=s branch=true
if sw("safe"):
sw = s.startswith
if sw("safe"): # $ MISSING: checks=s branch=true
pass