Files
manyfold/config/initializers/libarchive_security.rb
T
James Smith 176ef29854 Make archive extraction thread-safe
Had to allow absolute extraction paths, but that's OK as we're always going to set the destination path. Also had to allow extraction through symlinks because MacOS seems to use them for its temp dirs.
2024-09-10 15:04:08 +01:00

10 lines
406 B
Ruby

module Archive
# Create a preset "secure extraction" flag combination for libarchive to make sure we avoid security problems
# See https://github.com/libarchive/libarchive/blob/6ee1eebefdf41f36ef1a548c9a7000d132c453f3/libarchive/archive.h#L662
EXTRACT_SECURE = [
Archive::EXTRACT_NO_OVERWRITE,
Archive::EXTRACT_NO_OVERWRITE_NEWER,
Archive::EXTRACT_SECURE_NODOTDOT
].reduce(:|).to_i
end