This commit is contained in:
amammad
2023-10-08 21:24:54 +02:00
parent eb3f1967a5
commit 6c8cc79b4d
16 changed files with 237 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
testFailures
failures

View File

@@ -0,0 +1,2 @@
import python
import experimental.meta.ConceptsTest

View File

@@ -0,0 +1,20 @@
import python
import semmle.python.dataflow.new.DataFlow
import semmle.python.Concepts
import TestUtilities.InlineExpectationsTest
private import semmle.python.dataflow.new.internal.PrintNode
module FileSystemAccessTest implements TestSig {
string getARelevantTag() { result = "getAPathArgument" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(location.getFile().getRelativePath()) and
exists(FileSystemAccess a, DataFlow::Node path |
path = a.getAPathArgument() and
location = a.getLocation() and
element = path.toString() and
value = prettyNodeForInlineTest(path) and
tag = "getAPathArgument"
)
}
}

View File

@@ -0,0 +1,4 @@
from aiofile import async_open, AIOFile
AIOFile("file", 'r') # $ getAPathArgument="file"
async_open("file", "r") # $ getAPathArgument="file"

View File

@@ -0,0 +1,3 @@
import aiofiles
aiofiles.open("file", mode='r') # $ getAPathArgument="file"

View File

@@ -0,0 +1,8 @@
import anyio
from anyio.streams.file import FileReadStream, FileWriteStream
from anyio import Path
anyio.open_file("file", 'r') # $ getAPathArgument="file"
FileReadStream.from_path("file") # $ getAPathArgument="file"
FileWriteStream.from_path("file") # $ getAPathArgument="file"
Path("file") # $ getAPathArgument="file"

View File

@@ -0,0 +1,4 @@
from sanic import response
response.file("file") # $ getAPathArgument="file"
response.file_stream("file") # $ getAPathArgument="file"

View File

@@ -0,0 +1,5 @@
from starlette.responses import FileResponse
from baize.asgi import FileResponse as baizeFileResponse
baizeFileResponse("file") # $ getAPathArgument="file"
FileResponse("file") # $ getAPathArgument="file"

View File

@@ -1,2 +1,2 @@
failures
testFailures
failures

View File

@@ -20,6 +20,8 @@ builtins.open(file="file") # $ getAPathArgument="file"
io.open("file") # $ getAPathArgument="file"
io.open(file="file") # $ getAPathArgument="file"
io.open_code("file") # $ getAPathArgument="file"
io.FileIO("file") # $ getAPathArgument="file"
f = open("path") # $ getAPathArgument="path"
f.write("foo") # $ getAPathArgument="path" fileWriteData="foo"