diff --git a/core/addAndCheckGitRepository.sh b/core/addAndCheckGitRepository.sh index 2368f02..f9bb8b2 100755 --- a/core/addAndCheckGitRepository.sh +++ b/core/addAndCheckGitRepository.sh @@ -99,9 +99,9 @@ function addAndCheckGitRepository() { } # sanitizes all parameters -base.set FOLDER "${1}" '^[-a-zA-Z0-9/:@._]*/$' || exit 1 -base.set RIGHTS "${2}" '^(readonly|writable)$' || exit 1 -base.set SUGGESTED_REPOSITORY "${3}" '^([-a-zA-Z0-9/:@._]*)?$' || exit 1 +base.set FOLDER "${1}" '^[-a-zA-Z0-9/:@._]*/$' +base.set RIGHTS "${2}" '^(readonly|writable)$' +base.set SUGGESTED_REPOSITORY "${3}" '^[-a-zA-Z0-9/:@._]*$' optional addAndCheckGitRepository \ "${FOLDER:?"Missing FOLDER"}" \ "${RIGHTS:?"Missing RIGHTS"}" \ diff --git a/core/addNormalUser.sh b/core/addNormalUser.sh index e625cbf..6dd89e2 100755 --- a/core/addNormalUser.sh +++ b/core/addNormalUser.sh @@ -37,7 +37,7 @@ function addNormalUser() { } # sanitizes all parameters -base.set USER "${1}" '^[a-z][-a-z0-9_.]*$' || exit 1 +base.set USER "${1}" '^[a-z][-a-z0-9_.]*$' addNormalUser "${USER:?"Missing USER"}" \ && exit 0 diff --git a/core/addToCrontabEveryHour.sh b/core/addToCrontabEveryHour.sh index 567a2b2..769e864 100755 --- a/core/addToCrontabEveryHour.sh +++ b/core/addToCrontabEveryHour.sh @@ -44,8 +44,8 @@ function addToCrontabEveryHour() { } # sanitizes all parameters -base.set COMMAND "${1}" '^[-a-zA-Z0-9/:@._]*$' || exit 1 -base.set MINUTE_VALUE "${2}" '^[-a-zA-Z0-9/:@._]*$' || exit 1 +base.set COMMAND "${1}" '^[-a-zA-Z0-9/:@._]*$' +base.set MINUTE_VALUE "${2}" '^[-a-zA-Z0-9/:@._]*$' addToCrontabEveryHour \ "${COMMAND:?"Missing COMMAND"}" \ "${MINUTE_VALUE:?"Missing MINUTE_VALUE"}" \ diff --git a/core/base.module.sh b/core/base.module.sh index 1f3e5ae..593bce9 100755 --- a/core/base.module.sh +++ b/core/base.module.sh @@ -290,7 +290,7 @@ function base.loadModule() { function base.log() { local _LOGLEVEL _LOGLEVEL_UPPER - base.set _LOGLEVEL "${1}" '^(error|warn|info|debug)$' || exit 1 + base.set _LOGLEVEL "${1}" '^(error|warn|info|debug)$' _LOGLEVEL_UPPER="${_LOGLEVEL:?"base.log(): Missing valid first parameter LOGLEVEL"}" _LOGLEVEL_UPPER="${_LOGLEVEL_UPPER^^}" readonly _LOGLEVEL_UPPER diff --git a/core/defineAuthorizedKeysOfUser.sh b/core/defineAuthorizedKeysOfUser.sh index d9e4582..03f5553 100755 --- a/core/defineAuthorizedKeysOfUser.sh +++ b/core/defineAuthorizedKeysOfUser.sh @@ -136,8 +136,8 @@ function defineAuthorizedKeysOfUser() { } # sanitizes all parameters -base.set DEFINITIONS "${1}" '^[-a-zA-Z0-9/:@._]*$' || exit 1 -base.set USER "${2}" '^[-a-zA-Z0-9/:@._]*$' || exit 1 +base.set DEFINITIONS "${1}" '^[-a-zA-Z0-9/:@._]*$' +base.set USER "${2}" '^[-a-zA-Z0-9/:@._]*$' defineAuthorizedKeysOfUser \ "${DEFINITIONS:?"Missing DEFINITIONS"}" \ "${USER:?"Missing USER"}" \ diff --git a/core/ensureUsageOfDefinitions.sh b/core/ensureUsageOfDefinitions.sh index 2d7e512..ac00385 100755 --- a/core/ensureUsageOfDefinitions.sh +++ b/core/ensureUsageOfDefinitions.sh @@ -218,8 +218,8 @@ function ensureUsageOfDefinitions() { } # sanitizes all parameters -base.set DEFINITIONS "${1}" '^[-a-zA-Z0-9/:@._]*$' || exit 1 -base.set CURRENT_FULLFILE "${2}" '^[-a-zA-Z0-9/:@._]*$' || exit 1 +base.set DEFINITIONS "${1}" '^[-a-zA-Z0-9/:@._]*$' +base.set CURRENT_FULLFILE "${2}" '^[-a-zA-Z0-9/:@._]*$' ensureUsageOfDefinitions \ "${DEFINITIONS:?"Missing DEFINITIONS"}" \ "${CURRENT_FULLFILE:?"Missing CURRENT_FULLFILE"}" \ diff --git a/script/host/zfs/composition-sync/setupSyncHost.sh b/script/host/zfs/composition-sync/setupSyncHost.sh index 1c04622..f694238 100755 --- a/script/host/zfs/composition-sync/setupSyncHost.sh +++ b/script/host/zfs/composition-sync/setupSyncHost.sh @@ -50,7 +50,7 @@ function setup() { -base.set COMPOSITION "${1}" '^([a-zA-Z0-9][a-zA-Z0-9_-]*)?$' || exit 1 +base.set COMPOSITION "${1}" '^[a-zA-Z0-9][a-zA-Z0-9_-]*$' optional setup "${COMPOSITION}" diff --git a/script/host/zfs/composition-sync/sync-send.sh b/script/host/zfs/composition-sync/sync-send.sh index 09bfe8b..9ec690a 100755 --- a/script/host/zfs/composition-sync/sync-send.sh +++ b/script/host/zfs/composition-sync/sync-send.sh @@ -130,11 +130,11 @@ function send() { # Parameter 3: Only alphanumeric characters allowed and [.-] if not leading (due to: -oProxyCommand=...). # Parameter 4: Only alphanumeric characters allowed and [._:-] if not leading (due to: -oProxyCommand=...), but can be empty. # Parameter 5: Only alphanumeric characters allowed and [._:-] if not leading (due to: -oProxyCommand=...), but can be empty. -base.set RECEIVERHOST "${1}" '^[a-zA-Z0-9][a-zA-Z0-9._-]*$' || exit 1 -base.set ZFS_BRANCH "${2}" '^[a-zA-Z][a-zA-Z0-9/_-]*[a-zA-Z0-9]$' || exit 1 -base.set COMPOSITION "${3}" '^[a-zA-Z0-9][a-zA-Z0-9.-]*$' || exit 1 -base.set RECEIVERS_SNAPSHOT "${4}" '(^[a-zA-Z0-9][a-zA-Z0-9._:-]*$)?' || exit 1 -base.set RESUME_TOKEN "${5}" '(^[a-zA-Z0-9][a-zA-Z0-9._:-]*$)?' || exit 1 +base.set RECEIVERHOST "${1}" '^[a-zA-Z0-9][a-zA-Z0-9._-]*$' +base.set ZFS_BRANCH "${2}" '^[a-zA-Z][a-zA-Z0-9/_-]*[a-zA-Z0-9]$' +base.set COMPOSITION "${3}" '^[a-zA-Z0-9][a-zA-Z0-9.-]*$' +base.set RECEIVERS_SNAPSHOT "${4}" '^[a-zA-Z0-9][a-zA-Z0-9._:-]*$' optional +base.set RESUME_TOKEN "${5}" '^[a-zA-Z0-9][a-zA-Z0-9._:-]*$' optional # Resume mode if [ "${RECEIVERS_SNAPSHOT}" == "RESUME" ]; then diff --git a/script/host/zfs/composition-sync/sync.sh b/script/host/zfs/composition-sync/sync.sh index c38a7ef..a9c31c8 100755 --- a/script/host/zfs/composition-sync/sync.sh +++ b/script/host/zfs/composition-sync/sync.sh @@ -223,8 +223,8 @@ function usage() { -# Parameter 2: is optional '()?' and only a subset of alphanumeric characters are allowed and [_-] if not leading (due to: -oProxyCommand=...). -base.set COMPOSITION "${2}" '^([a-zA-Z0-9][a-zA-Z0-9_-]*)?$' +# Parameter 2: only a subset of alphanumeric characters are allowed and [_-] if not leading (due to: -oProxyCommand=...). +base.set COMPOSITION "${2}" '^[a-zA-Z0-9][a-zA-Z0-9_-]*$' optional case "${1}" in --onceAll) diff --git a/script/host/zfs/snapshot.sh b/script/host/zfs/snapshot.sh index 9c6156d..33d4848 100755 --- a/script/host/zfs/snapshot.sh +++ b/script/host/zfs/snapshot.sh @@ -136,7 +136,7 @@ function snapshot() { # Parameter 1: Only one of these values (MINUTELY, HOURLY, DAILY, MONTHLY, NONE) are allowed, or empty. -base.set MODE "${1}" '^(MINUTELY|HOURLY|DAILY|MONTHLY|NONE)?$' || exit 1 +base.set MODE "${1}" '^(MINUTELY|HOURLY|DAILY|MONTHLY|NONE)$' optional snapshot "${MODE}" cleanup diff --git a/script/monitor/generic/CIS_OWN_DOMAIN_CHECK.sh b/script/monitor/generic/CIS_OWN_DOMAIN_CHECK.sh index 59a7ba3..ffd2caf 100755 --- a/script/monitor/generic/CIS_OWN_DOMAIN_CHECK.sh +++ b/script/monitor/generic/CIS_OWN_DOMAIN_CHECK.sh @@ -29,6 +29,6 @@ function testDomain() { } # FQDN of server: e.g. host.example.net[:port] -base.set REMOTE_HOST "${1}" '^(([a-zA-Z0-9][a-zA-Z0-9.-]*)+(:[0-9]+)?)?$' +base.set REMOTE_HOST "${1}" '^([a-zA-Z0-9][a-zA-Z0-9.-]*)+(:[0-9]+)?$' optional testDomain "${REMOTE_HOST}" && exit 0 exit 1 diff --git a/script/monitor/generic/COMPOSITION_SYNC_CHECK.sh b/script/monitor/generic/COMPOSITION_SYNC_CHECK.sh index 01a8a58..17b91a9 100755 --- a/script/monitor/generic/COMPOSITION_SYNC_CHECK.sh +++ b/script/monitor/generic/COMPOSITION_SYNC_CHECK.sh @@ -75,7 +75,7 @@ function checkSync() { } base.set REMOTE_HOST "${1:?"FQDN of server missing: e.g. host.example.net[:port]"}" '^([a-zA-Z0-9][a-zA-Z0-9.-]*)+(:[0-9]+)?$' -base.set GIVEN_REMOTE_HOSTNAME_FQDN "${2}" '^([a-zA-Z0-9][a-zA-Z0-9.-]*)?$' +base.set GIVEN_REMOTE_HOSTNAME_FQDN "${2}" '^[a-zA-Z0-9][a-zA-Z0-9.-]*$' optional base.set MODE "${3:-"normal"}" '^(debug|normal)$' RESULTS=$(checkSync "${REMOTE_HOST}" "${MODE}" "${GIVEN_REMOTE_HOSTNAME_FQDN}") diff --git a/script/monitor/generic/ZFS_SYNC_CHECK.sh b/script/monitor/generic/ZFS_SYNC_CHECK.sh index f8649a0..d75a2a3 100755 --- a/script/monitor/generic/ZFS_SYNC_CHECK.sh +++ b/script/monitor/generic/ZFS_SYNC_CHECK.sh @@ -75,7 +75,7 @@ function checkSync() { } base.set REMOTE_HOST "${1:?"FQDN of server missing: e.g. host.example.net[:port]"}" '^([a-zA-Z0-9][a-zA-Z0-9.-]*)+(:[0-9]+)?$' -base.set GIVEN_REMOTE_HOSTNAME_FQDN "${2}" '^([a-zA-Z0-9][a-zA-Z0-9.-]*)?$' +base.set GIVEN_REMOTE_HOSTNAME_FQDN "${2}" '^[a-zA-Z0-9][a-zA-Z0-9.-]*$' optional base.set MODE "${3:-"normal"}" '^(debug|normal)$' RESULTS=$(checkSync "${REMOTE_HOST}" "${MODE}" "${GIVEN_REMOTE_HOSTNAME_FQDN}") diff --git a/setupCoreOntoThisHost.sh b/setupCoreOntoThisHost.sh index 738f691..e3f9322 100755 --- a/setupCoreOntoThisHost.sh +++ b/setupCoreOntoThisHost.sh @@ -208,8 +208,8 @@ function setup() { -# Parameter 1: is optional '()?' and only alphanumeric characters are allowed and [.-] if not leading (due to: -oProxyCommand=...). -base.set DOMAIN "${1}" '^([a-zA-Z0-9][a-zA-Z0-9.-]*)?$' || exit 1 +# Parameter 1: only alphanumeric characters are allowed and [.-] if not leading (due to: -oProxyCommand=...). +base.set DOMAIN "${1}" '^[a-zA-Z0-9][a-zA-Z0-9.-]*$' optional setup "${DOMAIN}" \ && exit 0 diff --git a/updateRepositories.sh b/updateRepositories.sh index d8fdd37..29bf00f 100755 --- a/updateRepositories.sh +++ b/updateRepositories.sh @@ -73,7 +73,7 @@ function update_repositories() { # Parameter 1: Only one of these values are allowed, or empty (--core, --definitions, --repair, --scripts, --states, --test)? -base.set MODE "${1}" '^(--core|--definitions|--repair|--scripts|--states|--test)?$' || exit 1 +base.set MODE "${1}" '^(--core|--definitions|--repair|--scripts|--states|--test)$' optional update_repositories "${MODE}" \ && exit 0