Skip to content

Project dependencies updated addressing security #232

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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

albenik
Copy link
Contributor

@albenik albenik commented Apr 16, 2025

Project dependencies updated addressing security

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe): Deps update, security fix

What is the current behavior?

> cargo audit

# stripped verbose output

error: 11 vulnerabilities found!
warning: 14 allowed warnings found

> cargo pants

# stripped verbose output

Audited Dependencies: 291
Vulnerable Dependencies: 6

Issue Number: N/A

What is the new behavior?

> cargo audit

# stripped verbose output

warning: 3 allowed warnings found

> cargo pants

# stripped verbose output

Audited Dependencies: 339
Vulnerable Dependencies: 0

Other information

Additionally, my inner perfectionist cleaned up the Cargo.toml using cargo sort. I also removed the minor version from 1.x dependencies and the patch version from 0.x ones, since the project uses a version-controlled Cargo.lock file that ensures version consistency. Now it's easier to update minor versions of dependencies with a simple cargo update, if needed.

albenik added 11 commits July 5, 2025 09:05
Refactor error handling and improve code readability in gRPC wrapper and example URL shortener. Updated conversion methods to use `try_from` for better error handling, simplified cloning of consumer stats, and enhanced logging messages with formatted strings.
- Changed Rust version from 1.88.0 to stable in linter workflow.
- Added steps for installing nightly Rust and checking for unused dependencies in the linter workflow.
- Introduced a new security workflow for YDB tests, including cargo audit and cargo pants checks.
- Removed redundant cargo install and check steps from rust-tests workflow to streamline the process.
- Removed deprecated `partition_count_limit` in favor of `max_active_partitions` in topic-related structures.
- Introduced `auto_partitioning_settings` to enhance partition management.
- Updated `tonic` and `tower` versions in `Cargo.toml` and `Cargo.lock`.
- Added handling for new session response types in `coordination_session.rs`.
- Adjusted gRPC request and response structures to accommodate new partitioning features.
- Updated `rand` version in `Cargo.toml` and `Cargo.lock` to 0.9.1, enabling the use of new features.
- Refactored random number generation to utilize the new `rng()` function instead of `thread_rng()` for improved performance and consistency.
- Adjusted random string generation and endpoint selection methods to align with the updated `rand` API.
Copy link
Member

@rekby rekby left a comment

Choose a reason for hiding this comment

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

Hello, thanks for great work.

I have few questions. I wrote them in the files section.

RUST_VERSION_OLD: "1.68.0"
RUST_VERSION_NEW: "1.88.0"
RUST_VERSION_OLD: "1.81.0" # aka MSRV
RUST_VERSION_NEW: "stable"
Copy link
Member

Choose a reason for hiding this comment

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

"stable" for RUST_VERSION_NEW is bad for CI because it will be updated in background without commit. The new version is used not only for compilation (which should remain stable), but for linter too and linter from new version often causing it to break on older code.

It mean that if I want to fix a bug after new rust version released - I should to fix all linter errors as pre-requisite, or ignore it.

I prefer to use fixed versions for reproducible CI.

Copy link
Contributor Author

@albenik albenik Jul 10, 2025

Choose a reason for hiding this comment

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

Get it!
Will fix
What do you think about 3-version matrix in ci?

  • minimal supported aka RUST_VERSION_OLD
  • latest stable as version number aka RUST_VERSION_NEW
  • "stable" – to catch future rust releases bugs as soon as possible. This check can be optional and not block PRs.

Copy link
Member

Choose a reason for hiding this comment

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

third unblock stable - is ok, for early handle rusts bugs - nightly may be better.

@@ -11,8 +11,8 @@ on:
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUST_VERSION_OLD: "1.68.0"
RUST_VERSION_NEW: "1.88.0"
RUST_VERSION_OLD: "1.81.0" # aka MSRV
Copy link
Member

Choose a reason for hiding this comment

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

What is msrv in this context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's about terminology.

MSRV (Minimal Supported Rust Version, value if the rust-version in the Cargo.toml) – well-known widely used term.

While "OLD" have to broad meaning for me.
So I kept the original variables in the code, but have added I bit more context by comment.

submodules: true
key: ${{ env[matrix.rust_version] }}

- name: Show YDB server version
Copy link
Member

Choose a reason for hiding this comment

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

It's very convenient to see the server version at the beginning, and it's independent of the source code and Rust. Why did you move it?

Copy link
Contributor Author

@albenik albenik Jul 10, 2025

Choose a reason for hiding this comment

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

Because docker run more expensive operation than code checkout. About rust toolchain installation I am not sure by the way :)) But still: if you failed with very basic project setup it is a good idea not to execute anything more.

It's not important for me to stay at this point. If you say, that looking at YDB version as early as possible is required, I'll just rollback and make a comment in the code with such description.

Copy link
Member

@rekby rekby Jul 10, 2025

Choose a reason for hiding this comment

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

YDB run as service before. It starts before any step, the command show version only. It is fast. Faster, then install toolchain.

uses: dtolnay/rust-toolchain@v1
- name: Install nightly rust
if: matrix.rust_version == 'RUST_VERSION_NEW'
uses: dtolnay/rust-toolchain@nightly
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need nightly toolchain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is obsolete code. Will drop it.
It used to execute cargo-udeps but I moved it to a separate workflow file

@@ -11,8 +11,8 @@ on:
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
RUST_VERSION_OLD: "1.68.0"
RUST_VERSION_NEW: "1.88.0"
RUST_VERSION_OLD: "1.82" # aka MSRV
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need rust newer, than 1.68?

It's ok to update an old version, when necessary, but the update should a reasonable justification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because some of updated dependencies now require Rust 1.82
Probably I can downgrade some dependencies to keep MSRV 1.81 but not less.

Updates of dependencies which contains fixes for critical vulnerabilities reported by cargo audit requires at least 1.81.

run: |
cargo audit

- name: Cargi pants
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- name: Cargi pants
- name: Cargo pants

- name: Cargi pants
if: matrix.rust_version == 'RUST_VERSION_NEW'
run: |
cargo pants
Copy link
Member

Choose a reason for hiding this comment

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

All files must have new line at the end.

if: matrix.rust_version == 'RUST_VERSION_NEW'
run: cargo install --locked cargo-audit cargo-pants

- name: Cargo audit
Copy link
Member

Choose a reason for hiding this comment

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

Great idea, thanks

serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.18", features = ["macros", "rt-multi-thread", "net"] }
hashers = "1"
serde = { version = "1", features = ["derive"] }
Copy link
Member

Choose a reason for hiding this comment

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

The dependencies set to minimum supported version. If somebody want to update the version - it is free. Anybody can update version of the serde/tokio/... crate for own lib or end binary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Get it!

@@ -160,14 +160,16 @@ impl From<AlterConsumer> for RawAlterConsumer {
#[derive(Debug, Clone, Default)]
pub struct PartitioningSettings {
pub min_active_partitions: i64,
pub partition_count_limit: i64,
pub max_active_partitions: i64,
pub auto_partitioning_settings: Option<ydb_grpc::ydb_proto::topic::AutoPartitioningSettings>,
Copy link
Member

Choose a reason for hiding this comment

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

Extract change api, internal logic and etc to other PR please. For separate reformats/style updates/dependency update from api/logic updates. It will be much easer for research changes reason in the future.

Copy link
Member

Choose a reason for hiding this comment

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

many of style fixes already done within upgrade rust version for the CI #356

Copy link
Member

Choose a reason for hiding this comment

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

What about split the PR to 3 parts?

  1. Add vulnerabilities linters and upgrade dependencies, MSRV
  2. Fix api fields
  3. Fix style (if need)

Copy link
Contributor Author

@albenik albenik Jul 13, 2025

Choose a reason for hiding this comment

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

Agreed! Will do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants