From 58b7e41e74088631bfee98fa66a896746fd817d1 Mon Sep 17 00:00:00 2001 From: Rohit kumar Date: Tue, 27 Aug 2024 17:34:19 +0530 Subject: [PATCH] Fixed exit_code issue in pipeline.rs --- .github/workflows/build.yml | 2 +- src/utils/common.rs | 1 - src/utils/pipeline.rs | 25 ++++++++++++++++--------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f36282d..3a086d8 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:v5 + tags: ${{ secrets.DOCKERHUB_USERNAME }}/hela:v6 diff --git a/src/utils/common.rs b/src/utils/common.rs index 9ff884b..1d5a8b3 100644 --- a/src/utils/common.rs +++ b/src/utils/common.rs @@ -197,7 +197,6 @@ pub async fn insert_job_info( .into_iter() .map(|v| to_bson(&v).unwrap_or(Bson::Null)) .collect(); - // Create the document to insert let document = doc! { "job_id": job_id, diff --git a/src/utils/pipeline.rs b/src/utils/pipeline.rs index 2eb9d53..a7b657c 100644 --- a/src/utils/pipeline.rs +++ b/src/utils/pipeline.rs @@ -951,8 +951,10 @@ pub async fn pipeline_failure( } } } - exit_code = common::EXIT_CODE_SAST_FAILED; - exit_msg = common::SAST_FAILED_MSG.to_string(); + if is_pipeline_failed { + exit_code = common::EXIT_CODE_SAST_FAILED; + exit_msg = common::SAST_FAILED_MSG.to_string(); + } } if is_sca && sca_policy.is_some() { @@ -999,8 +1001,10 @@ pub async fn pipeline_failure( } } } - exit_code = common::EXIT_CODE_SCA_FAILED; - exit_msg = common::SCA_FAILED_MSG.to_string(); + if is_pipeline_failed { + exit_code = common::EXIT_CODE_SCA_FAILED; + exit_msg = common::SCA_FAILED_MSG.to_string(); + } } if is_secret && secret_policy.is_some() { @@ -1056,9 +1060,10 @@ pub async fn pipeline_failure( } } } - - exit_code = common::EXIT_CODE_SECRET_FAILED; - exit_msg = common::SECRET_FAILED_MSG.to_string(); + if is_pipeline_failed { + exit_code = common::EXIT_CODE_SECRET_FAILED; + exit_msg = common::SECRET_FAILED_MSG.to_string(); + } } if is_license_compliance && license_policy.is_some() { let license_policy = license_policy.unwrap().as_mapping().unwrap(); @@ -1083,8 +1088,10 @@ pub async fn pipeline_failure( } } } - exit_code = common::EXIT_CODE_LICENSE_FAILED; - exit_msg = common::LICENSE_FAILED_MSG.to_string(); + if is_pipeline_failed { + exit_code = common::EXIT_CODE_LICENSE_FAILED; + exit_msg = common::LICENSE_FAILED_MSG.to_string(); + } } if is_pipeline_failed { println!("\n\n");