Skip to content

Commit 124730d

Browse files
committed
Update bundler-audit vulnerability database as app user
We're currently installing gems and updating the `bundler-audit` vulnerability database as the `root` user. `bundle-audit update` downloads the database relative to the current user's home directory. As the `root` user, the database is stored at `/root/.local/share/ruby-advisory-db`. Following best security practices, we drop down to a less privileged user within our `Dockerfile`. Like the `bundle-audit update` command, `bundle-audit check` will refer to a vulnerability database relative to the current user's home directory. Running as the `app` user, `bundler-audit` looks for a database at `/home/app/.local/share/ruby-advisory-db`. So, to summarize, we've been downloading the vulnerability database to `/root/.local/share/ruby-advisory-db` and checking for it at `/home/app/.local/share/ruby-advisory-db` during engine runs. This obviously doesn't work and consistently produced out-of-date analysis results. This commit updates this project's Dockerfile to update the `bundler-audit` vulnerability database after we switch down to the `app` user, so it goes to the right directory and can be picked up by the running engine.
1 parent 65caa65 commit 124730d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ RUN apk --update add ruby ruby-dev ruby-bundler build-base git
66
COPY Gemfile /usr/src/app/
77
COPY Gemfile.lock /usr/src/app/
88
RUN bundle install -j 4 && \
9-
bundle-audit update && \
109
apk del build-base && rm -fr /usr/share/ri
1110

1211
RUN adduser -u 9000 -D app
1312
USER app
1413

14+
RUN bundle-audit update
15+
1516
COPY . /usr/src/app
1617

1718
CMD ["/usr/src/app/bin/bundler-audit"]

0 commit comments

Comments
 (0)