mirror of
https://github.com/github/codeql.git
synced 2026-02-22 18:03:39 +01:00
add pyTorch :) code execution sinks, add proper tests
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
25
python/ql/test/library-tests/frameworks/torch/Decoding.py
Normal file
25
python/ql/test/library-tests/frameworks/torch/Decoding.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from io import BytesIO
|
||||
|
||||
import torch
|
||||
|
||||
|
||||
def someSafeMethod():
|
||||
pass
|
||||
|
||||
|
||||
PicklePayload = BytesIO(b"payload")
|
||||
torch.load(PicklePayload) # $ decodeInput=PicklePayload decodeOutput=torch.load(..) decodeFormat=pickle decodeMayExecuteInput
|
||||
torch.load(PicklePayload, pickle_module=None) # $ decodeInput=PicklePayload decodeOutput=torch.load(..) decodeFormat=pickle decodeMayExecuteInput
|
||||
torch.load(PicklePayload, pickle_module=someSafeMethod()) # $ decodeInput=PicklePayload decodeOutput=torch.load(..) decodeFormat=pickle
|
||||
|
||||
from torch.package import PackageImporter
|
||||
|
||||
importer = PackageImporter(PicklePayload) # $ decodeInput=PicklePayload PackageImporter(..) decodeFormat=pickle decodeMayExecuteInput
|
||||
my_tensor = importer.load_pickle("my_resources", "tensor.pkl") # $ decodeOutput=importer.load_pickle(..)
|
||||
|
||||
importer = PackageImporter(PicklePayload)
|
||||
|
||||
|
||||
from torch import jit
|
||||
|
||||
jit.load(PicklePayload) # $ decodeInput=PicklePayload decodeOutput=jit.load(..) decodeFormat=pickle decodeMayExecuteInput
|
||||
Reference in New Issue
Block a user