file_manager: reserved path fix

Raise an exception if an attempt is made to access .git folders.

Signed-off-by:  Eric Callahan <arksine.cde@gmail.com>
This commit is contained in:
Eric Callahan 2023-01-07 16:47:20 -05:00
parent 6021b39234
commit fe9a9899e3
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 4 additions and 0 deletions

View File

@ -275,6 +275,10 @@ class FileManager:
req_path = pathlib.Path(req_path)
req_path = req_path.expanduser().resolve()
if ".git" in req_path.parts:
if raise_error:
raise self.server.error(
"Access to .git folders is forbidden", 403
)
return True
for name, (res_path, can_read) in self.reserved_paths.items():
if (