From 6e2facbfc0c991b5a9c5a7bebb5713dff8cd69b3 Mon Sep 17 00:00:00 2001 From: Axel Hahn <ax2002@gmx.net> Date: Sun, 17 Mar 2024 23:53:54 +0100 Subject: [PATCH] insert usage of ini.class.sh --- includes/dbdetect.class.sh | 2 +- includes/dbdetect_validate_profile.ini | 52 ++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 includes/dbdetect_validate_profile.ini diff --git a/includes/dbdetect.class.sh b/includes/dbdetect.class.sh index 03a67e9..a7327f1 100644 --- a/includes/dbdetect.class.sh +++ b/includes/dbdetect.class.sh @@ -80,7 +80,7 @@ function dbdetect.validate(){ local _config="${1:-$DBD_INIFILE}" # show errors in profile ini files - ini.validate "$_config" "$( dirname "$0")/includes/dbdetect_validate_profile_ini.sh" 0 && dbdetect._wd "OK: Validation of '$_config' successful" + ini.validate "$_config" "$( dirname "$0")/includes/dbdetect_validate_profile.ini" 1 && dbdetect._wd "OK: Validation of '$_config' was successful" } # check if the requirements for a database match diff --git a/includes/dbdetect_validate_profile.ini b/includes/dbdetect_validate_profile.ini new file mode 100644 index 0000000..b438680 --- /dev/null +++ b/includes/dbdetect_validate_profile.ini @@ -0,0 +1,52 @@ +# ---------------------------------------------------------------------- +# +# VALIDATE PROFILE INI +# +# ---------------------------------------------------------------------- + +# IDEA +[style] +section = "^[a-zA-Z0-9_]*$" +key = "^[a-zA-Z0-9_\-]*$" + +# ---------------------------------------------------------------------- +# section names +# +# SYNTAX: +# comma separated list of sections +# ---------------------------------------------------------------------- + +[sections] +must = "detect,set" +can = "" + +# ---------------------------------------------------------------------- +# validate keys in sections +# +# SYNTAX: +# <section> .<key> = "<VALIDATION_TYPE>[:<VALIDATION_VALUE>]" +# VALIDATION_TYPE: +# - INTEGER +# - REGEX:<REGEX_TO_VALIDATE> +# - ONEOF:<VALUE1[,<VALUE_N>]> +# ---------------------------------------------------------------------- + +[varsMust] +; detect.tcp-port = "INTEGER" + +[varsCan] +detect.binary = "REGEX:.*" +detect.process = +detect.tcp-port = "INTEGER" +detect.tcp-target = "REGEX:.*" +detect.tcp-process = +detect.type = "ONEOF:sqlite" +detect.file[] = + +set.su = +set.dbuser = +set.dbpassword = +set.env = +set.params = + +# ---------------------------------------------------------------------- -- GitLab