Skip to content

Commit 57ca709

Browse files
koskjanoahcoetseepanaman67Defman
authored
Cargo audit fix (#512)
* Change from `chrono` implementation to impl based on `time` crate, as it has addressed the issues present in RUSTSEC-2020-0159 in its own security advisory: RUSTSEC-2020-071. * Update feather/server/src/logging.rs Co-authored-by: Nick Paladino <[email protected]> * Remove 'simple_logger' from Cargo.toml in feather/utils * Remove 'simple_logger' from Cargo.toml in feather/utils, adding `logging` module that mimics the `feather-server` setup. * Update zeroize in Cargo.lock to avoid RUSTSEC-2021-0115 * Update Cargo.toml/Cargo.lock to new `rsa-der` version 0.3.0 Note that this still leaves the `rsa` issue until the `pem-rfc7468`/`pkcs8` dependency issues are resolved within that crate. * Pin `base64ct` to "=1.1.1" to avoid `edition="2021"` * Update `rsa` to v0.5, Update `rand` to v0.8.0, fix implementation to account for new `RsaPrivateKey` capitalization. * Run cargo update Added `host-fs` and `sys` to `wasmer-wasi` dependencies Removed `time` from the list of `zip` dependencies * Relaxed version constraints on base64ct and time * Removed exact version dependency. Co-authored-by: Noah Coetsee <[email protected]> Co-authored-by: Noah Coetsee <[email protected]> Co-authored-by: Nick Paladino <[email protected]> Co-authored-by: Jacob Emil Ulvedal Rosborg <[email protected]>
1 parent d574826 commit 57ca709

File tree

10 files changed

+617
-451
lines changed

10 files changed

+617
-451
lines changed

Cargo.lock

+543-434
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

feather/datapacks/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ serde_json = "1"
1313
smartstring = { version = "0.2", features = [ "serde" ] }
1414
thiserror = "1"
1515
ureq = { version = "2", default-features = false, features = [ "tls" ] }
16-
zip = "0.5"
16+
zip = { version = "0.5", default-features = false, features = [ "deflate", "bzip2" ] }

feather/plugin-host/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ serde = "1"
2424
tempfile = "3"
2525
vec-arena = "1"
2626
wasmer = { version = "2", default-features = false, features = [ "jit" ] }
27-
wasmer-wasi = { version = "2", default-features = false }
27+
wasmer-wasi = { version = "2", default-features = false, features = [ "host-fs", "sys" ] }
2828

2929
[features]
3030
llvm = [ "wasmer/llvm" ]

feather/server/Cargo.toml

+8-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ahash = "0.7"
1717
anyhow = "1"
1818
base = { path = "../base", package = "feather-base" }
1919
base64 = "0.13"
20-
chrono = "0.4"
20+
time = { version = "0.3", features = ["local-offset", "formatting", "macros"] }
2121
colored = "2"
2222
common = { path = "../common", package = "feather-common" }
2323
crossbeam-utils = "0.8"
@@ -36,10 +36,14 @@ parking_lot = "0.11"
3636
plugin-host = { path = "../plugin-host", package = "feather-plugin-host" }
3737
protocol = { path = "../protocol", package = "feather-protocol" }
3838
quill-common = { path = "../../quill/common" }
39-
rand = "0.7"
39+
40+
rand = "0.8"
4041
ring = "0.16"
41-
rsa = "0.3"
42-
rsa-der = "0.2"
42+
43+
rsa = "0.5"
44+
rsa-der = "0.3"
45+
base64ct = "1"
46+
4347
serde = { version = "1", features = [ "derive" ] }
4448
serde_json = "1"
4549
sha-1 = "0.9"

feather/server/src/initial_handler.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use protocol::{
1919
ServerLoginPacket, ServerPlayPacket, ServerStatusPacket,
2020
};
2121
use rand::rngs::OsRng;
22-
use rsa::{PaddingScheme, PublicKeyParts, RSAPrivateKey};
22+
use rsa::{PaddingScheme, PublicKeyParts, RsaPrivateKey};
2323
use serde::{Deserialize, Serialize};
2424
use sha1::Sha1;
2525
use std::convert::TryInto;
@@ -205,8 +205,8 @@ fn offline_mode_uuid(username: &str) -> Uuid {
205205
const RSA_BITS: usize = 1024;
206206

207207
/// Cached RSA key used by this server instance.
208-
static RSA_KEY: Lazy<RSAPrivateKey> =
209-
Lazy::new(|| RSAPrivateKey::new(&mut OsRng, RSA_BITS).expect("failed to create RSA key"));
208+
static RSA_KEY: Lazy<RsaPrivateKey> =
209+
Lazy::new(|| RsaPrivateKey::new(&mut OsRng, RSA_BITS).expect("failed to create RSA key"));
210210
static RSA_KEY_ENCODED: Lazy<Vec<u8>> = Lazy::new(|| {
211211
rsa_der::public_key_to_der(&RSA_KEY.n().to_bytes_be(), &RSA_KEY.e().to_bytes_be())
212212
});

feather/server/src/logging.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use colored::Colorize;
22
use log::{Level, LevelFilter};
3+
use time::macros::format_description;
4+
use time::OffsetDateTime;
35

46
pub fn init(level: LevelFilter) {
57
fern::Dispatch::new()
@@ -16,9 +18,18 @@ pub fn init(level: LevelFilter) {
1618
} else {
1719
record.module_path().unwrap_or_default()
1820
};
21+
22+
let datetime: OffsetDateTime = match OffsetDateTime::now_local() {
23+
Ok(x) => x,
24+
Err(_) => OffsetDateTime::now_utc(),
25+
};
1926
out.finish(format_args!(
2027
"{} {:<5} [{}] {}",
21-
chrono::Local::now().format("%Y-%m-%d %H:%M:%S,%3f"),
28+
datetime
29+
.format(format_description!(
30+
"[year]-[month]-[day] [hour]:[minute]:[second],[subsecond digits:3]"
31+
))
32+
.unwrap(),
2233
level_string,
2334
target,
2435
message,

feather/utils/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ edition = "2018"
77
[dependencies]
88

99
[dev-dependencies]
10-
simple_logger = "1"

tools/proxy/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ futures-lite = "1"
1212
argh = "0.1"
1313
anyhow = "1"
1414
log = "0.4"
15-
simple_logger = "1"
1615
either = "1"
16+
colored = "2"
17+
fern = "0.6"
18+
time = { version = "0.3", features = ["local-offset", "formatting", "macros"] }
19+

tools/proxy/src/logging.rs

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use colored::Colorize;
2+
use log::{Level, LevelFilter};
3+
use time::macros::format_description;
4+
use time::OffsetDateTime;
5+
6+
pub fn init(level: LevelFilter) {
7+
fern::Dispatch::new()
8+
.format(|out, message, record| {
9+
let level_string = match record.level() {
10+
Level::Error => record.level().to_string().red(),
11+
Level::Warn => record.level().to_string().yellow(),
12+
Level::Info => record.level().to_string().cyan(),
13+
Level::Debug => record.level().to_string().purple(),
14+
Level::Trace => record.level().to_string().normal(),
15+
};
16+
let target = if !record.target().is_empty() {
17+
record.target()
18+
} else {
19+
record.module_path().unwrap_or_default()
20+
};
21+
22+
let datetime: OffsetDateTime = match OffsetDateTime::now_local() {
23+
Ok(x) => x,
24+
Err(_) => OffsetDateTime::now_utc(),
25+
};
26+
out.finish(format_args!(
27+
"{} {:<5} [{}] {}",
28+
datetime
29+
.format(format_description!(
30+
"[year]-[month]-[day] [hour]:[minute]:[second],[subsecond digits:3]"
31+
))
32+
.unwrap(),
33+
level_string,
34+
target,
35+
message,
36+
));
37+
})
38+
.level(level)
39+
.chain(std::io::stdout())
40+
.apply()
41+
.unwrap();
42+
}

tools/proxy/src/main.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::net::{SocketAddr, TcpListener, TcpStream};
22

3+
mod logging;
4+
35
use anyhow::{bail, Context};
46
use argh::FromArgs;
57
use async_executor::Executor;
@@ -11,7 +13,6 @@ use feather_protocol::{
1113
};
1214
use futures_lite::FutureExt;
1315
use futures_lite::{AsyncReadExt, AsyncWriteExt};
14-
use simple_logger::SimpleLogger;
1516

1617
/// A proxy for debugging and inspecting the Minecraft protocol.
1718
#[derive(Debug, FromArgs)]
@@ -26,10 +27,7 @@ struct Args {
2627
}
2728

2829
fn main() -> anyhow::Result<()> {
29-
SimpleLogger::new()
30-
.with_level(log::LevelFilter::Debug)
31-
.init()
32-
.unwrap();
30+
logging::init(log::LevelFilter::Debug);
3331
let args: Args = argh::from_env();
3432

3533
let addr = format!("127.0.0.1:{}", args.port);

0 commit comments

Comments
 (0)