Skip to content
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
11 changes: 8 additions & 3 deletions docker/Dockerfile.assemble
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Workaround: add sequip lib directory to PERL5LIB
# NOTE: sequip version here must match the version in requirements/assemble.txt
ENV PERL5LIB=$PERL5LIB:/opt/conda/share/sequip-0.11/lib

Check warning on line 23 in docker/Dockerfile.assemble

View workflow job for this annotation

GitHub Actions / build-assemble-amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PERL5LIB' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 23 in docker/Dockerfile.assemble

View workflow job for this annotation

GitHub Actions / build-assemble-amd64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PERL5LIB' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 23 in docker/Dockerfile.assemble

View workflow job for this annotation

GitHub Actions / build-assemble-arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PERL5LIB' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

Check warning on line 23 in docker/Dockerfile.assemble

View workflow job for this annotation

GitHub Actions / build-assemble-arm64

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$PERL5LIB' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

# Copy requirements and dependency installation script
COPY docker/requirements/baseimage.txt docker/requirements/core.txt docker/requirements/assemble.txt docker/requirements/assemble-x86.txt /tmp/requirements/
Expand All @@ -28,11 +28,16 @@

# Install conda dependencies (assembly tools)
# All files resolved together in single micromamba call; x86-only files skipped on ARM
# Remove mafft's dash_client (Go 1.22.1 binary with 11 Go stdlib CVEs) — we
# never use --dash mode; delete inline so it never appears in any layer.
# Post-install fixups (inline so vulnerable files never appear in a committed layer):
# - mafft's dash_client: Go 1.22.1 binary with Go stdlib CVEs; we never use --dash mode
# - Ruby json gem: mummer4/sequip pull in Ruby (via yaggo), whose bundled json gem
# has CVE-2026-33210; remove the old default gem and install patched version (>=2.19.2)
RUN /tmp/install-conda-deps.sh /tmp/requirements/baseimage.txt /tmp/requirements/core.txt /tmp/requirements/assemble.txt \
Comment on lines +31 to 35
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says this affects assemble, phylo, and mega containers, but this change is only in Dockerfile.assemble. Dockerfile.mega and Dockerfile.phylo both build directly FROM main-core and run their own install-conda-deps.sh step, so they will not pick up this json-gem cleanup unless the same fix is applied there (notably mega installs assemble.txt, which is where sequip is pulled in).

Copilot uses AI. Check for mistakes.
--x86-only:/tmp/requirements/assemble-x86.txt && \
rm -f /opt/conda/libexec/mafft/dash_client
rm -f /opt/conda/libexec/mafft/dash_client && \
find /opt/conda/lib/ruby -maxdepth 3 -name 'json*' -not -path '*/psych/*' -exec rm -rf {} + && \
rm -f /opt/conda/lib/ruby/gems/*/specifications/default/json-*.gemspec && \
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup command find /opt/conda/lib/ruby -maxdepth 3 -name 'json*' ... will not traverse into the default gem payload under /opt/conda/lib/ruby/gems/<rubyver>/gems/json-* (depth is >3), so the vulnerable json gem files may remain on disk even after removing the default gemspec. If the goal is to eliminate CVE findings and the vulnerable code, also remove the json gem directories (and related cache/extensions/specs) under the RubyGems directory (ideally by querying gem env gemdir/ruby -e 'print Gem.default_dir' rather than relying on a fixed depth).

Suggested change
rm -f /opt/conda/lib/ruby/gems/*/specifications/default/json-*.gemspec && \
RUBY_GEM_DIRS="$(ruby -e 'print Gem.default_dir' 2>/dev/null || true) $(gem env gemdir 2>/dev/null || true)" && \
for d in $RUBY_GEM_DIRS; do \
if [ -d "$d" ]; then \
rm -rf "$d"/gems/json-* "$d"/cache/json-* "$d"/specifications/json-*.gemspec "$d"/extensions/*/*/json-* 2>/dev/null || true; \
rm -f "$d"/specifications/default/json-*.gemspec 2>/dev/null || true; \
fi; \
done && \

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +39
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These paths are hard-coded to /opt/conda/lib/ruby/.... To make this resilient to Ruby version / conda layout changes, consider deriving the RubyGems directory dynamically (e.g., via gem env gemdir or ruby -e 'print Gem.default_dir') and performing removals relative to that, rather than assuming /opt/conda/lib/ruby/gems/*/... exists.

Suggested change
find /opt/conda/lib/ruby -maxdepth 3 -name 'json*' -not -path '*/psych/*' -exec rm -rf {} + && \
rm -f /opt/conda/lib/ruby/gems/*/specifications/default/json-*.gemspec && \
RUBY_LIB_DIR="$(ruby -e 'require \"rbconfig\"; print RbConfig::CONFIG[\"rubylibdir\"]')" && \
RUBY_GEM_DIR="$(ruby -e 'print Gem.default_dir')" && \
find "$RUBY_LIB_DIR" -maxdepth 3 -name 'json*' -not -path '*/psych/*' -exec rm -rf {} + && \
rm -f "$RUBY_GEM_DIR"/specifications/default/json-*.gemspec && \

Copilot uses AI. Check for mistakes.
gem install json --version '>=2.19.2' --no-document
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To ensure the vulnerability fix actually takes effect (and catch cases where gem install silently installs a different version than expected), consider adding a build-time assertion right after installation (e.g., requiring json and checking JSON::VERSION is >= 2.19.2). This keeps the Docker build from succeeding with the old default gem still being used.

Suggested change
gem install json --version '>=2.19.2' --no-document
gem install json --version '>=2.19.2' --no-document && \
ruby -e "require 'rubygems'; require 'json'; min = Gem::Version.new('2.19.2'); if Gem::Version.new(JSON::VERSION) < min; abort(\"json gem version #{JSON::VERSION} is less than required #{min}\"); end"

Copilot uses AI. Check for mistakes.

# Copy source code (includes assembly module)
COPY src/ /opt/viral-ngs/source/src/
Expand Down
11 changes: 8 additions & 3 deletions docker/Dockerfile.mega
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ COPY docker/install-conda-deps.sh /tmp/

# Install ALL conda dependencies in single resolver call for proper dependency resolution
# All files resolved together; x86-only files skipped on ARM
# Remove mafft's dash_client (Go 1.22.1 binary with 11 Go stdlib CVEs) — we
# never use --dash mode; delete inline so it never appears in any layer.
# Post-install fixups (inline so vulnerable files never appear in a committed layer):
# - mafft's dash_client: Go 1.22.1 binary with Go stdlib CVEs; we never use --dash mode
# - Ruby json gem: mummer4 → yaggo → Ruby, whose bundled json gem has CVE-2026-33210;
# remove the old default gem and install patched version (>=2.19.2)
RUN /tmp/install-conda-deps.sh /tmp/requirements/baseimage.txt /tmp/requirements/core.txt /tmp/requirements/assemble.txt /tmp/requirements/classify.txt /tmp/requirements/phylo.txt \
--x86-only:/tmp/requirements/assemble-x86.txt \
--x86-only:/tmp/requirements/classify-x86.txt \
--x86-only:/tmp/requirements/phylo-x86.txt && \
rm -f /opt/conda/libexec/mafft/dash_client
rm -f /opt/conda/libexec/mafft/dash_client && \
find /opt/conda/lib/ruby -maxdepth 3 -name 'json*' -not -path '*/psych/*' -exec rm -rf {} + && \
rm -f /opt/conda/lib/ruby/gems/*/specifications/default/json-*.gemspec && \
gem install json --version '>=2.19.2' --no-document

# Copy source code (includes all modules)
COPY src/ /opt/viral-ngs/source/src/
Expand Down
11 changes: 8 additions & 3 deletions docker/Dockerfile.phylo
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ COPY docker/install-conda-deps.sh /tmp/

# Install conda dependencies (phylo tools)
# All files resolved together in single micromamba call; x86-only files skipped on ARM
# Remove mafft's dash_client (Go 1.22.1 binary with 11 Go stdlib CVEs) — we
# never use --dash mode; delete inline so it never appears in any layer.
# Post-install fixups (inline so vulnerable files never appear in a committed layer):
# - mafft's dash_client: Go 1.22.1 binary with Go stdlib CVEs; we never use --dash mode
# - Ruby json gem: mummer4 pulls in yaggo → Ruby, whose bundled json gem has
# CVE-2026-33210; remove the old default gem and install patched version (>=2.19.2)
RUN /tmp/install-conda-deps.sh /tmp/requirements/baseimage.txt /tmp/requirements/core.txt /tmp/requirements/phylo.txt \
--x86-only:/tmp/requirements/phylo-x86.txt && \
rm -f /opt/conda/libexec/mafft/dash_client
rm -f /opt/conda/libexec/mafft/dash_client && \
find /opt/conda/lib/ruby -maxdepth 3 -name 'json*' -not -path '*/psych/*' -exec rm -rf {} + && \
rm -f /opt/conda/lib/ruby/gems/*/specifications/default/json-*.gemspec && \
gem install json --version '>=2.19.2' --no-document

# Copy source code (includes phylo module)
COPY src/ /opt/viral-ngs/source/src/
Expand Down
Loading