Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add layer of security and download p7zip-full lib on docker #237

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading