Skip to content

Bumping versions, also locking versions, and fixed some code#77

Merged
Power2All merged 1 commit into
masterfrom
v4.2.9
May 7, 2026
Merged

Bumping versions, also locking versions, and fixed some code#77
Power2All merged 1 commit into
masterfrom
v4.2.9

Conversation

@Power2All

@Power2All Power2All commented May 7, 2026

Copy link
Copy Markdown
Owner

v4.2.9

  • Bumping versions
  • Locking versions, cause of chain attacks, making sure we use "safe" libs

Summary by CodeRabbit

  • Chores

    • Version bumped to 4.2.9
  • Security

    • Dependency versions pinned to enhance supply chain security and mitigate potential attacks
  • Improvements

    • Streamlined database initialization process

@Power2All Power2All self-assigned this May 7, 2026
@Power2All Power2All added the enhancement New feature or request label May 7, 2026
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Version 4.2.9 release hardening supply chain security through dependency pinning, refactoring database initialization to exit from main rather than connectors, fixing test reliability for SQLite remove and concurrent operations, and updating version metadata across build and desktop entry files.

Changes

v4.2.9 Release and Supply Chain Hardening

Layer / File(s) Summary
Version & Metadata Bumps
Cargo.toml, README.md, docker/Dockerfile, docker/build.bat, torrust-actix.desktop
Version incremented from 4.2.8 to 4.2.9 across package manifests, Docker build artifacts, README changelog documenting library locking for chain attack mitigation, and desktop metadata.
Dependency Version Pinning
Cargo.toml
All [dependencies] and [dev-dependencies] converted from caret (^) constraints to explicit pinned versions (e.g., actix = "0.13.5", tokio = "1.52.2", sqlx = "0.8.6", tempfile = "3.27.0"), preserving existing feature flags to lock supply chain risk.
Database Connector Import Cleanup
src/database/impls/database_connector_mysql.rs, src/database/impls/database_connector_pgsql.rs, src/database/impls/database_connector_sqlite.rs
Removed unused use async_std::task; imports from MySQL, PostgreSQL, and SQLite connector modules.
Database Creation Flow Refactoring
src/database/impls/database_connector_pgsql.rs, src/main.rs
Removed process termination (task::sleep + exit(0)) from PostgreSQL database creation path; added early-exit branch in main.rs that sleeps 1 second and exits with code 0 when args.create_database is true, centralizing shutdown responsibility and preventing tracker initialization.
Test Reliability Improvements
tests/database_tests.rs
Fixed test_database_update_action_remove by enabling config.database.remove_action = true and clearing in-memory whitelist state before database reload; converted test_concurrent_database_writes to multi-threaded Tokio runtime with temporary on-disk SQLite file instead of :memory: to ensure pooled connections share the same database during concurrent writes.
Benchmark Updates
benches/tracker_benchmarks.rs
Added explicit rtc_data: None field to TorrentPeer construction; updated IPv6 address string formatting template in bench_peer_filtering_ipv4_vs_ipv6 for consistent peer generation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Versions hop from 4.2.8 to true,
Locked dependencies shield from the queue,
Database dreams now exit with care,
Tests run concurrent without despair,
Supply chains fortified, safe and sincere!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title addresses three main aspects of the PR: version bumping (v4.2.9), dependency version locking, and code fixes. However, it is somewhat vague and generic in its phrasing—particularly 'fixed some code' lacks specificity about what was actually fixed. Consider a more specific title that clearly prioritizes the main change, such as 'Release v4.2.9: lock dependency versions and fix database initialization' or 'v4.2.9: pin dependencies and refactor async_std usage.'
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v4.2.9

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Cargo.toml`:
- Around line 36-91: Change all caret-style version requirements in the
Cargo.toml dependency lists to exact pins by prefixing with '=' (e.g., change
actix = "0.13.5" to actix = "=0.13.5") for every dependency shown (actix,
actix-cors, actix-web, actix-web-actors, tokio-tungstenite, rmp-serde,
once_cell, uuid, async-std, binascii, bip_bencode, byteorder, chrono, clap,
fern, futures-util, hex, log, parking_lot, percent-encoding, rcgen, regex,
rustls, rustls-pemfile, sentry, sentry-actix, serde, serde_json, serde_millis,
sha1, socket2, sqlx, async-trait, redis, memcache, thiserror, tokio, rand,
base64, tokio-shutdown, toml, tracing, utoipa-swagger-ui, lazy_static,
crossbeam, smallvec, ahash, lz4_flex, zstd and the dev-dependencies tempfile,
criterion, mockall, proptest, reqwest) so versions are exact; also update any
feature tuples unchanged and ensure CI/release jobs are configured to use the
checked-in Cargo.lock for reproducible builds.

In `@docker/Dockerfile`:
- Line 6: The Dockerfile currently forces a git checkout of the remote tag via
the RUN line "RUN cd /app/torrust-actix && git checkout tags/v4.2.9", which
causes the image to package the remote tag instead of local sources; remove that
RUN checkout and instead rely on the build context (COPY the local repo into
/app/torrust-actix before build) or, if you must use git inside the image,
replace the checkout with a command that checks out the current HEAD/commit
(e.g., checkout the repo's provided branch or commit hash) so PR/local changes
are included; update the Dockerfile to remove the hardcoded tag checkout and
ensure COPY/ADD of local code happens prior to any build steps that use
/app/torrust-actix.

In `@README.md`:
- Around line 569-571: Update the v4.2.9 changelog entry: replace the awkward
phrase "cause of chain attacks" with a clearer supply-chain security phrase and
replace the vague '"safe" libs' wording with a concrete description (e.g.,
"locking dependency versions to mitigate supply‑chain risks" and
"updating/locking vulnerable third‑party libraries"). Edit the two bullets under
"#### v4.2.9" to read something like "Locking dependency versions to mitigate
supply‑chain risks" and "Bumping/locking third‑party library versions to address
known vulnerabilities" so the purpose is explicit.

In `@src/main.rs`:
- Around line 80-82: The code currently calls std::process::exit(0) inside the
async block when args.create_database is true, which bypasses Drop and prevents
cleanup (e.g. _sentry_guard); replace the exit(...) call with an early return
from the async block (return Ok(()) ) so the function can unwind normally after
awaiting task::sleep(Duration::from_secs(1)). Locate the branch checking
args.create_database and change the control flow to return Ok(()) instead of
calling exit(0), preserving the sleep await and allowing outer scope destructors
to run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a7a249c-82f2-41d8-b418-a05d4a812f93

📥 Commits

Reviewing files that changed from the base of the PR and between e9cb83b and 894cbd3.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • Cargo.toml
  • README.md
  • benches/tracker_benchmarks.rs
  • docker/Dockerfile
  • docker/build.bat
  • src/database/impls/database_connector_mysql.rs
  • src/database/impls/database_connector_pgsql.rs
  • src/database/impls/database_connector_sqlite.rs
  • src/main.rs
  • tests/database_tests.rs
  • torrust-actix.desktop
💤 Files with no reviewable changes (3)
  • src/database/impls/database_connector_mysql.rs
  • src/database/impls/database_connector_sqlite.rs
  • src/database/impls/database_connector_pgsql.rs

Comment thread Cargo.toml
Comment on lines +36 to +91
actix = "0.13.5"
actix-cors = "0.7.1"
actix-web = { version = "4.13.0", features = ["rustls-0_23", "compress-gzip"] }
actix-web-actors = "4.3.1"
tokio-tungstenite = { version = "0.29.0", features = ["rustls-tls-webpki-roots"] }
rmp-serde = "1.3.1"
once_cell = "1.21.4"
uuid = { version = "1.23.1", features = ["v4"] }
async-std = "1.13.2"
binascii = "0.1.4"
bip_bencode = "0.4.4"
byteorder = "1.5.0"
chrono = "0.4.44"
clap = { version = "4.6.1", features = ["derive"] }
fern = { version = "0.7.1", features = ["colored"] }
futures-util = "0.3.32"
hex = "0.4.3"
log = "0.4.29"
parking_lot = { version = "0.12.5", features = ["arc_lock", "hardware-lock-elision", "serde", "deadlock_detection"] }
percent-encoding = "2.3.2"
rcgen = "0.14.7"
regex = "1.12.3"
rustls = { version = "0.23.37", default-features = false, features = ["std", "ring"] }
rustls-pemfile = "2.2.0"
sentry = { version = "0.48.1", default-features = false, features = ["rustls", "backtrace", "contexts", "panic", "transport", "debug-images", "reqwest"] }
sentry-actix = "0.48.1"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = { version = "1.0.149", features = ["preserve_order"] }
serde_millis = "0.1.1"
sha1 = "0.11.0"
socket2 = "0.6.3"
sqlx = { version = "0.8.6", features = ["mysql", "postgres", "sqlite", "runtime-tokio-rustls"] }
async-trait = "0.1.89"
redis = { version = "1.2.1", features = ["tokio-comp", "connection-manager"] }
memcache = { version = "0.19.0", default-features = false }
thiserror = "2.0.18"
tokio = { version = "1.52.2", features = ["full"] }
rand = "0.10.1"
base64 = "0.22.1"
tokio-shutdown = "0.1.5"
toml = "1.1.2"
tracing = "0.1.44"
utoipa-swagger-ui = { version = "9.0.2", features = ["actix-web"] }
lazy_static = "1.5.0"
crossbeam = "0.8.4"
smallvec = { version = "1.15.1", features = ["union", "const_generics"] }
ahash = "0.8.12"
lz4_flex = { version = "0.13.0", default-features = false }
zstd = { version = "0.13.3", default-features = false }

[dev-dependencies]
tempfile = "^3.26"
criterion = { version = "^0.8", features = ["async_tokio"] }
mockall = "^0.14"
proptest = "^1.10"
reqwest = { version = "^0.13", default-features = false, features = ["rustls", "json"] }
tempfile = "3.27.0"
criterion = { version = "0.8.2", features = ["async_tokio"] }
mockall = "0.14.0"
proptest = "1.11.0"
reqwest = { version = "0.13.3", default-features = false, features = ["rustls", "json"] }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In Cargo.toml, does version = "1.2.3"pin exactly1.2.3, or is it a caret requirement equivalent to ^1.2.3? How do you express an exact version pin in Cargo?

💡 Result:

In Cargo.toml, version = "1.2.3" does not pin exactly to 1.2.3; it is a caret requirement equivalent to ^1.2.3, allowing any SemVer-compatible version >=1.2.3 and <2.0.0 [1][2]. To express an exact version pin, use the equals operator: version = "=1.2.3" [3][1].

Citations:


Use exact version pins if the goal is true dependency locking.

In Cargo, version = "1.2.3" is a caret requirement (equivalent to ^1.2.3), which allows SemVer-compatible updates up to the next major version. This does not pin exact versions. To lock dependencies precisely, use version = "=1.2.3" instead. Additionally, enforce reproducible builds by ensuring release builds use the checked-in lockfile.

Fix pattern
-actix = "0.13.5"
+actix = "=0.13.5"

-tokio = { version = "1.52.2", features = ["full"] }
+tokio = { version = "=1.52.2", features = ["full"] }

-serde = { version = "1.0.228", features = ["derive"] }
+serde = { version = "=1.0.228", features = ["derive"] }

Apply across all modified dependencies.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Cargo.toml` around lines 36 - 91, Change all caret-style version requirements
in the Cargo.toml dependency lists to exact pins by prefixing with '=' (e.g.,
change actix = "0.13.5" to actix = "=0.13.5") for every dependency shown (actix,
actix-cors, actix-web, actix-web-actors, tokio-tungstenite, rmp-serde,
once_cell, uuid, async-std, binascii, bip_bencode, byteorder, chrono, clap,
fern, futures-util, hex, log, parking_lot, percent-encoding, rcgen, regex,
rustls, rustls-pemfile, sentry, sentry-actix, serde, serde_json, serde_millis,
sha1, socket2, sqlx, async-trait, redis, memcache, thiserror, tokio, rand,
base64, tokio-shutdown, toml, tracing, utoipa-swagger-ui, lazy_static,
crossbeam, smallvec, ahash, lz4_flex, zstd and the dev-dependencies tempfile,
criterion, mockall, proptest, reqwest) so versions are exact; also update any
feature tuples unchanged and ensure CI/release jobs are configured to use the
checked-in Cargo.lock for reproducible builds.

Comment thread docker/Dockerfile
RUN apk add git musl-dev curl pkgconfig openssl-dev openssl-libs-static --no-interactive
RUN git clone https://github.com/Power2All/torrust-actix.git /app/torrust-actix
RUN cd /app/torrust-actix && git checkout tags/v4.2.8
RUN cd /app/torrust-actix && git checkout tags/v4.2.9

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Build the checked-out source instead of a remote tag.

This image no longer packages the code in the current checkout; it packages whatever v4.2.9 points to on GitHub. That makes PR builds depend on the tag existing and can silently miss local changes.

📦 Proposed fix
-RUN git clone https://github.com/Power2All/torrust-actix.git /app/torrust-actix
-RUN cd /app/torrust-actix && git checkout tags/v4.2.9
 WORKDIR /app/torrust-actix
-RUN cd /app/torrust-actix
-RUN cargo build --release && rm -Rf target/release/.fingerprint target/release/build target/release/deps target/release/examples target/release/incremental
+COPY . .
+RUN cargo build --release --locked && rm -Rf target/release/.fingerprint target/release/build target/release/deps target/release/examples target/release/incremental
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docker/Dockerfile` at line 6, The Dockerfile currently forces a git checkout
of the remote tag via the RUN line "RUN cd /app/torrust-actix && git checkout
tags/v4.2.9", which causes the image to package the remote tag instead of local
sources; remove that RUN checkout and instead rely on the build context (COPY
the local repo into /app/torrust-actix before build) or, if you must use git
inside the image, replace the checkout with a command that checks out the
current HEAD/commit (e.g., checkout the repo's provided branch or commit hash)
so PR/local changes are included; update the Dockerfile to remove the hardcoded
tag checkout and ensure COPY/ADD of local code happens prior to any build steps
that use /app/torrust-actix.

Comment thread README.md
Comment on lines +569 to +571
#### v4.2.9
* Bumping versions
* Locking versions, cause of chain attacks, making sure we use "safe" libs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Reword this changelog entry.

cause of chain attacks reads awkwardly, and safe libs is too vague for release notes. A clearer supply-chain phrasing would be better here.

✏️ Suggested wording
 #### v4.2.9
 * Bumping versions
-* Locking versions, cause of chain attacks, making sure we use "safe" libs
+* Locked dependency versions to reduce supply-chain risk and standardize on vetted library releases
🧰 Tools
🪛 LanguageTool

[grammar] ~571-~571: Ensure spelling is correct
Context: ....9 * Bumping versions * Locking versions, cause of chain attacks, making sure we use "s...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 569 - 571, Update the v4.2.9 changelog entry: replace
the awkward phrase "cause of chain attacks" with a clearer supply-chain security
phrase and replace the vague '"safe" libs' wording with a concrete description
(e.g., "locking dependency versions to mitigate supply‑chain risks" and
"updating/locking vulnerable third‑party libraries"). Edit the two bullets under
"#### v4.2.9" to read something like "Locking dependency versions to mitigate
supply‑chain risks" and "Bumping/locking third‑party library versions to address
known vulnerabilities" so the purpose is explicit.

Comment thread src/main.rs
Comment on lines +80 to +82
if args.create_database {
task::sleep(Duration::from_secs(1)).await;
exit(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In Rust, does std::process::exit(0)runDropdestructors, and is returning frommain/an async block the recommended way to exit after work is complete?

💡 Result:

No, std::process::exit(0) does not run Drop destructors. It immediately terminates the process without running destructors on the current stack or any other thread's stack [1][2][3]. The official Rust documentation explicitly states this and recommends avoiding it for clean shutdowns [1].

Citations:


🏁 Script executed:

cat -n src/main.rs | sed -n '60,95p'

Repository: Power2All/torrust-actix

Length of output: 2231


🏁 Script executed:

cat -n src/main.rs | sed -n '1,80p'

Repository: Power2All/torrust-actix

Length of output: 3329


🏁 Script executed:

cat -n src/main.rs | sed -n '150,220p'

Repository: Power2All/torrust-actix

Length of output: 3433


🏁 Script executed:

cat -n src/main.rs | tail -50

Repository: Power2All/torrust-actix

Length of output: 2547


Return from the async block instead of calling exit(0) here.

std::process::exit(0) immediately terminates the process without running any Drop destructors. This means _sentry_guard and other resources in the outer scope won't be cleaned up properly. Since this code is already inside the async block that returns Ok(()), use return Ok(()); instead to enable normal cleanup.

♻️ Proposed fix
             if args.create_database {
                 task::sleep(Duration::from_secs(1)).await;
-                exit(0);
+                return Ok(());
             }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if args.create_database {
task::sleep(Duration::from_secs(1)).await;
exit(0);
if args.create_database {
task::sleep(Duration::from_secs(1)).await;
return Ok(());
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main.rs` around lines 80 - 82, The code currently calls
std::process::exit(0) inside the async block when args.create_database is true,
which bypasses Drop and prevents cleanup (e.g. _sentry_guard); replace the
exit(...) call with an early return from the async block (return Ok(()) ) so the
function can unwind normally after awaiting task::sleep(Duration::from_secs(1)).
Locate the branch checking args.create_database and change the control flow to
return Ok(()) instead of calling exit(0), preserving the sleep await and
allowing outer scope destructors to run.

@Power2All Power2All merged commit 328e4f2 into master May 7, 2026
2 checks passed
@Power2All Power2All deleted the v4.2.9 branch May 7, 2026 23:25
@coderabbitai coderabbitai Bot mentioned this pull request May 8, 2026
@coderabbitai coderabbitai Bot mentioned this pull request May 25, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant