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

Security updates to containers #1336

Open
wants to merge 20 commits into
base: devel
Choose a base branch
from
Open

Security updates to containers #1336

wants to merge 20 commits into from

Conversation

nedvedba
Copy link
Collaborator

@nedvedba nedvedba commented Mar 6, 2025

PR Description

This PR serves to reduce image sizes and drastically reduce CVEs in built images, along with fixing a deprecation warning to the python API.

BEFORE

Container Name Size Critical CVEs High CVEs Medium CVEs Low CVEs Unspecified CVEs
datafed/core 200.37MB 0 0 5 52 0
datafed/web 610.28MB 1 8 1211 59 0
datafed/repo 181.30MB 0 0 5 12 0
datafed/gcs 6.16GB 2 23 30 19 0

AFTER

Container Name Size Critical CVEs High CVEs Medium CVEs Low CVEs Unspecified CVEs
datafed/core 159.88MB 0 0 0 33 0
datafed/web 747.02MB 0 2 1 75 2
datafed/repo 141.48MB 0 0 0 33 0
datafed/gcs 1.57GB 1 14 13 53 0

Tasks

  • - A description of the PR has been provided, and a diagram included if it is a new feature.
  • - Formatter has been run
  • - CHANGELOG comment has been added
  • - Labels have been assigned to the pr
  • - A reviwer has been added
  • - A user has been assigned to work on the pr
  • - If new feature a unit test has been added

Summary by Sourcery

Updates dependencies, base images, and protobuf handling to reduce image sizes and CVEs, and fixes a deprecation warning in the Python API.

Bug Fixes:

  • Fixes a deprecation warning in the Python API related to protobuf messages by using MessageFactory to create protobuf message instances.

Enhancements:

  • Updates the base image for the GCS container to debian:bookworm-slim, reducing image size and potential security vulnerabilities.
  • Updates dependencies including Node.js, protobuf, libcurl, and Boost to address security vulnerabilities and improve performance.

Copy link

sourcery-ai bot commented Mar 6, 2025

Reviewer's Guide by Sourcery

This PR updates dependency versions, addresses a protobuf deprecation warning, and modifies the base image used for building containers. These changes aim to reduce image sizes, mitigate CVEs, and improve the overall security and compatibility of the DataFed system.

Updated class diagram for protobuf message handling

classDiagram
  class Connection {
    +recv(self, a_timeout=1000)
    +makeMessage(self, msg_name)
  }
  note for Connection.recv "Uses MessageFactory to create message instances"
  note for Connection.makeMessage "Uses MessageFactory to create message instances"
  class MessageFactory {
    +GetMessageClass(desc)
  }
  Connection -- MessageFactory : uses
Loading

File-Level Changes

Change Details Files
Updated dependency versions in dependency_versions.sh to address security vulnerabilities and improve compatibility.
  • Updated DATAFED_NVM_VERSION to v0.40.1.
  • Updated DATAFED_NODE_VERSION to v20.18.2.
  • Updated DATAFED_BOOST to 1.74.0.
  • Updated DATAFED_GCS_SUBMODULE_VERSION to ff7167860345e9b994110dfabdb251fe4dea8c00.
scripts/dependency_versions.sh
Addressed a deprecation warning in the Python API related to protobuf message creation.
  • Replaced google.protobuf.reflection.ParseMessage with MessageFactory().GetMessageClass(desc)() and reply.ParseFromString(data) in recv method.
  • Replaced google.protobuf.reflection.MakeClass with MessageFactory().GetMessageClass(self._msg_desc_by_name[msg_name])() in makeMessage method.
python/datafed_pkg/datafed/Connection.py
Modified the base image and submodule checkout in compose_build_images.sh to reduce image sizes and CVEs.
  • Set BASE_IMAGE to debian:bookworm-slim.
  • Updated the docker build command to use Dockerfile.debian-12 instead of Dockerfile.ubuntu-20.04.
scripts/compose_build_images.sh
Passed arguments to the compose build images script.
  • Added $@ to the end of the compose build images script call.
compose/all/build_images_for_compose.sh
Updated the protobuf dependency version in requirements.txt.
  • Updated protobuf to 5.27.1.
python/datafed_pkg/requirements.txt
Added libopenssl to the list of external dependencies in install_authz_dependencies.sh.
  • Added libopenssl to the externals array.
scripts/install_authz_dependencies.sh
Added libboost-program-options-dev to the list of packages in install_core_dependencies.sh.
  • Added libboost-program-options-dev to the packages array.
scripts/install_core_dependencies.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @nedvedba - I've reviewed your changes - here's some feedback:

Overall Comments:

  • It looks like you're updating dependencies - consider adding a comment to the changelog about these dependency updates.
  • It looks like you're using a specific commit hash for the gcs submodule - is there a reason not to use a tagged release?
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

DATAFED_NVM_VERSION="v0.39.7"
DATAFED_NVM_VERSION="v0.40.1"
# we cannot use node 22 even though it is the currently highest supported LTS version, due to a currently unsolved build error
DATAFED_NODE_VERSION="v20.18.2"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this come with any breakages? I know @AronPerez was exploring an upgrade

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have not noticed any, maybe @AronPerez can point out what he was running into?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can upgrade node, but we need to keep our web dependencies locked at their version

What I was running into was with node ~v16: #1245

That being said v20.18.2 looks like clean install
image

@nedvedba nedvedba added Type: New Feature New or enhanced feature Component: Web API Relates to web service / API Component: Core Relates to core service Component: Repository Relates to repository service Component: GridFTP Auth Module Relates to GridFTP authorization library Component: Python API Relates to Python API Component: Build Related to the build system Component: Scripts Helper scripts or admin scripts Component: CI Type: Update Update a dependency or some other package labels Mar 6, 2025
@nedvedba nedvedba self-assigned this Mar 6, 2025
@AronPerez
Copy link
Collaborator

I have been pinged

Comment on lines +75 to +76
# RUN ${BUILD_DIR}/scripts/copy_dependency.sh boost_program_options to
# RUN ${BUILD_DIR}/scripts/copy_dependency.sh boost_filesystem to
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can these be deleted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Anything that is commented out will be removed once I get the CI to pass.

@AronPerez AronPerez mentioned this pull request Mar 11, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Build Related to the build system Component: CI Component: Core Relates to core service Component: GridFTP Auth Module Relates to GridFTP authorization library Component: Python API Relates to Python API Component: Repository Relates to repository service Component: Scripts Helper scripts or admin scripts Component: Web API Relates to web service / API Type: New Feature New or enhanced feature Type: Update Update a dependency or some other package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants