derrickaw commented on code in PR #41592:
URL: https://github.com/apache/beam/pull/41592#discussion_r4670585536
##########
.github/actions/test-arguments-action/action.yml:
##########
@@ -37,60 +37,74 @@ runs:
using: composite
steps:
- name: Check if test-type was provided
+ env:
+ INPUT_TEST_TYPE: ${{ inputs.test-type }}
shell: bash
- run: |
- if [ -z "${{ inputs.test-type }}" ]; then
+ run: |
+ if [ -z "${INPUT_TEST_TYPE}" ]; then
echo "Test type was not provided"
exit 1
fi
- name: Check if test-language was provided
+ env:
+ INPUT_TEST_LANGUAGE: ${{ inputs.test-language }}
shell: bash
- run: |
- if [ -z "${{ inputs.test-language }}" ]; then
+ run: |
+ if [ -z "${INPUT_TEST_LANGUAGE}" ]; then
echo "Test language was not provided"
exit 1
fi
- name: Set common arguments
id: common_arguments
shell: bash
run: |
- echo project="apache-beam-testing" >> $GITHUB_OUTPUT
- echo influx_db_name="beam_test_metrics" >> $GITHUB_OUTPUT
- echo influx_host="http://10.128.0.96:8086" >> $GITHUB_OUTPUT
+ echo project="apache-beam-testing" >> "$GITHUB_OUTPUT"
+ echo influx_db_name="beam_test_metrics" >> "$GITHUB_OUTPUT"
+ echo influx_host="http://10.128.0.96:8086" >> "$GITHUB_OUTPUT"
- name: Get default ${{ inputs.test-language }} test arguments
id: default_arguments
+ env:
+ INPUT_TEST_LANGUAGE: ${{ inputs.test-language }}
+ COMMON_PROJECT: ${{ steps.common_arguments.outputs.project }}
+ COMMON_INFLUX_DB: ${{ steps.common_arguments.outputs.influx_db_name }}
+ COMMON_INFLUX_HOST: ${{ steps.common_arguments.outputs.influx_host }}
shell: bash
run: |
DEFAULT_ARGUMENTS=""
- if ${{ inputs.test-language == 'java' }}; then
- DEFAULT_ARGUMENTS=$(echo "
- --project=${{ steps.common_arguments.outputs.project }}
- --influxDatabase=${{ steps.common_arguments.outputs.influx_db_name
}}
- --influxHost=${{ steps.common_arguments.outputs.influx_host }}
- ")
- elif ${{ inputs.test-language == 'python' || inputs.test-language ==
'go' }}; then
- DEFAULT_ARGUMENTS=$(echo "
- --project=${{ steps.common_arguments.outputs.project }}
- --influx_db_name=${{ steps.common_arguments.outputs.influx_db_name
}}
- --influx_hostname=${{ steps.common_arguments.outputs.influx_host }}
- ")
+ if [[ "${INPUT_TEST_LANGUAGE}" == "java" ]]; then
+ DEFAULT_ARGUMENTS="--project=${COMMON_PROJECT}
--influxDatabase=${COMMON_INFLUX_DB} --influxHost=${COMMON_INFLUX_HOST}"
+ elif [[ "${INPUT_TEST_LANGUAGE}" == "python" ||
"${INPUT_TEST_LANGUAGE}" == "go" ]]; then
+ DEFAULT_ARGUMENTS="--project=${COMMON_PROJECT}
--influx_db_name=${COMMON_INFLUX_DB} --influx_hostname=${COMMON_INFLUX_HOST}"
fi
- echo arguments=$DEFAULT_ARGUMENTS >> $GITHUB_OUTPUT
+ echo "arguments=${DEFAULT_ARGUMENTS}" >> "$GITHUB_OUTPUT"
- name: Group arguments
+ env:
+ INPUT_ARGUMENT_FILE_PATHS: ${{ inputs.argument-file-paths }}
+ DEFAULT_ARGUMENTS: ${{ steps.default_arguments.outputs.arguments }}
+ INPUT_ARGUMENTS: ${{ inputs.arguments }}
+ INPUT_TEST_TYPE: ${{ inputs.test-type }}
+ JOB_ID: ${{ github.job }}
shell: bash
run: |
- PATHS=($(echo "${{ inputs.argument-file-paths }}" | tr '\n' ' '))
+ if [[ ! "${JOB_ID}" =~ ^[A-Za-z0-9_-]+$ ]]; then
+ echo "::error::Invalid job identifier: ${JOB_ID}"
+ exit 1
+ fi
+ read -r -a PATHS <<< "$(printf '%s' "${INPUT_ARGUMENT_FILE_PATHS}" |
tr '\n' ' ')"
for index in "${!PATHS[@]}"; do
- CONFIG=$(grep -v "^#.*" ${PATHS[index]})
- ARGUMENTS=$(echo "${{ steps.default_arguments.outputs.arguments }}
${{ inputs.arguments }} $CONFIG" | tr '\n' ' ')
+ CONFIG=$(grep -v "^#.*" "${PATHS[index]}" || true)
+ ARGUMENTS=$(printf '%s %s %s' "${DEFAULT_ARGUMENTS}"
"${INPUT_ARGUMENTS}" "${CONFIG}" | tr '\n\r' ' ' | tr -s ' ')
Review Comment:
Good catch — audited all 44 caller workflows and added literal substitution
for `$(date '+%m%d%H%M%S' --utc)` plus single-pass double-quote backslash
unescaping (`\"` / `\\"`) on `INPUT_ARGUMENTS` so all existing callers remain
backward-compatible without evaluating arbitrary shell command substitutions.
##########
.github/actions/test-arguments-action/action.yml:
##########
@@ -37,60 +37,74 @@ runs:
using: composite
steps:
- name: Check if test-type was provided
+ env:
+ INPUT_TEST_TYPE: ${{ inputs.test-type }}
shell: bash
- run: |
- if [ -z "${{ inputs.test-type }}" ]; then
+ run: |
+ if [ -z "${INPUT_TEST_TYPE}" ]; then
echo "Test type was not provided"
exit 1
fi
- name: Check if test-language was provided
+ env:
+ INPUT_TEST_LANGUAGE: ${{ inputs.test-language }}
shell: bash
- run: |
- if [ -z "${{ inputs.test-language }}" ]; then
+ run: |
+ if [ -z "${INPUT_TEST_LANGUAGE}" ]; then
echo "Test language was not provided"
exit 1
fi
- name: Set common arguments
id: common_arguments
shell: bash
run: |
- echo project="apache-beam-testing" >> $GITHUB_OUTPUT
- echo influx_db_name="beam_test_metrics" >> $GITHUB_OUTPUT
- echo influx_host="http://10.128.0.96:8086" >> $GITHUB_OUTPUT
+ echo project="apache-beam-testing" >> "$GITHUB_OUTPUT"
+ echo influx_db_name="beam_test_metrics" >> "$GITHUB_OUTPUT"
+ echo influx_host="http://10.128.0.96:8086" >> "$GITHUB_OUTPUT"
- name: Get default ${{ inputs.test-language }} test arguments
id: default_arguments
+ env:
+ INPUT_TEST_LANGUAGE: ${{ inputs.test-language }}
+ COMMON_PROJECT: ${{ steps.common_arguments.outputs.project }}
+ COMMON_INFLUX_DB: ${{ steps.common_arguments.outputs.influx_db_name }}
+ COMMON_INFLUX_HOST: ${{ steps.common_arguments.outputs.influx_host }}
shell: bash
run: |
DEFAULT_ARGUMENTS=""
- if ${{ inputs.test-language == 'java' }}; then
- DEFAULT_ARGUMENTS=$(echo "
- --project=${{ steps.common_arguments.outputs.project }}
- --influxDatabase=${{ steps.common_arguments.outputs.influx_db_name
}}
- --influxHost=${{ steps.common_arguments.outputs.influx_host }}
- ")
- elif ${{ inputs.test-language == 'python' || inputs.test-language ==
'go' }}; then
- DEFAULT_ARGUMENTS=$(echo "
- --project=${{ steps.common_arguments.outputs.project }}
- --influx_db_name=${{ steps.common_arguments.outputs.influx_db_name
}}
- --influx_hostname=${{ steps.common_arguments.outputs.influx_host }}
- ")
+ if [[ "${INPUT_TEST_LANGUAGE}" == "java" ]]; then
+ DEFAULT_ARGUMENTS="--project=${COMMON_PROJECT}
--influxDatabase=${COMMON_INFLUX_DB} --influxHost=${COMMON_INFLUX_HOST}"
+ elif [[ "${INPUT_TEST_LANGUAGE}" == "python" ||
"${INPUT_TEST_LANGUAGE}" == "go" ]]; then
+ DEFAULT_ARGUMENTS="--project=${COMMON_PROJECT}
--influx_db_name=${COMMON_INFLUX_DB} --influx_hostname=${COMMON_INFLUX_HOST}"
fi
- echo arguments=$DEFAULT_ARGUMENTS >> $GITHUB_OUTPUT
+ echo "arguments=${DEFAULT_ARGUMENTS}" >> "$GITHUB_OUTPUT"
- name: Group arguments
+ env:
+ INPUT_ARGUMENT_FILE_PATHS: ${{ inputs.argument-file-paths }}
+ DEFAULT_ARGUMENTS: ${{ steps.default_arguments.outputs.arguments }}
+ INPUT_ARGUMENTS: ${{ inputs.arguments }}
+ INPUT_TEST_TYPE: ${{ inputs.test-type }}
+ JOB_ID: ${{ github.job }}
shell: bash
run: |
- PATHS=($(echo "${{ inputs.argument-file-paths }}" | tr '\n' ' '))
+ if [[ ! "${JOB_ID}" =~ ^[A-Za-z0-9_-]+$ ]]; then
+ echo "::error::Invalid job identifier: ${JOB_ID}"
+ exit 1
+ fi
+ read -r -a PATHS <<< "$(printf '%s' "${INPUT_ARGUMENT_FILE_PATHS}" |
tr '\n' ' ')"
for index in "${!PATHS[@]}"; do
- CONFIG=$(grep -v "^#.*" ${PATHS[index]})
- ARGUMENTS=$(echo "${{ steps.default_arguments.outputs.arguments }}
${{ inputs.arguments }} $CONFIG" | tr '\n' ' ')
+ CONFIG=$(grep -v "^#.*" "${PATHS[index]}" || true)
+ ARGUMENTS=$(printf '%s %s %s' "${DEFAULT_ARGUMENTS}"
"${INPUT_ARGUMENTS}" "${CONFIG}" | tr '\n\r' ' ' | tr -s ' ')
Review Comment:
Good catch — audited all 44 caller workflows and added literal substitution
for `$(date '+%m%d%H%M%S' --utc)` plus single-pass double-quote backslash
unescaping (`\"` / `\\"`) on `INPUT_ARGUMENTS` so all existing callers remain
backward-compatible without evaluating arbitrary shell command substitutions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]