From 6ce7e4d42d8f08d21b1b345cc86a1bcfdd903967 Mon Sep 17 00:00:00 2001 From: Rohit kumar Date: Fri, 22 Nov 2024 17:36:57 +0530 Subject: [PATCH] PR Clone fix --- .github/workflows/build.yml | 2 +- src/utils/common.rs | 32 +++++++++++++------------------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3c7b6a..aabe564 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,4 +28,4 @@ jobs: context: . file: ./Dockerfile push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/hela:v8 + tags: ${{ secrets.DOCKERHUB_USERNAME }}/hela:v10 diff --git a/src/utils/common.rs b/src/utils/common.rs index d74d629..1aeb907 100644 --- a/src/utils/common.rs +++ b/src/utils/common.rs @@ -98,30 +98,24 @@ pub async fn bulk_check_hash_exists( mongo_uri: &str, ) -> Result, Box> { let client = connect_to_mongodb(mongo_uri, "code-security-open-source").await?; - // let existing_hashes = find_messages_in_hashes(&client, hashes).await?; - // returb blank HashSet if no hashes found - let existing_hashes = HashSet::new(); - let blank_hashset = HashSet::new(); - if existing_hashes.is_empty() { - return Ok(blank_hashset); - } + let existing_hashes = find_messages_in_hashes(&client, hashes).await?; Ok(existing_hashes) } pub async fn register_hash(message: &str, mongo_uri: &str) { let hashed_message = hash_text(message); - // match connect_to_mongodb(mongo_uri, "code-security-open-source").await { - // Ok(client) => { - // let collection = client - // .database("code-security-open-source") - // .collection("hashes"); - // let document = doc! { "message": hashed_message }; - // collection.insert_one(document, None).await.unwrap(); - // } - // Err(e) => { - // print_error(&format!("Error: {}", e.to_string()), 101); - // } - // } + match connect_to_mongodb(mongo_uri, "code-security-open-source").await { + Ok(client) => { + let collection = client + .database("code-security-open-source") + .collection("hashes"); + let document = doc! { "message": hashed_message }; + collection.insert_one(document, None).await.unwrap(); + } + Err(e) => { + print_error(&format!("Error: {}", e.to_string()), 101); + } + } } pub fn print_error(error: &str, error_code: i32) { if error.to_lowercase().starts_with("warning") {