Skip to content

Update bito-cra.sh #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cra-scripts/bito-cra.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ include_source_branches=
include_target_branches=
exclude_files=*.xml,*.json,*.properties,.gitignore,*.yml,*.md
exclude_draft_pr=True
post_as_request_changes=False
support_email=
suggestion_mode=essential
38 changes: 34 additions & 4 deletions cra-scripts/bito-cra.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ function Validate-Boolean {
return $boolean_val
}

# Function to set default suggestion mode
function Validate-Suggestion-Mode {
param($suggestion_mode)
# Convert the input to lowercase
$suggestion_mode = $suggestion_mode.ToLower()

if ($suggestion_mode -eq "comprehensive") {
return $suggestion_mode
}

return "essential"
}

# Function to validate a mode value i.e. cli or server
function Validate-Mode {
param($mode_val)
Expand Down Expand Up @@ -414,7 +427,10 @@ $optional_params_cli = @(
"enable_default_branch",
"exclude_branches",
"include_source_branches",
"include_target_branches",
"include_target_branches"
"post_as_request_changes",
"suggestion_mode",
"locale",
"exclude_files",
"exclude_draft_pr",
"dependency_check",
Expand All @@ -433,6 +449,7 @@ $optional_params_cli = @(
"custom_rules.region_name"
"custom_rules.bucket_name"
"custom_rules.aes_key"
"support_email"
)

# Parameters that are required/optional in mode server
Expand All @@ -456,6 +473,9 @@ $optional_params_server = @(
"exclude_branches",
"include_source_branches",
"include_target_branches",
"post_as_request_changes",
"suggestion_mode",
"locale",
"exclude_files",
"exclude_draft_pr",
"dependency_check",
Expand All @@ -474,6 +494,7 @@ $optional_params_server = @(
"custom_rules.bucket_name"
"custom_rules.aes_key"
"output_path"
"support_email"
)

$bee_params = @(
Expand Down Expand Up @@ -542,7 +563,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 "acceptable_suggestions_enabled" -and $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 "secret_scanner_feedback" -and $param -ne "enable_default_branch" -and $param -ne "git.domain" -and $param -ne "review_scope" -and $param -ne "exclude_branches" -and $param -ne "include_source_branches" -and $param -ne "include_target_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") {
} elseif ($param -ne "acceptable_suggestions_enabled" -and $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 "secret_scanner_feedback" -and $param -ne "enable_default_branch" -and $param -ne "git.domain" -and $param -ne "review_scope" -and $param -ne "exclude_branches" -and $param -ne "include_source_branches" -and $param -ne "include_target_branches" -and $param -ne "suggestion_mode" -and $param -ne "locale" -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" -and $param -ne "support_email" -and $param -ne "post_as_request_changes") {
Ask-For-Param $param $false
}
}
Expand Down Expand Up @@ -571,6 +592,9 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
} elseif ($param -eq "linters_feedback") {
$validated_boolean = Validate-Boolean $props[$param]
$docker_cmd += " --$param=$validated_boolean"
} elseif ($param -eq "post_as_request_changes") {
$validated_boolean = Validate-Boolean $props[$param]
$docker_cmd += " --$param=$validated_boolean"
} elseif ($param -eq "secret_scanner_feedback") {
$validated_boolean = Validate-Boolean $props[$param]
$docker_cmd += " --$param=$validated_boolean"
Expand All @@ -589,6 +613,11 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
$docker_cmd += " --include_source_branches='$($props[$param])'"
} elseif ($param -eq "include_target_branches") {
$docker_cmd += " --include_target_branches='$($props[$param])'"
} elseif ($param -eq "suggestion_mode") {
$validated_suggestion_mode = Validate-Suggestion-Mode $props[$param]
$docker_cmd += " --suggestion_mode='$validated_suggestion_mode'"
} elseif ($param -eq "locale") {
$docker_cmd += " --locale='$($props[$param])'"
} elseif ($param -eq "exclude_files") {
$docker_cmd += " --exclude_files='$($props[$param])'"
} elseif ($param -eq "exclude_draft_pr") {
Expand Down Expand Up @@ -627,8 +656,9 @@ foreach ($param in $required_params + $bee_params + $optional_params) {
$crEventType = ValidateCrEventType $props[$param]
} elseif ($param -eq "posting_to_pr") {
$postingToPr = ValidatePostingToPr $props[$param]
}
else {
} elseif ($param -eq "support_email") {
$docker_cmd += " --support_email='$( $props[$param] )'"
} else {
$docker_cmd += " --$param=$($props[$param])"
}
}
Expand Down
30 changes: 29 additions & 1 deletion cra-scripts/bito-cra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ validate_boolean() {
fi
}

# Function to validate suggestion mode
validate_suggestion_mode() {
local suggestion_mode="$(echo "$1" | awk '{print tolower($0)}')"
if [ "$suggestion_mode" == "comprehensive" ]; then
echo "comprehensive"
else
echo "essential"
fi
}

# Function to validate a mode value i.e. cli or server
validate_mode() {
local mode_val="$1"
Expand Down Expand Up @@ -424,6 +434,9 @@ optional_params_cli=(
"exclude_branches"
"include_source_branches"
"include_target_branches"
"post_as_request_changes"
"suggestion_mode"
"locale"
"exclude_files"
"exclude_draft_pr"
"dependency_check"
Expand All @@ -443,6 +456,7 @@ optional_params_cli=(
"custom_rules.region_name"
"custom_rules.bucket_name"
"custom_rules.aes_key"
"support_email"
)

# Parameters that are required/optional in mode server
Expand All @@ -466,6 +480,9 @@ optional_params_server=(
"exclude_branches"
"include_source_branches"
"include_target_branches"
"post_as_request_changes"
"suggestion_mode"
"locale"
"exclude_files"
"exclude_draft_pr"
"dependency_check"
Expand All @@ -485,6 +502,7 @@ optional_params_server=(
"custom_rules.bucket_name"
"custom_rules.aes_key"
"output_path"
"support_email"
)

bee_params=(
Expand Down Expand Up @@ -550,7 +568,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" != "acceptable_suggestions_enabled" ] && [ "$param" != "dependency_check.snyk_auth_token" ] && [ "$param" != "env" ] && [ "$param" != "cli_path" ] && [ "$param" != "output_path" ] && [ "$param" != "static_analysis_tool" ] && [ "$param" != "linters_feedback" ] && [ "$param" != "secret_scanner_feedback" ] && [ "$param" != "enable_default_branch" ] && [ "$param" != "git.domain" ] && [ "$param" != "review_scope" ] && [ "$param" != "exclude_branches" ] && [ "$param" != "include_source_branches" ] && [ "$param" != "include_target_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
elif [ "$param" != "acceptable_suggestions_enabled" ] && [ "$param" != "dependency_check.snyk_auth_token" ] && [ "$param" != "env" ] && [ "$param" != "cli_path" ] && [ "$param" != "output_path" ] && [ "$param" != "static_analysis_tool" ] && [ "$param" != "linters_feedback" ] && [ "$param" != "secret_scanner_feedback" ] && [ "$param" != "enable_default_branch" ] && [ "$param" != "git.domain" ] && [ "$param" != "review_scope" ] && [ "$param" != "exclude_branches" ] && [ "$param" != "include_source_branches" ] && [ "$param" != "include_target_branches" ] && [ "$param" != "suggestion_mode" ] && [ "$param" != "locale" ] && [ "$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" ] && [ "$param" != "post_as_request_changes" ] && [ "$param" != "support_email" ]; then
ask_for_param "$param" "False"
fi
done
Expand Down Expand Up @@ -585,6 +603,9 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
elif [ "$param" == "linters_feedback" ]; then
props[$param]=$(validate_boolean "${props[$param]}")
docker_cmd+=" --linters_feedback=${props[$param]}"
elif [ "$param" == "post_as_request_changes" ]; then
props[$param]=$(validate_boolean "${props[$param]}")
docker_cmd+=" --post_as_request_changes=${props[$param]}"
elif [ "$param" == "secret_scanner_feedback" ]; then
props[$param]=$(validate_boolean "${props[$param]}")
docker_cmd+=" --secret_scanner_feedback=${props[$param]}"
Expand All @@ -603,6 +624,11 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
docker_cmd+=" --include_source_branches='${props[$param]}'"
elif [ "$param" == "include_target_branches" ]; then
docker_cmd+=" --include_target_branches='${props[$param]}'"
elif [ "$param" == "suggestion_mode" ]; then
props[$param]=$(validate_suggestion_mode "${props[$param]}")
docker_cmd+=" --suggestion_mode='${props[$param]}'"
elif [ "$param" == "locale" ]; then
docker_cmd+=" --locale='${props[$param]}'"
elif [ "$param" == "exclude_files" ]; then
docker_cmd+=" --exclude_files='${props[$param]}'"
elif [ "$param" == "exclude_draft_pr" ]; then
Expand Down Expand Up @@ -655,6 +681,8 @@ for param in "${required_params[@]}" "${bee_params[@]}" "${optional_params[@]}";
validate_cr_event_type "${props[$param]}"
elif [ "$param" == "posting_to_pr" ]; then
validate_posting_to_pr "${props[$param]}"
elif [ "$param" == "support_email" ]; then
docker_cmd+=" --support_email='${props[$param]}'"
else
docker_cmd+=" --$param=${props[$param]}"
fi
Expand Down