Skip to content
Open
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
20 changes: 16 additions & 4 deletions .github/workflows/checkVersions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ on:
type: string
required: false
default: '.'
currentStreamVersionProperty:
description: Maven property name to use for determining the stream version in commit messages
type: string
required: false
default: 'releaseNumberSDK'

permissions: {} # all none

Expand Down Expand Up @@ -89,11 +94,18 @@ jobs:
if [[ $(git diff --name-only --cached) != '' ]]; then
# Relevant files were staged, i.e. some version were changed

# Read 'releaseNumberSDK' property as stream version
# Validate property name to prevent injection
propertyName="${{ inputs.currentStreamVersionProperty }}"
if [[ ! "$propertyName" =~ ^[a-zA-Z0-9._-]+$ ]]; then
echo "::error::Invalid property name: $propertyName. Must contain only alphanumeric characters, dots, hyphens, and underscores."
exit 1
fi
Comment on lines +97 to +102
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is necessary as this job doesn't have any permissions:

and with extra-setup-command we have another argument that is also executed as it is.
So this extra check does not really buy us extra safety and therefore I suggest to keep it simple and remove it.


# Read property as stream version
pushd ${{ inputs.working-directory }}
mvn help:evaluate -Dexpression=releaseNumberSDK ${{ inputs.extra-maven-args }} --quiet '-Doutput=releaseNumberSDK-value.txt'
streamVersion=$(<releaseNumberSDK-value.txt)
rm -f releaseNumberSDK-value.txt
mvn help:evaluate -Dexpression="$propertyName" ${{ inputs.extra-maven-args }} --quiet '-Doutput=currentStreamVersion-value.txt'
streamVersion=$(<currentStreamVersion-value.txt)
rm -f currentStreamVersion-value.txt
popd

git config --global user.email '${{ inputs.botMail }}'
Expand Down