Skip to content

Commit e0926fe

Browse files
committed
Fix parser error while dealing with operator negation
This patch closes the issue #960
1 parent 47a62b9 commit e0926fe

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

src/operators/operator.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ Operator *Operator::instantiate(std::string op_string) {
109109
std::string param = "";
110110
if (op.find(" ") != std::string::npos) {
111111
param = op;
112-
param.erase(0, op_string.find(" "));
113-
op.erase(op_string.find(" "),
114-
op_string.length() - op_string.find(" "));
112+
param.erase(0, param.find(" ") + 1);
113+
op.erase(op.find(" "),
114+
op.length() - op.find(" "));
115115
}
116116

117117
for (std::basic_string<char>::iterator p = op.begin();

src/parser/seclang-scanner.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
174174
VAR_FREE_TEXT_SPACE [^ \t\"]+
175175
176176
177-
SOMETHING ["]{1}[^@]{1}([^"]|([^\\"]\\\"))*["]{1}
177+
SOMETHING ["]{1}[^@|!]{1}([^"]|([^\\"]\\\"))*["]{1}
178178
179179
CONFIG_DIR_UNICODE_MAP_FILE (?i:SecUnicodeMapFile)
180180

test/test-cases/regression/config-include.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
]
3232
},
3333
"expected":{
34-
"debug_log":"Executing operator \"@contains \" with param \"config_example2\" against ARGS."
34+
"debug_log":"Executing operator \"@contains\" with param \"config_example2\" against ARGS."
3535
},
3636
"rules":[
3737
"SecRuleEngine On",
@@ -73,7 +73,7 @@
7373
]
7474
},
7575
"expected":{
76-
"debug_log":"Executing operator \"@contains \" with param \"config_example\" against ARGS."
76+
"debug_log":"Executing operator \"@contains\" with param \"config_example\" against ARGS."
7777
},
7878
"rules":[
7979
"SecRuleEngine On",
@@ -115,7 +115,7 @@
115115
]
116116
},
117117
"expected":{
118-
"debug_log":"Executing operator \"@contains \" with param \"config_example2\" against ARGS."
118+
"debug_log":"Executing operator \"@contains\" with param \"config_example2\" against ARGS."
119119
},
120120
"rules":[
121121
"SecRuleEngine On",
@@ -157,7 +157,7 @@
157157
]
158158
},
159159
"expected":{
160-
"debug_log":"Executing operator \"@contains \" with param \"test\" against ARGS."
160+
"debug_log":"Executing operator \"@contains\" with param \"test\" against ARGS."
161161
},
162162
"rules":[
163163
"SecRuleEngine On",
@@ -199,7 +199,7 @@
199199
]
200200
},
201201
"expected":{
202-
"debug_log":"Executing operator \"@contains \" with param \"config_example2\" against ARGS."
202+
"debug_log":"Executing operator \"@contains\" with param \"config_example2\" against ARGS."
203203
},
204204
"rules":[
205205
"SecRuleEngine On",
@@ -242,7 +242,7 @@
242242
]
243243
},
244244
"expected":{
245-
"debug_log":"Executing operator \"@contains \" with param \"test\" against ARGS."
245+
"debug_log":"Executing operator \"@contains\" with param \"test\" against ARGS."
246246
},
247247
"rules":[
248248
"SecRuleEngine On",

test/test-cases/regression/config-secremoterules.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
]
3232
},
3333
"expected":{
34-
"debug_log":"Executing operator \"@pmfromfile \" with param \"https://www.modsecurity.org/modsecurity-regression-test.txt\" against REQUEST_FILENAME"
34+
"debug_log":"Executing operator \"@pmfromfile\" with param \"https://www.modsecurity.org/modsecurity-regression-test.txt\" against REQUEST_FILENAME"
3535
},
3636
"rules":[
3737
"SecRuleEngine On",
@@ -88,7 +88,7 @@
8888
]
8989
},
9090
"expected":{
91-
"debug_log":"Executing operator \"@contains \" with param \"somethingelse\" against ARGS."
91+
"debug_log":"Executing operator \"@contains\" with param \"somethingelse\" against ARGS."
9292
},
9393
"rules":[
9494
"SecRuleEngine On",

test/test-cases/regression/misc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"title":"Testing action :: SecRule directives should be case insensitive",
77
"expected":{
88
"audit_log":"",
9-
"debug_log":"Executing operator \"@contains \" with param \"PHPSESSID\" against REQUEST_HEADERS.",
9+
"debug_log":"Executing operator \"@contains\" with param \"PHPSESSID\" against REQUEST_HEADERS.",
1010
"error_log":""
1111
},
1212
"rules":[

0 commit comments

Comments
 (0)