Deny file mode changes outside of specified paths in sandbox
This commit is contained in:
parent
6a5bcb339d
commit
ab46965d95
@ -37,6 +37,14 @@ class Sandbox
|
|||||||
def allow_write(path:, type: :literal)
|
def allow_write(path:, type: :literal)
|
||||||
add_rule allow: true, operation: "file-write*", filter: path_filter(path, type)
|
add_rule allow: true, operation: "file-write*", filter: path_filter(path, type)
|
||||||
add_rule allow: true, operation: "file-write-setugid", filter: path_filter(path, type)
|
add_rule allow: true, operation: "file-write-setugid", filter: path_filter(path, type)
|
||||||
|
|
||||||
|
file_write_mode_path = if Pathname(path).directory?
|
||||||
|
"#{path}/*"
|
||||||
|
else
|
||||||
|
path
|
||||||
|
end
|
||||||
|
|
||||||
|
add_rule allow: true, operation: "file-write-mode", filter: path_filter(file_write_mode_path, type)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(path: T.any(String, Pathname), type: Symbol).void }
|
sig { params(path: T.any(String, Pathname), type: Symbol).void }
|
||||||
@ -289,6 +297,7 @@ class Sandbox
|
|||||||
(regex #"^/dev/tty[a-z0-9]*$")
|
(regex #"^/dev/tty[a-z0-9]*$")
|
||||||
)
|
)
|
||||||
(deny file-write*) ; deny non-allowlist file write operations
|
(deny file-write*) ; deny non-allowlist file write operations
|
||||||
|
(deny file-write-mode) ; deny non-allowlist file write mode operations
|
||||||
(allow process-exec
|
(allow process-exec
|
||||||
(literal "/bin/ps")
|
(literal "/bin/ps")
|
||||||
(with no-sandbox)
|
(with no-sandbox)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user