Skip to content

Commit

Permalink
feat: AssetController shall denies access to files in folder that has…
Browse files Browse the repository at this point in the history
… a .DENIED file
  • Loading branch information
lxsang committed Mar 17, 2024
1 parent 14e20cf commit 824769d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# initialise autoconf and set up some basic information about the program we’re packaging
AC_INIT([silk], [0.1.1], [xsang.le@gmail.com])
AC_INIT([silk], [0.2.0], [xsang.le@gmail.com])

# We’re going to use automake for this project
# [subdir-objects] if needed
Expand Down
15 changes: 13 additions & 2 deletions silkmvc/BaseController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,19 @@ function AssetController:index(...)
end

function AssetController:get(...)
local path = WWW_ROOT..DIR_SEP..implode({...}, DIR_SEP)

-- check for access in all parent DIR
local DENIEDF = ".DENIED"
local curr_dir = WWW_ROOT
local args = {...}
for i, v in ipairs(explode(args[1], "/")) do
LOG_DEBUG("Checking acess for %s", curr_dir)
if ulib.exists(curr_dir..DIR_SEP..DENIEDF) then
self:error("Access forbidden: "..curr_dir)
return false
end
curr_dir = curr_dir..DIR_SEP..v
end
local path = WWW_ROOT..DIR_SEP..implode(args, DIR_SEP)
if self.registry.fileaccess and ulib.exists(path) then
local mime = std.mimeOf(path)
if POLICY.mimes[mime] then
Expand Down

0 comments on commit 824769d

Please sign in to comment.