From eed1a0c29a08b8c0388168c8670518ad5f69c715 Mon Sep 17 00:00:00 2001 From: adhirpotdarbito Date: Thu, 7 Nov 2024 16:48:13 +0530 Subject: [PATCH 1/3] Added support for linter feedback enable/disable and output path for server mode. --- cra-scripts/bito-cra.properties | 7 +++++++ cra-scripts/bito-cra.ps1 | 9 ++++++++- cra-scripts/bito-cra.sh | 10 ++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cra-scripts/bito-cra.properties b/cra-scripts/bito-cra.properties index d87886a..cde9778 100644 --- a/cra-scripts/bito-cra.properties +++ b/cra-scripts/bito-cra.properties @@ -7,6 +7,7 @@ git.access_token= git.domain= static_analysis=True static_analysis_tool=fb_infer,astral_ruff,mypy +linters_feedback=True review_scope= dependency_check=False code_context=True @@ -17,3 +18,9 @@ cra_version=latest exclude_branches=main,master exclude_files=*.xml,*.json,*.properties,.gitignore,*.yml,*.md exclude_draft_pr=True +custom_rules.configured_ws_ids= +custom_rules.aws_access_key_id= +custom_rules.aws_secret_access_key= +custom_rules.region_name= +custom_rules.bucket_name= +custom_rules.aes_key= \ No newline at end of file diff --git a/cra-scripts/bito-cra.ps1 b/cra-scripts/bito-cra.ps1 index 61426f7..c556d7f 100755 --- a/cra-scripts/bito-cra.ps1 +++ b/cra-scripts/bito-cra.ps1 @@ -232,6 +232,7 @@ function Check-OutputDirectory { exit 1 } + Write-Host "Output path: $output_path" #return valid cli directory return $output_path } @@ -406,6 +407,7 @@ $optional_params_cli = @( "review_comments", "static_analysis", "static_analysis_tool", + "linters_feedback", "review_scope", "exclude_branches", "exclude_files", @@ -441,6 +443,7 @@ $optional_params_server = @( "review_comments", "static_analysis", "static_analysis_tool", + "linters_feedback" "review_scope", "exclude_branches", "exclude_files", @@ -460,6 +463,7 @@ $optional_params_server = @( "custom_rules.region_name" "custom_rules.bucket_name" "custom_rules.aes_key" + "output_path" ) $bee_params = @( @@ -528,7 +532,7 @@ foreach ($param in $required_params) { foreach ($param in $optional_params) { if ($param -eq "dependency_check.snyk_auth_token" -and $props["dependency_check"] -eq "True") { Ask-For-Param $param $false - } elseif ($param -ne "dependency_check.snyk_auth_token" -and $param -ne "env" -and $param -ne "cli_path" -and $param -ne "output_path" -and $param -ne "static_analysis_tool" -and $param -ne "git.domain" -and $param -ne "review_scope" -and $param -ne "exclude_branches" -and $param -ne "exclude_files" -and $param -ne "exclude_draft_pr" -and $param -ne "cr_event_type" -and $param -ne "posting_to_pr" -and $param -ne "custom_rules.configured_ws_ids" -and $param -ne "custom_rules.aws_access_key_id" -and $param -ne "custom_rules.aws_secret_access_key" -and $param -ne "custom_rules.region_name" -and $param -ne "custom_rules.bucket_name" -and $param -ne "custom_rules.aes_key") { + } elseif ($param -ne "dependency_check.snyk_auth_token" -and $param -ne "env" -and $param -ne "cli_path" -and $param -ne "output_path" -and $param -ne "static_analysis_tool" -and $param -ne "linters_feedback" -and $param -ne "git.domain" -and $param -ne "review_scope" -and $param -ne "exclude_branches" -and $param -ne "exclude_files" -and $param -ne "exclude_draft_pr" -and $param -ne "cr_event_type" -and $param -ne "posting_to_pr" -and $param -ne "custom_rules.configured_ws_ids" -and $param -ne "custom_rules.aws_access_key_id" -and $param -ne "custom_rules.aws_secret_access_key" -and $param -ne "custom_rules.region_name" -and $param -ne "custom_rules.bucket_name" -and $param -ne "custom_rules.aes_key" -and $param -ne "code_context_config.partial_timeout" -and $param -ne "code_context_config.max_depth" -and $param -ne "code_context_config.kill_timeout_sec") { Ask-For-Param $param $false } } @@ -554,6 +558,9 @@ foreach ($param in $required_params + $bee_params + $optional_params) { $docker_cmd += " --static_analysis.fb_infer.enabled=$validated_boolean" } elseif ($param -eq "static_analysis_tool") { $docker_cmd += " --$param=$($props[$param])" + } elseif ($param -eq "linters_feedback") { + $validated_boolean = Validate-Boolean $props[$param] + $docker_cmd += " --$param=$validated_boolean" } elseif ($param -eq "review_scope") { $scopes = $($props[$param]) -replace ',\s*', ',' $docker_cmd += " --$param='[$scopes]'" diff --git a/cra-scripts/bito-cra.sh b/cra-scripts/bito-cra.sh index 5939d24..5cc9e64 100755 --- a/cra-scripts/bito-cra.sh +++ b/cra-scripts/bito-cra.sh @@ -220,7 +220,7 @@ check_output_directory() { echo "output path directory not found!" return 1 else - echo $output_path + echo "Output Path: $output_path" return 0 fi } @@ -416,6 +416,7 @@ optional_params_cli=( "review_comments" "static_analysis" "static_analysis_tool" + "linters_feedback" "review_scope" "exclude_branches" "exclude_files" @@ -452,6 +453,7 @@ optional_params_server=( "review_comments" "static_analysis" "static_analysis_tool" + "linters_feedback" "review_scope" "exclude_branches" "exclude_files" @@ -472,6 +474,7 @@ optional_params_server=( "custom_rules.region_name" "custom_rules.bucket_name" "custom_rules.aes_key" + "output_path" ) bee_params=( @@ -537,7 +540,7 @@ done for param in "${optional_params[@]}"; do if [ "$param" == "dependency_check.snyk_auth_token" ] && [ "${props["dependency_check"]}" == "True" ]; then ask_for_param "$param" "False" - elif [ "$param" != "dependency_check.snyk_auth_token" ] && [ "$param" != "env" ] && [ "$param" != "cli_path" ] && [ "$param" != "output_path" ] && [ "$param" != "static_analysis_tool" ] && [ "$param" != "git.domain" ] && [ "$param" != "review_scope" ] && [ "$param" != "exclude_branches" ] && [ "$param" != "nexus_url" ] && [ "$param" != "exclude_files" ] && [ "$param" != "exclude_draft_pr" ] && [ "$param" != "cr_event_type" ] && [ "$param" != "posting_to_pr" ] && [ "$param" != "custom_rules.configured_ws_ids" ] && [ "$param" != "custom_rules.aws_access_key_id" ] && [ "$param" != "custom_rules.aws_secret_access_key" ] && [ "$param" != "custom_rules.region_name" ] && [ "$param" != "custom_rules.bucket_name" ] && [ "$param" != "custom_rules.aes_key" ]; then + elif [ "$param" != "dependency_check.snyk_auth_token" ] && [ "$param" != "env" ] && [ "$param" != "cli_path" ] && [ "$param" != "output_path" ] && [ "$param" != "static_analysis_tool" ] && [ "$param" != "linters_feedback" ] && [ "$param" != "git.domain" ] && [ "$param" != "review_scope" ] && [ "$param" != "exclude_branches" ] && [ "$param" != "nexus_url" ] && [ "$param" != "exclude_files" ] && [ "$param" != "exclude_draft_pr" ] && [ "$param" != "cr_event_type" ] && [ "$param" != "posting_to_pr" ] && [ "$param" != "custom_rules.configured_ws_ids" ] && [ "$param" != "custom_rules.aws_access_key_id" ] && [ "$param" != "custom_rules.aws_secret_access_key" ] && [ "$param" != "custom_rules.region_name" ] && [ "$param" != "custom_rules.bucket_name" ] && [ "$param" != "custom_rules.aes_key" ] && [ "$param" != "code_context_config.partial_timeout" ] && [ "$param" != "code_context_config.max_depth" ] && [ "$param" != "code_context_config.kill_timeout_sec" ]; then ask_for_param "$param" "False" fi done @@ -569,6 +572,9 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}"; docker_cmd+=" --static_analysis.fb_infer.enabled=${props[$param]}" elif [ "$param" == "static_analysis_tool" ]; then docker_cmd+=" --static_analysis_tool=${props[$param]}" + elif [ "$param" == "linters_feedback" ]; then + props[$param]=$(validate_boolean "${props[$param]}") + docker_cmd+=" --linters_feedback=${props[$param]}" elif [ "$param" == "review_scope" ]; then scopes=$(echo ${props[$param]} | sed 's/, */,/g') docker_cmd+=" --review_scope='[$scopes]'" From 6a71a9f28f96d8ad3d12546958b790f307dd4ad7 Mon Sep 17 00:00:00 2001 From: adhirpotdarbito Date: Thu, 7 Nov 2024 17:02:39 +0530 Subject: [PATCH 2/3] Removed un-necessary custom rules related parameters from bito-cra.properties. --- cra-scripts/bito-cra.properties | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cra-scripts/bito-cra.properties b/cra-scripts/bito-cra.properties index cde9778..7bdd190 100644 --- a/cra-scripts/bito-cra.properties +++ b/cra-scripts/bito-cra.properties @@ -18,9 +18,3 @@ cra_version=latest exclude_branches=main,master exclude_files=*.xml,*.json,*.properties,.gitignore,*.yml,*.md exclude_draft_pr=True -custom_rules.configured_ws_ids= -custom_rules.aws_access_key_id= -custom_rules.aws_secret_access_key= -custom_rules.region_name= -custom_rules.bucket_name= -custom_rules.aes_key= \ No newline at end of file From 1fbaca1040a30da47e63b815f5e9779a4c6717d2 Mon Sep 17 00:00:00 2001 From: adhirpotdarbito Date: Thu, 7 Nov 2024 18:39:37 +0530 Subject: [PATCH 3/3] Resolved error due to missing comma. --- cra-scripts/bito-cra.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cra-scripts/bito-cra.ps1 b/cra-scripts/bito-cra.ps1 index c556d7f..95a8249 100755 --- a/cra-scripts/bito-cra.ps1 +++ b/cra-scripts/bito-cra.ps1 @@ -443,7 +443,7 @@ $optional_params_server = @( "review_comments", "static_analysis", "static_analysis_tool", - "linters_feedback" + "linters_feedback", "review_scope", "exclude_branches", "exclude_files",