mirror of https://github.com/corca-ai/EVAL
Refactor/file store (#18)
* feat: change port variable name * feat: chdir to playground * refactor: etc * feat: add verify decoratorpull/22/head
parent
4cd1d35914
commit
e5165d6f90
@ -0,0 +1,18 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from env import settings
|
||||||
|
|
||||||
|
|
||||||
|
def verify(func):
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
try:
|
||||||
|
filepath = args[0].filepath
|
||||||
|
except:
|
||||||
|
raise Exception("This tool doesn't have filepath. Please check your code.")
|
||||||
|
if not str(Path(filepath).resolve()).startswith(
|
||||||
|
str(Path(settings["PLAYGROUND_DIR"]).resolve())
|
||||||
|
):
|
||||||
|
return "You can't access file outside of playground."
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
|
return wrapper
|
Loading…
Reference in New Issue