From 2e0cc09d012dd41ba14d26f4a4a6bb7b47721ede Mon Sep 17 00:00:00 2001 From: Aiden Fujiwara Date: Tue, 10 Oct 2023 16:29:49 -0700 Subject: [PATCH] skip file paths that do not conform to expected path --- src/tool_provider/artifactory.rs | 42 ++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/tool_provider/artifactory.rs b/src/tool_provider/artifactory.rs index 6b341a5..6fbd3ad 100644 --- a/src/tool_provider/artifactory.rs +++ b/src/tool_provider/artifactory.rs @@ -59,11 +59,16 @@ impl ToolProviderImpl for ArtifactoryProvider { let mut releases: Vec = Vec::new(); let mut release_map: HashMap<&str, Vec> = HashMap::new(); for file in &response.files { - let mut uri = file.uri.split("/"); - // file.uri will look something like //, so uri will be ["", , /, so uri will be ["", , /", + file.uri + ); + continue; + }; let asset_url = format!("{}artifactory/{}/{}/{}", host, repo, version, asset_name); @@ -106,6 +111,33 @@ impl ToolProviderImpl for ArtifactoryProvider { } } +fn get_version_and_asset_name<'a, I>(mut uri: I) -> Option<(&'a str, &'a str)> +where + I: Iterator, +{ + let Some(empty_string) = uri.next() else { + return None; + }; + + if empty_string != "" { + return None; + } + + let Some(version) = uri.next() else { + return None; + }; + + let Some(asset_name) = uri.next() else { + return None; + }; + + if uri.next().is_some() { + return None; + } + + Some((version, asset_name)) +} + #[derive(Debug, Serialize, Deserialize)] struct ArtifactoryResponse { files: Vec,