Skip to content

Commit

Permalink
fix: Add layer of security and download p7zip-full lib on docker
Browse files Browse the repository at this point in the history
  • Loading branch information
AyakorK committed Sep 25, 2024
1 parent d609ab2 commit 1385c2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV RAILS_ENV=production \
WORKDIR /app

RUN apt-get update && \
apt-get -y install libpq-dev curl git libicu-dev build-essential libproj-dev proj-bin && \
apt-get -y install libpq-dev curl git libicu-dev build-essential libproj-dev proj-bin p7zip-full && \
curl https://deb.nodesource.com/setup_16.x | bash && \
apt-get install -y nodejs && \
npm install --global yarn && \
Expand Down Expand Up @@ -42,7 +42,7 @@ ENV RAILS_ENV=production \
RAILS_LOG_TO_STDOUT=true

RUN apt update && \
apt install -y postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 && \
apt install -y postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 p7zip-full && \
gem install bundler:2.4.9

WORKDIR /app
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV RAILS_ENV=production \
# Install common dependencies
RUN apt-get update -q && \
apt-get install -yq --no-install-recommends \
libpq-dev curl git libicu-dev build-essential openssl && \
libpq-dev curl git libicu-dev build-essential openssl p7zip-full && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -66,7 +66,7 @@ WORKDIR /app
# Install runtime dependencies
RUN apt-get update -q && \
apt-get install -yq --no-install-recommends \
postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 && \
postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 p7zip-full && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand Down
5 changes: 4 additions & 1 deletion app/services/decidim/download_your_data_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def export
save_user_data(tmpdir, user_data)
save_user_attachments(tmpdir, user_attachments)

SevenZipWrapper.compress_and_encrypt(filename: @path, password: @password, input_directory: tmpdir)
Decidim::SevenZipWrapper.compress_and_encrypt(filename: @path, password: @password, input_directory: tmpdir)
end

private
Expand Down Expand Up @@ -59,6 +59,9 @@ def save_user_data(tmpdir, user_data)
next if exporter_data.read == "\n"

file_name = File.join(tmpdir, "#{entity}-#{exporter_data.filename}")

dir_path = File.dirname(file_name)
FileUtils.mkdir_p(dir_path) unless Dir.exist?(dir_path)
File.write(file_name, exporter_data.read)
end
end
Expand Down

0 comments on commit 1385c2b

Please sign in to comment.