Skip to content

Commit 4c5c635

Browse files
Merge pull request #284 from Checkmarx/additional-params-fix
Addition of New Parameter Flags
2 parents 2c828f1 + 1445b54 commit 4c5c635

File tree

2 files changed

+70
-7
lines changed

2 files changed

+70
-7
lines changed

action.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,26 @@ inputs:
2626
required: false
2727
default: ${{ github.token }}
2828
description: 'GitHub API Token'
29+
global_params:
30+
required: false
31+
default: ''
32+
description: 'Global parameters applied to all cx commands'
33+
scan_params:
34+
required: false
35+
default: ''
36+
description: 'Additional parameters for cx scan command only'
37+
utils_params:
38+
required: false
39+
default: ''
40+
description: 'Additional parameters for cx utils pr command only'
41+
results_params:
42+
required: false
43+
default: ''
44+
description: 'Additional parameters for cx results show command only'
2945
additional_params:
3046
required: false
3147
default: ''
32-
description: 'Additional parameters for AST scan'
48+
description: '[DEPRECATED] Use scan_params instead. Additional parameters for AST scan'
3349
repo_name:
3450
required: false
3551
default: ${{ github.event.repository.name }}
@@ -62,6 +78,10 @@ runs:
6278
- ${{ inputs.github_token }}
6379
- ${{ inputs.project_name }}
6480
- ${{ inputs.additional_params }}
81+
- ${{ inputs.global_params }}
82+
- ${{ inputs.scan_params }}
83+
- ${{ inputs.utils_params }}
84+
- ${{ inputs.results_params }}
6585
- ${{ inputs.repo_name }}
6686
- ${{ inputs.namespace }}
6787
- ${{ inputs.pr_number }}
@@ -79,6 +99,10 @@ runs:
7999
BRANCH: ${{ inputs.branch }}
80100
PROJECT_NAME: ${{ inputs.project_name }}
81101
ADDITIONAL_PARAMS: ${{ inputs.additional_params }}
102+
GLOBAL_PARAMS: ${{ inputs.global_params }}
103+
SCAN_PARAMS: ${{ inputs.scan_params }}
104+
UTILS_PARAMS: ${{ inputs.utils_params }}
105+
RESULTS_PARAMS: ${{ inputs.results_params }}
82106
REPO_NAME: ${{ inputs.repo_name }}
83107
NAMESPACE: ${{ inputs.namespace }}
84108
PR_NUMBER: ${{ inputs.pr_number }}

entrypoint.sh

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,46 @@ if [[ -n "$REGISTRIES" ]]; then
4242
else
4343
echo "⚠️ No REGISTRIES specified, skipping auth.json creation."
4444
fi
45-
# ------------------------------------------------------
4645

47-
# Parse additional params into array
48-
eval "arr=(${ADDITIONAL_PARAMS})"
49-
/app/bin/cx scan create --project-name "${PROJECT_NAME}" -s "${SOURCE_DIR}" --branch "${BRANCH#refs/heads/}" --scan-info-format json --agent "Github Action" "${arr[@]}" | tee -i $output_file
46+
# Parse global params (applied to all commands)
47+
if [ -n "${GLOBAL_PARAMS}" ]; then
48+
eval "global_arr=(${GLOBAL_PARAMS})"
49+
else
50+
global_arr=()
51+
fi
52+
53+
# Parse scan-specific params
54+
if [ -n "${SCAN_PARAMS}" ]; then
55+
eval "scan_arr=(${SCAN_PARAMS})"
56+
else
57+
scan_arr=()
58+
fi
59+
60+
# Parse utils-specific params
61+
if [ -n "${UTILS_PARAMS}" ]; then
62+
eval "utils_arr=(${UTILS_PARAMS})"
63+
else
64+
utils_arr=()
65+
fi
66+
67+
# Parse results-specific params
68+
if [ -n "${RESULTS_PARAMS}" ]; then
69+
eval "results_arr=(${RESULTS_PARAMS})"
70+
else
71+
results_arr=()
72+
fi
73+
74+
# Backward compatibility: Support ADDITIONAL_PARAMS
75+
if [ -n "${ADDITIONAL_PARAMS}" ] && [ -z "${SCAN_PARAMS}" ]; then
76+
echo "⚠️ ADDITIONAL_PARAMS is deprecated. Please use SCAN_PARAMS instead."
77+
eval "scan_arr=(${ADDITIONAL_PARAMS})"
78+
fi
79+
80+
# Combine global + scan-specific params
81+
combined_scan_params=("${global_arr[@]}" "${scan_arr[@]}")
82+
83+
84+
/app/bin/cx scan create --project-name "${PROJECT_NAME}" -s "${SOURCE_DIR}" --branch "${BRANCH#refs/heads/}" --scan-info-format json --agent "Github Action" "${combined_scan_params[@]}" | tee -i $output_file
5085
exitCode=${PIPESTATUS[0]}
5186

5287
scanId=(`grep -E '"(ID)":"((\\"|[^"])*)"' $output_file | cut -d',' -f1 | cut -d':' -f2 | tr -d '"'`)
@@ -55,14 +90,18 @@ echo "cxcli=$(cat $output_file | tr -d '\r\n')" >> $GITHUB_OUTPUT
5590

5691
if [ -n "$scanId" ] && [ -n "${PR_NUMBER}" ]; then
5792
echo "Creating PR decoration for scan ID:" $scanId
58-
/app/bin/cx utils pr github --scan-id "${scanId}" --namespace "${NAMESPACE}" --repo-name "${REPO_NAME}" --pr-number "${PR_NUMBER}" --token "${GITHUB_TOKEN}"
93+
# Combine global + utils-specific params
94+
combined_utils_params=("${global_arr[@]}" "${utils_arr[@]}")
95+
/app/bin/cx utils pr github --scan-id "${scanId}" --namespace "${NAMESPACE}" --repo-name "${REPO_NAME}" --pr-number "${PR_NUMBER}" --token "${GITHUB_TOKEN}" "${combined_utils_params[@]}"
5996
else
6097
echo "PR decoration not created."
6198
fi
6299

63100

64101
if [ -n "$scanId" ]; then
65-
/app/bin/cx results show --scan-id "${scanId}" --report-format markdown
102+
# Combine global + results-specific params
103+
combined_results_params=("${global_arr[@]}" "${results_arr[@]}")
104+
/app/bin/cx results show --scan-id "${scanId}" --report-format markdown "${combined_results_params[@]}"
66105
cat ./cx_result.md >$GITHUB_STEP_SUMMARY
67106
rm ./cx_result.md
68107
echo "cxScanID=$scanId" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)