diff --git a/rust/src/chrome.rs b/rust/src/chrome.rs index 0179b4f4512a6..7beb7b5b1ac6a 100644 --- a/rust/src/chrome.rs +++ b/rust/src/chrome.rs @@ -192,7 +192,11 @@ impl SeleniumManager for ChromeManager { "Reading {} version from {}", &self.driver_name, driver_url )); - match read_version_from_link(self.get_http_client(), driver_url) { + match read_version_from_link( + self.get_http_client(), + driver_url, + self.get_logger(), + ) { Ok(version) => { driver_version = version; break; diff --git a/rust/src/downloads.rs b/rust/src/downloads.rs index f56c6bf62e4a6..64de457681ac9 100644 --- a/rust/src/downloads.rs +++ b/rust/src/downloads.rs @@ -65,8 +65,12 @@ pub async fn download_driver_to_tmp_folder( Ok((tmp_dir, target_path)) } -pub fn read_version_from_link(http_client: &Client, url: String) -> Result> { - parse_version(read_content_from_link(http_client, url)?) +pub fn read_version_from_link( + http_client: &Client, + url: String, + log: &Logger, +) -> Result> { + parse_version(read_content_from_link(http_client, url)?, log) } #[tokio::main] @@ -81,6 +85,10 @@ pub async fn read_content_from_link( pub async fn read_redirect_from_link( http_client: &Client, url: String, + log: &Logger, ) -> Result> { - parse_version(http_client.get(&url).send().await?.url().path().to_string()) + parse_version( + http_client.get(&url).send().await?.url().path().to_string(), + log, + ) } diff --git a/rust/src/edge.rs b/rust/src/edge.rs index 30a41e9dbc2bc..55e2bbf7a5790 100644 --- a/rust/src/edge.rs +++ b/rust/src/edge.rs @@ -192,7 +192,8 @@ impl SeleniumManager for EdgeManager { "Reading {} version from {}", &self.driver_name, driver_url )); - let driver_version = read_version_from_link(self.get_http_client(), driver_url)?; + let driver_version = + read_version_from_link(self.get_http_client(), driver_url, self.get_logger())?; if !browser_version.is_empty() { metadata.drivers.push(create_driver_metadata( diff --git a/rust/src/files.rs b/rust/src/files.rs index 472e55f3beb0e..70f406bc579ba 100644 --- a/rust/src/files.rs +++ b/rust/src/files.rs @@ -179,8 +179,9 @@ pub fn get_binary_extension(os: &str) -> &str { } } -pub fn parse_version(version_text: String) -> Result> { +pub fn parse_version(version_text: String, log: &Logger) -> Result> { if version_text.to_ascii_lowercase().contains("error") { + log.debug(format!("Error parsing version: {}", version_text)); return Err(PARSE_ERROR.into()); } let mut parsed_version = "".to_string(); diff --git a/rust/src/firefox.rs b/rust/src/firefox.rs index de3cbe47b8c79..6831a28e4e89c 100644 --- a/rust/src/firefox.rs +++ b/rust/src/firefox.rs @@ -178,7 +178,8 @@ impl SeleniumManager for FirefoxManager { } _ => { let latest_url = format!("{}{}", DRIVER_URL, LATEST_RELEASE); - let driver_version = read_redirect_from_link(self.get_http_client(), latest_url)?; + let driver_version = + read_redirect_from_link(self.get_http_client(), latest_url, self.get_logger())?; if !browser_version.is_empty() { metadata.drivers.push(create_driver_metadata( diff --git a/rust/src/iexplorer.rs b/rust/src/iexplorer.rs index aa66d6b7b2d0f..43b97526297bd 100644 --- a/rust/src/iexplorer.rs +++ b/rust/src/iexplorer.rs @@ -134,8 +134,10 @@ impl SeleniumManager for IExplorerManager { let index_release = driver_url.rfind(IEDRIVER_RELEASE).unwrap() + IEDRIVER_RELEASE.len(); - let driver_version = - parse_version(driver_url.as_str()[index_release..].to_string())?; + let driver_version = parse_version( + driver_url.as_str()[index_release..].to_string(), + self.get_logger(), + )?; if !browser_version.is_empty() { metadata.drivers.push(create_driver_metadata( diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 71a3a84651c04..58fdb75122dcf 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -170,7 +170,8 @@ pub trait SeleniumManager { Ok(out) => out, Err(_e) => continue, }; - let full_browser_version = parse_version(output).unwrap_or_default(); + let full_browser_version = + parse_version(output, self.get_logger()).unwrap_or_default(); if full_browser_version.is_empty() { continue; } @@ -254,7 +255,7 @@ pub trait SeleniumManager { .run_shell_command_with_log(format_one_arg(DASH_DASH_VERSION, self.get_driver_name())) { Ok(output) => { - let parsed_version = parse_version(output).unwrap_or_default(); + let parsed_version = parse_version(output, self.get_logger()).unwrap_or_default(); if !parsed_version.is_empty() { let which_command = if WINDOWS.is(self.get_os()) { WHERE_COMMAND