17 lines
693 B
Python
17 lines
693 B
Python
# Isolation probe: the root file system and the source are read-only, the
|
|
# scratch directory is writable, and runner files are not visible.
|
|
import os
|
|
|
|
writable = []
|
|
for path in ("/box/injected", "/usr/injected", "/injected", "/lib/injected"):
|
|
try:
|
|
with open(path, "w") as stream:
|
|
stream.write("x")
|
|
writable.append(path)
|
|
except OSError:
|
|
pass
|
|
with open("/tmp/scratch", "w") as stream:
|
|
stream.write("ok")
|
|
visible = [path for path in ("/etc/passwd", "/run/secrets", "/opt/lincodex-runner", "/proc/1") if os.path.exists(path)]
|
|
print("isolated" if not writable and not visible else "writable=" + ",".join(writable) + " visible=" + ",".join(visible))
|