mirror of
https://github.com/ivuorinen/actions.git
synced 2026-02-18 06:49:00 +00:00
fix: convert bash-specific syntax to POSIX sh in php-tests
Replace bash-specific [[ ]] syntax with POSIX-compliant alternatives to adhere to CLAUDE.md standards (all scripts must be POSIX sh). Changes: - PHP version validation: Replace regex =~ with case statement matching X.Y and X.Y.Z patterns - Max retries validation: Replace regex =~ with case statement checking for non-digit characters - Email validation: Replace glob patterns with case statement matching *@*.* pattern - Username validation: Replace glob patterns with case statement detecting command injection characters (;, &&, |) All validation logic preserved, error messages unchanged.
This commit is contained in:
@@ -109,11 +109,19 @@ runs:
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Validate PHP version format
|
# Validate PHP version format
|
||||||
if [[ "$PHP_VERSION" != "latest" ]]; then
|
if [ "$PHP_VERSION" != "latest" ]; then
|
||||||
if ! [[ "$PHP_VERSION" =~ ^[0-9]+(\.[0-9]+)?(\.[0-9]+)?$ ]]; then
|
case "$PHP_VERSION" in
|
||||||
echo "::error::Invalid php-version format: '$PHP_VERSION'. Expected format: X.Y or X.Y.Z (e.g., 8.4, 8.3.0)"
|
[0-9]*.[0-9]*.[0-9]*)
|
||||||
exit 1
|
# X.Y.Z format (e.g., 8.3.0)
|
||||||
fi
|
;;
|
||||||
|
[0-9]*.[0-9]*)
|
||||||
|
# X.Y format (e.g., 8.4)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "::error::Invalid php-version format: '$PHP_VERSION'. Expected format: X.Y or X.Y.Z (e.g., 8.4, 8.3.0)"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate coverage driver
|
# Validate coverage driver
|
||||||
@@ -126,23 +134,35 @@ runs:
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Validate max retries
|
# Validate max retries (must be digits only)
|
||||||
if ! [[ "$MAX_RETRIES" =~ ^[0-9]+$ ]] || [ "$MAX_RETRIES" -le 0 ] || [ "$MAX_RETRIES" -gt 10 ]; then
|
case "$MAX_RETRIES" in
|
||||||
|
*[!0-9]*)
|
||||||
|
echo "::error::Invalid max-retries: '$MAX_RETRIES'. Must be a positive integer between 1 and 10"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# Validate max retries range
|
||||||
|
if [ "$MAX_RETRIES" -le 0 ] || [ "$MAX_RETRIES" -gt 10 ]; then
|
||||||
echo "::error::Invalid max-retries: '$MAX_RETRIES'. Must be a positive integer between 1 and 10"
|
echo "::error::Invalid max-retries: '$MAX_RETRIES'. Must be a positive integer between 1 and 10"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate email format
|
# Validate email format (must contain @ and .)
|
||||||
if [[ "$EMAIL" != *"@"* ]] || [[ "$EMAIL" != *"."* ]]; then
|
case "$EMAIL" in
|
||||||
echo "::error::Invalid email format: '$EMAIL'. Expected valid email address"
|
*@*.*) ;;
|
||||||
exit 1
|
*)
|
||||||
fi
|
echo "::error::Invalid email format: '$EMAIL'. Expected valid email address"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Validate username format
|
# Validate username format (reject command injection patterns)
|
||||||
if [[ "$USERNAME" == *";"* ]] || [[ "$USERNAME" == *"&&"* ]] || [[ "$USERNAME" == *"|"* ]]; then
|
case "$USERNAME" in
|
||||||
echo "::error::Invalid username: '$USERNAME'. Command injection patterns not allowed"
|
*";"*|*"&&"*|*"|"*)
|
||||||
exit 1
|
echo "::error::Invalid username: '$USERNAME'. Command injection patterns not allowed"
|
||||||
fi
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if [ ${#USERNAME} -gt 39 ]; then
|
if [ ${#USERNAME} -gt 39 ]; then
|
||||||
echo "::error::Username too long: ${#USERNAME} characters. GitHub usernames are max 39 characters"
|
echo "::error::Username too long: ${#USERNAME} characters. GitHub usernames are max 39 characters"
|
||||||
|
|||||||
Reference in New Issue
Block a user