Improved performance for AT command hint(potential injection vulnerabilities)

This commit is contained in:
fujr 2024-11-14 23:53:52 +08:00
parent 260f5aba1b
commit d6539a1978

View File

@ -78,19 +78,16 @@ get_at_cfg(){
json_close_array json_close_array
json_add_string using_port $(uci get qmodem.$config_section.at_port) json_add_string using_port $(uci get qmodem.$config_section.at_port)
json_add_array cmds json_add_array cmds
general_cmd=$(jq -rc '.general[]|to_entries' /usr/share/qmodem/at_commands.json) general_cmd=$(jq -rc '.general[]|to_entries| .[] | @sh "key=\(.key) value=\(.value)"' /usr/share/qmodem/at_commands.json)
platform_cmd=$(jq -rc ".${vendor}.${platform}[]|to_entries| .[] | @sh \"key=\(.key) value=\(.value)\"" /usr/share/qmodem/at_commands.json)
platform_cmd=$(jq -rc ".${vendor}.${platform}[]|to_entries" /usr/share/qmodem/at_commands.json) [ -z "$platform_cmd" ] && platform_cmd=$(jq -rc ".$vendor.general[]|to_entries| .[] | @sh \"key=\(.key) value=\(.value)\"" /usr/share/qmodem/at_commands.json)
[ -z "$platform_cmd" ] && platform_cmd=$(jq -rc ".$vendor.general[]|to_entries" /usr/share/qmodem/at_commands.json)
cmds=$(echo -e "$general_cmd\n$platform_cmd") cmds=$(echo -e "$general_cmd\n$platform_cmd")
IFS=$'\n' IFS=$'\n'
for cmd in $cmds; do for cmd in $cmds; do
json_add_object cmd json_add_object cmd
cmd_name="$(echo $cmd | jq -r '.[0].key')" eval $cmd
cmd_value="$(echo $cmd | jq -r '.[0].value')" json_add_string "name" "$key"
json_add_string "name" "$cmd_name" json_add_string "value" "$value"
json_add_string "value" "$cmd_value"
json_close_object json_close_object
done done
json_close_array json_close_array
@ -99,7 +96,6 @@ get_at_cfg(){
unset IFS unset IFS
} }
#会初始化一个json对象 命令执行结果会保存在json对象中 #会初始化一个json对象 命令执行结果会保存在json对象中
json_init json_init
json_add_object result json_add_object result