View difference between Paste ID: NGQ4s3Qi and VjguGKZv
SHOW: | | - or go back to the newest paste.
1-
if fs.exists("/.sandbox") == false then
1+
local sbRoot = "/sandboxed/" --#The path programs shouldn't escape
2-
   fs.makeDir("/.sandbox")
2+
local function sandboxCheck(path)
3-
end
3+
  local fullPath = fs.combine(sbRoot, path)
4-
4+
  local splitPath = split(fullPath, "/")
5-
local move = fs.move
5+
  local sbRootSP = split(sbRoot, "/")
6-
local open = fs.open
6+
  local ssPath = ""
7-
local rename = fs.rename
7+
  local ssFPath = ""
8-
local delete = fs.delete
8+
  for i, v in ipairs(splitPath) do
9-
local list = fs.list
9+
    ssPath = ssPath .. " " .. v
10-
local copy = fs.copy
10+
    if i <= #sbRootSP then
11-
11+
          if not isEmpty(sbRootSP[i]) then
12-
fs.list = function(path)
12+
            ssFPath = ssFPath .. " " .. sbRootSP[i]
13-
   path = string.gsub(path, "/", ".sandbox") 
13+
          end
14-
   return list(path)
14+
    end
15
  end
16
  for i, v in ipairs(sbRootSP) do
17
    if not string.match(ssPath, v) then
18
          print("BYPASS ATTEMPT IN: " .. path)
19
          return false
20
    end
21
  end
22
  return true
23
end