Skip to content

Commit de59229

Browse files
committed
fix: revert ed
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
1 parent bcafb53 commit de59229

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/opt/modsecurity/configure-rules.sh

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ set_value() {
4646
var_name="${2}"
4747
tx_var_name="${3}"
4848
var_value="${4}"
49-
49+
5050
echo "Configuring ${rule} for ${var_name} with ${tx_var_name}=${var_value}"
5151

5252
# For each rule, we do one pass to uncomment the rule (up to first blank line after the rule),
@@ -68,24 +68,12 @@ EOF
6868
# and whether the expression is enclosed in single quotes.
6969
# Use `#` as pattern delimiter, as `/` is part of some variable values.
7070
# Try to find and update the variable (with or without quotes)
71-
if ed -s "${setup_conf_path}" <<EOF 2 > /dev/null
72-
/id:${rule}/
73-
/setvar:tx\.${tx_var_name}=/
74-
s#=[^,"']*#=${var_value}#
75-
wq
76-
EOF
77-
then
78-
# Success with unquoted pattern
79-
true
80-
else
81-
# Try with quoted pattern
82-
ed -s "${setup_conf_path}" <<EOF 2 > /dev/null
71+
ed -s "${setup_conf_path}" <<EOF 2 > /dev/null
8372
/id:${rule}/
84-
/setvar:'tx\.${tx_var_name}=/
85-
s#=[^'"]'\"#=${var_value}'\"#
73+
/setvar:'\?tx\.${tx_var_name}=/
74+
s#=[^,'"]\+#=${var_value}#
8675
wq
8776
EOF
88-
fi
8977
}
9078

9179
should_set() {

0 commit comments

Comments
 (0)