File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,19 @@ if [ -n "${MANUAL_MODE}" ]; then
17
17
return
18
18
fi
19
19
20
-
20
+ # Default config file path
21
21
setup_conf_path=" /etc/modsecurity.d/owasp-crs/crs-setup.conf"
22
22
23
+ # Accept optional config file
24
+ if [ -n " ${CONFIG_FILE} " ]; then
25
+ setup_conf_path=" ${CONFIG_FILE} "
26
+ fi
27
+
23
28
set_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} "
28
33
echo " Configuring ${rule} for ${var_name} with ${tx_var_name} =${var_value} "
29
34
30
35
# 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() {
58
63
}
59
64
60
65
can_set () {
61
- local rule=" ${1} "
62
- local tx_var_name=" ${2} "
66
+ rule=" ${1} "
67
+ tx_var_name=" ${2} "
63
68
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
65
70
return 1
66
- elif ! grep -Eq " setvar:'?tx\.${tx_var_name} " " ${setup_conf_path} " ; then
67
- return 1
68
- else
69
- return 0
70
71
fi
72
+ return 0
71
73
}
72
74
73
75
get_legacy () {
@@ -80,7 +82,7 @@ get_var_name() {
80
82
81
83
get_var_value () {
82
84
# 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 ) "
84
86
}
85
87
86
88
get_rule () {
You can’t perform that action at this time.
0 commit comments