fix: False positive NETW-2400 on OpenWrt

To save resources, BusyBox for OpenWrt is compiled without support for
character classes in `tr` command (FEATURE_TR_CLASSES). In that case `tr`
treats `[:alnum:]` like a group of single characters, so it misses all numbers
and most of letters.
This commit is contained in:
macie 2025-02-08 16:38:52 +01:00
parent b8f5b41b98
commit 61061471fe
No known key found for this signature in database
1 changed files with 2 additions and 1 deletions

View File

@ -69,7 +69,8 @@
LogText "Result: hostnamed is defined and not longer than 63 characters" LogText "Result: hostnamed is defined and not longer than 63 characters"
fi fi
# Test valid characters (normally a dot should not be in the name, but we can't be 100% sure we have short name) # Test valid characters (normally a dot should not be in the name, but we can't be 100% sure we have short name)
FIND=$(echo "${HOSTNAME}" | ${TRBINARY} -d '[:alnum:]\.\-') # (we are NOT using [:alnum:] to support BusyBox's tr on devices with limited resources)
FIND=$(echo "${HOSTNAME}" | ${TRBINARY} -d '[a-zA-Z0-9]\.\-')
if [ -z "${FIND}" ]; then if [ -z "${FIND}" ]; then
LogText "Result: good, no unexpected characters discovered in hostname" LogText "Result: good, no unexpected characters discovered in hostname"
if IsVerbose; then Display --indent 2 --text "- Hostname (allowed characters)" --result "${STATUS_OK}" --color GREEN; fi if IsVerbose; then Display --indent 2 --text "- Hostname (allowed characters)" --result "${STATUS_OK}" --color GREEN; fi