Move vulnerable dependencies to patched versions (#7)

* Move vulnerable dependencies to patched versions

Backend (Cargo.lock): openssl 0.10.55 -> 0.10.81, bytes 1.12.1, h2 0.3.27,
tokio 1.26 -> 1.47.1 (mio 1.x), url 2.3.1 -> 2.5.7 (idna 1.1), rand 0.8.8,
spin 0.9.9, time 0.3.55, ring 0.17.14.

Three alerts needed manifest changes:

- tokio-rustls 0.23 -> 0.26 (rustls 0.20 -> 0.23), which is what moves
  ring off 0.16. The ring provider is selected explicitly instead of the
  default aws-lc-rs, so the image build needs no cmake/C toolchain; roots
  still come from webpki-roots (now 1.0). Checked against live hosts: a
  valid certificate connects, an expired one and a name mismatch are
  refused.
- maxminddb 0.23 -> 0.27: lookup() now returns a result that is decoded,
  and the City model's fields are no longer Options. The existing
  locate_random_ip test (12.5.56.25 -> "Gardena") passes.
- structopt (clap 2, which pulled atty) -> clap 4 derive in telemetry_core,
  telemetry_shard and the soak tests; criterion 0.4 -> 0.5 for the same
  reason. Both binaries' arguments were parsed before and after for the
  docker-compose invocations and a set of other cases: identical results,
  except that `--feed-timeout` given without a value is now an error where
  structopt silently used the default. --denylist keeps taking every value
  up to the next flag (num_args = 1..), as its help text describes.

Frontend: npm audit fix within ranges, and webpack-dev-server 4 -> 5.2.6
(no devServer options are configured, so nothing to migrate). Left:
sockjs -> uuid 8 inside webpack-dev-server 5; the fix is 6.0, which needs
Node 22 while CI runs 20, and it is the local dev server only.

Checked: backend cargo test (58 passed), clippy, fmt; frontend lint,
prettier, test and build.

* Reject an invalid byte size instead of panicking

ByteSize::from_str called expect("all ascii digits") on the numeric part,
so a value with no digits ("abc", "k") or one too large for usize
aborted the shard at startup with a panic instead of a usage error, and
the suffix multiplication could overflow silently in release builds.
Parse errors now return Err and the multiplication is checked.

The new test fails on the old code (panic) and passes on this one.
This commit is contained in:
SatoshiQaziMuhammed authored and GitHub committed 2026-10-03 04:44:21 +04:00
1 parent fe3dd7744a
commit 925b6c9bcd
12 files changed
+4874 -2694

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ serde = { version = "1.0.126", features = ["derive"] }
serde_json = "1.0.64"
simple_logger = "4.0.0"
soketto = "0.7.1"
structopt = "0.3.21"
clap = { version = "4.5", features = ["derive"] }
thiserror = "1.0.25"
tokio = { version = "1.10.1", features = ["full"] }
tokio-util = { version = "0.7.4", features = ["compat"] }
+13 -13
View File
@@ -29,6 +29,7 @@ use std::{
use aggregator::{Aggregator, FromWebsocket};
use blocked_addrs::BlockedAddrs;
use clap::Parser;
use common::byte_size::ByteSize;
use common::http_utils;
use common::node_message;
@@ -38,7 +39,6 @@ use futures::{SinkExt, StreamExt};
use http::Uri;
use hyper::{Method, Response};
use simple_logger::SimpleLogger;
use structopt::StructOpt;
#[cfg(not(target_env = "msvc"))]
use jemallocator::Jemalloc;
@@ -53,21 +53,21 @@ const NAME: &str = "Substrate Telemetry Backend Shard";
const ABOUT: &str = "This is the Telemetry Backend Shard that forwards the \
data sent by Substrate/Polkadot nodes to the Backend Core";
#[derive(StructOpt, Debug)]
#[structopt(name = NAME, version = VERSION, author = AUTHORS, about = ABOUT)]
#[derive(Parser, Debug)]
#[command(name = NAME, version = VERSION, author = AUTHORS, about = ABOUT)]
struct Opts {
/// This is the socket address that this shard is listening to. This is restricted to
/// localhost (127.0.0.1) by default and should be fine for most use cases. If
/// you are using Telemetry in a container, you likely want to set this to '0.0.0.0:8000'
#[structopt(short = "l", long = "listen", default_value = "127.0.0.1:8001")]
#[arg(short = 'l', long = "listen", default_value = "127.0.0.1:8001")]
socket: std::net::SocketAddr,
/// The desired log level; one of 'error', 'warn', 'info', 'debug' or 'trace', where
/// 'error' only logs errors and 'trace' logs everything.
#[structopt(long = "log", default_value = "info")]
#[arg(long = "log", default_value = "info")]
log_level: log::LevelFilter,
/// Url to the Backend Core endpoint accepting shard connections
#[structopt(
short = "c",
#[arg(
short = 'c',
long = "core",
default_value = "ws://127.0.0.1:8000/shard_submit/"
)]
@@ -77,7 +77,7 @@ struct Opts {
///
/// This is important because without a limit, a single connection could exhaust
/// RAM by suggesting that it accounts for billions of nodes.
#[structopt(long, default_value = "20")]
#[arg(long, default_value = "20")]
max_nodes_per_connection: usize,
/// What is the maximum number of bytes per second, on average, that a connection from a
/// node is allowed to send to a shard before it gets booted. This is averaged over a
@@ -86,26 +86,26 @@ struct Opts {
///
/// As a reference point, syncing a new Polkadot node leads to a maximum of about 25k of
/// traffic on average (at least initially).
#[structopt(long, default_value = "256k")]
#[arg(long, default_value = "256k")]
max_node_data_per_second: ByteSize,
/// How many seconds is a "/feed" connection that violates the '--max-node-data-per-second'
/// value prevented from reconnecting to this shard for, in seconds.
#[structopt(long, default_value = "600")]
#[arg(long, default_value = "600")]
node_block_seconds: u64,
/// Number of worker threads to spawn. If "0" is given, use the number of CPUs available
/// on the machine. If no value is given, use an internal default that we have deemed sane.
#[structopt(long)]
#[arg(long)]
worker_threads: Option<usize>,
/// Roughly how long to wait in seconds for new telemetry data to arrive from a node. If
/// telemetry for a node does not arrive in this time frame, we remove the corresponding node
/// state, and if no messages are received on the connection at all in this time, it will be
/// dropped.
#[structopt(long, default_value = "60")]
#[arg(long, default_value = "60")]
stale_node_timeout: u64,
}
fn main() {
let opts = Opts::from_args();
let opts = Opts::parse();
SimpleLogger::new()
.with_level(opts.log_level)