From 5f4be8677c0f92f12dd6c68159718fa5a43fb6e9 Mon Sep 17 00:00:00 2001 From: Salvo Rapisarda Date: Tue, 11 Oct 2022 15:17:33 +0200 Subject: [PATCH 1/2] add serviceName validation --- setup/Setup.php | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/setup/Setup.php b/setup/Setup.php index 20956f8..9fec4dd 100644 --- a/setup/Setup.php +++ b/setup/Setup.php @@ -103,12 +103,21 @@ public static function setup(Event $event) { } if (!isset($config['serviceName'])) { - echo "Please insert name for service endpoint (" . - $colors->getColoredString($_serviceName, "green") . "): "; - $config['serviceName'] = str_replace("'", "\'", readline()); - if ($config['serviceName'] == null || $config['serviceName'] == "") { - $config['serviceName'] = $_serviceName; - } + do { + echo "Please insert name for service endpoint (" . + $colors->getColoredString($_serviceName, "green") . "): "; + $serviceName = readline(); + if ($serviceName == null || $serviceName == "") { + $serviceName = $_serviceName; + break; + } + $is_valid = preg_match("/^\w{1}[-\w]*$/i", $serviceName); + if (!$is_valid) + echo "Value '{$serviceName}' not allowed\n"; + + } while(!$is_valid); + $config['serviceName'] = $serviceName; + } if (!isset($config['entityID'])) { @@ -1310,12 +1319,20 @@ public static function remove() { if (!empty($config['serviceName'])) { $serviceName = $config['serviceName']; } else { - echo "Please insert name for service endpoint (" . - $colors->getColoredString($_serviceName, "green") . "): "; - $serviceName = readline(); - if ($serviceName == null || $serviceName == "") { - $serviceName = $_serviceName; - } + do { + echo "Please insert name for service endpoint (" . + $colors->getColoredString($_serviceName, "green") . "): "; + $serviceName = readline(); + if ($serviceName == null || $serviceName == "") { + $serviceName = $_serviceName; + break; + } + $is_valid = preg_match("/^\w{1}[-\w]*$/i", $serviceName); + if (!$is_valid) + echo "Value '{$serviceName}' not allowed\n"; + + } while(!$is_valid); + } if (file_exists("{$installDir}/vendor/simplesamlphp/simplesamlphp/log/simplesamlphp.log")) { From f7883aa426ef423f1aafefbbd022c9bf8fee00bb Mon Sep 17 00:00:00 2001 From: Salvo Rapisarda Date: Tue, 11 Oct 2022 16:08:17 +0200 Subject: [PATCH 2/2] update version to 3.10.3 --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4e47010..744b677 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,9 @@ { "config": { - "version": "3.10.2" + "version": "3.10.3", + "allow-plugins": { + "simplesamlphp/composer-module-installer": true + } }, "repositories": { "spid-sp-access-button": {