mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
fixed regexp rules exceptions
- ui, ruleseditor: added missing operator when using a regular expression on the DstIP/Net field. - daemon, rules: ensure that regular expressions are of type string before evaluating them. reported here: #333
This commit is contained in:
parent
b1dd51be7a
commit
b4672830cd
2 changed files with 6 additions and 0 deletions
|
@ -3,6 +3,7 @@ package rule
|
|||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
|
@ -122,6 +123,10 @@ func (o *Operator) simpleCmp(v interface{}) bool {
|
|||
}
|
||||
|
||||
func (o *Operator) reCmp(v interface{}) bool {
|
||||
if vt := reflect.ValueOf(v).Kind(); vt != reflect.String {
|
||||
log.Warning("Operator.reCmp() bad interface type: %T", v)
|
||||
return false
|
||||
}
|
||||
if o.Sensitive == false {
|
||||
v = strings.ToLower(v.(string))
|
||||
}
|
||||
|
|
|
@ -450,6 +450,7 @@ class RulesEditorDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self.rule.operator.type = "network"
|
||||
|
||||
if self._is_regex(dstIPtext):
|
||||
self.rule.operator.operand = "dest.ip"
|
||||
self.rule.operator.type = "regexp"
|
||||
if self._is_valid_regex(self.dstIPCombo.currentText()) == False:
|
||||
return False, QtCore.QCoreApplication.translate("rules", "Dst IP regexp error")
|
||||
|
|
Loading…
Add table
Reference in a new issue