(Rails) Test if user tries to get root directories -
there script directory user. how check if user tries more level public folder?
for example, tried detect empty string, if enter "?directory=/"
=> root directory. tried check if way public folder in path. again => "?directory=/home/user/app/public/../../../../../"
=> , again i'm in root.
how test , deny access?
try this:
def path_valid?(path, base = rails.public_path) expanded_path_name = pathname.new(path).realpath.to_s expanded_path_name.starts_with? base end
pathname#realpath
resolve path absolute path, symlink resolution. let test precisely path of file operated on is, , ensure inside given path.
Comments
Post a Comment