def _load_key(self, key): '''Modify dialog controls to reflect key.''' ids_key = util.parse_ids_key(key) # Silently show invalid IDS keys as text, only refuse them when closing # the dialog. if ids_key is None: self.key_is_text.set_active(True) self.key_text.set_text(key) else: self.key_is_ids.set_active(True) (type_, severity) = ids_key util.set_combo_option(self.key_ids_type, type_) util.set_combo_option(self.key_ids_severity, severity)
def _load_rule(self, rule): """Modify dialog controls to reflect rule.""" assert len(rule.fields) <= 1 has_field = len(rule.fields) == 1 self.event_type_any.set_active(not has_field) self.event_type_condition.set_active(has_field) if has_field: field = rule.fields[0] assert field.var == audit.AUDIT_MSGTYPE util.set_combo_option(self.event_type_op, field.op) util.set_combo_entry_text(self.event_type_value, util.msgtype_string(field.value)) else: self.event_type_op.set_active(-1) self.event_type_value.set_active(-1) self.event_type_value.child.set_text("")
def __rule_field_var_changed(self, *_): it = self.rule_field_var.get_active_iter() util.set_sensitive_all(it is not None, self.rule_field_op, self.rule_field_value, self.rule_field_add) if it is None: self.rule_field_var_info.set_text('') return name = self.field_var_store.get_value(it, 0) try: var = audit.audit_name_to_field(name) except OSError: var = None it = self.rule_field_op.get_active_iter() if it: old_op = self.field_op_store.get_value(it, 0) else: old_op = None self.field_op_store.clear() self.field_value_store.clear() if var is not None: field_type = Field.get_field_type(var) ops = field_type.usual_operators(var) for op in ops: self.field_op_store.append((op,)) if set(ops) != set(Field.all_operators): self.field_op_store.append(('',)) for op in Field.all_operators: if op not in ops: self.field_op_store.append((op,)) for hint in field_type.hints(): self.field_value_store.append((hint,)) else: for op in Field.all_operators: self.field_op_store.append((op,)) if old_op is not None: util.set_combo_option(self.rule_field_op, old_op) self.rule_field_var_info.set_text(field_help.field_help(var))