File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,14 +17,19 @@ if [ -n "${MANUAL_MODE}" ]; then
1717 return
1818fi
1919
20-
20+ # Default config file path
2121setup_conf_path=" /etc/modsecurity.d/owasp-crs/crs-setup.conf"
2222
23+ # Accept optional config file
24+ if [ -n " ${CONFIG_FILE} " ]; then
25+ setup_conf_path=" ${CONFIG_FILE} "
26+ fi
27+
2328set_value () {
24- local rule=" ${1} "
25- local var_name=" ${2} "
26- local tx_var_name=" ${3} "
27- local var_value=" ${4} "
29+ rule=" ${1} "
30+ var_name=" ${2} "
31+ tx_var_name=" ${3} "
32+ var_value=" ${4} "
2833 echo " Configuring ${rule} for ${var_name} with ${tx_var_name} =${var_value} "
2934
3035 # For each rule, we do one pass to uncomment the rule (up to first blank line after the rule),
@@ -58,16 +63,13 @@ should_set() {
5863}
5964
6065can_set () {
61- local rule=" ${1} "
62- local tx_var_name=" ${2} "
66+ rule=" ${1} "
67+ tx_var_name=" ${2} "
6368
64- if ! grep -q " id:${rule} " " ${setup_conf_path} " ; then
69+ if ! grep -q " id:${rule} " " ${setup_conf_path} " -a ! grep -Eq " setvar:'?tx\. ${tx_var_name} " " ${setup_conf_path} " ; then
6570 return 1
66- elif ! grep -Eq " setvar:'?tx\.${tx_var_name} " " ${setup_conf_path} " ; then
67- return 1
68- else
69- return 0
7071 fi
72+ return 0
7173}
7274
7375get_legacy () {
@@ -80,7 +82,7 @@ get_var_name() {
8082
8183get_var_value () {
8284 # Get the variable name, produce "${<var name>}" and use eval to expand
83- eval " echo $( echo " ${1} " | awk -F' \|' ' {print "${"$2"}"}' ) "
85+ eval " echo $( echo " ${1} " | awk -F' \|' ' {print "${"$2"}"}' || true ) "
8486}
8587
8688get_rule () {
You can’t perform that action at this time.
0 commit comments