diff --git a/src/proxy-manager/Cargo.lock b/src/proxy-manager/Cargo.lock index 7f2f3106a8..e5f9cb79a4 100644 --- a/src/proxy-manager/Cargo.lock +++ b/src/proxy-manager/Cargo.lock @@ -11,15 +11,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "anyhow" version = "1.0.57" @@ -154,17 +145,25 @@ dependencies = [ [[package]] name = "clap" -version = "2.34.0" +version = "4.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e" dependencies = [ - "ansi_term", "atty", "bitflags", + "clap_lex", + "once_cell", "strsim", - "textwrap", - "unicode-width", - "vec_map", + "termcolor", +] + +[[package]] +name = "clap_lex" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" +dependencies = [ + "os_str_bytes", ] [[package]] @@ -707,9 +706,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.8.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "onefuzz-proxy-manager" @@ -789,6 +788,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + [[package]] name = "parking_lot" version = "0.12.0" @@ -1248,9 +1253,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" @@ -1297,15 +1302,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - [[package]] name = "thiserror" version = "1.0.31" @@ -1469,12 +1465,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "unicode-xid" version = "0.1.0" @@ -1524,12 +1514,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "want" version = "0.3.0" diff --git a/src/proxy-manager/Cargo.toml b/src/proxy-manager/Cargo.toml index 3f3c8588a4..794aef933b 100644 --- a/src/proxy-manager/Cargo.toml +++ b/src/proxy-manager/Cargo.toml @@ -8,17 +8,26 @@ license = "MIT" [dependencies] anyhow = "1.0" -clap = "2.34" +clap = { version = "4", features = ["cargo", "string"] } env_logger = "0.9" futures = "0.3" -reqwest = { version = "0.11", features = ["json", "stream", "native-tls-vendored"], default-features = false } +reqwest = { version = "0.11", features = [ + "json", + "stream", + "native-tls-vendored", +], default-features = false } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" storage-queue = { path = "../agent/storage-queue" } thiserror = "1.0" -tokio = { version = "1.24", features = ["macros", "rt-multi-thread", "fs", "process"] } +tokio = { version = "1.24", features = [ + "macros", + "rt-multi-thread", + "fs", + "process", +] } url = { version = "2.3", features = ["serde"] } -reqwest-retry = { path = "../agent/reqwest-retry"} +reqwest-retry = { path = "../agent/reqwest-retry" } onefuzz-telemetry = { path = "../agent/onefuzz-telemetry" } uuid = "0.8" log = "0.4" diff --git a/src/proxy-manager/src/config.rs b/src/proxy-manager/src/config.rs index f346fb62bd..58d7ec498a 100644 --- a/src/proxy-manager/src/config.rs +++ b/src/proxy-manager/src/config.rs @@ -2,9 +2,9 @@ // Licensed under the MIT License. use crate::proxy; -use anyhow::Result; +use anyhow::{bail, Result}; use onefuzz_telemetry::{ - set_appinsights_clients, EventData, InstanceTelemetryKey, MicrosoftTelemetryKey, Role, + info, set_appinsights_clients, EventData, InstanceTelemetryKey, MicrosoftTelemetryKey, Role, }; use reqwest_retry::SendRetry; use serde::{Deserialize, Serialize}; @@ -16,9 +16,6 @@ use uuid::Uuid; #[derive(Error, Debug)] pub enum ProxyError { - #[error("missing argument {0}")] - MissingArg(String), - #[error("missing etag header")] EtagError, diff --git a/src/proxy-manager/src/main.rs b/src/proxy-manager/src/main.rs index 9d2f89cac3..bf9db6f9ec 100644 --- a/src/proxy-manager/src/main.rs +++ b/src/proxy-manager/src/main.rs @@ -1,19 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -#[macro_use] -extern crate onefuzz_telemetry; -#[macro_use] -extern crate anyhow; -#[macro_use] -extern crate clap; - mod config; mod proxy; use anyhow::Result; -use clap::{App, Arg, SubCommand}; -use config::{Config, ProxyError::MissingArg}; +use clap::{Arg, Command}; +use config::Config; +use onefuzz_telemetry::{error, info}; use std::{ io::{stdout, Write}, time::Instant, @@ -53,23 +47,18 @@ async fn run(proxy_config: Config) -> Result<()> { fn main() -> Result<()> { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); - let license_cmd = SubCommand::with_name("licenses").about("display third-party licenses"); + let license_cmd = Command::new("licenses").about("display third-party licenses"); let version = format!( "{} onefuzz:{} git:{}", - crate_version!(), + clap::crate_version!(), env!("ONEFUZZ_VERSION"), env!("GIT_VERSION") ); - let app = App::new("onefuzz-proxy") - .version(version.as_str()) - .arg( - Arg::with_name("config") - .long("config") - .short("c") - .takes_value(true), - ) + let app = Command::new("onefuzz-proxy") + .version(version) + .arg(Arg::new("config").long("config").short('c').required(true)) .subcommand(license_cmd); let matches = app.get_matches(); @@ -79,8 +68,8 @@ fn main() -> Result<()> { } let config_path = matches - .value_of("config") - .ok_or_else(|| MissingArg("--config".to_string()))? + .get_one::("config") + .expect("was required") .parse()?; let rt = Runtime::new()?; diff --git a/src/proxy-manager/src/proxy.rs b/src/proxy-manager/src/proxy.rs index d0a1fbc36c..395a857207 100644 --- a/src/proxy-manager/src/proxy.rs +++ b/src/proxy-manager/src/proxy.rs @@ -3,6 +3,7 @@ use crate::config::ConfigData; use anyhow::Result; +use onefuzz_telemetry::{error, info}; use std::{collections::HashMap, path::Path}; use tokio::process::Command;