Exemplo n.º 1
0
 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("")
Exemplo n.º 2
0
    def _load_rule(self, rule):
        '''Modify dialog controls to reflect rule.'''
        self._radio_set(rule.action, self.__action_map)
        if audit.AUDIT_FILTERKEY not in self.excluded_fields:
            self.keys = [f.value for f in rule.fields
                         if f.var == audit.AUDIT_FILTERKEY]
            self.rule_keys_present.set_active(len(self.keys) != 0)
            self.__update_rule_keys()
        if audit.AUDIT_ARCH not in self.excluded_fields:
            for f in rule.fields:
                if f.var == audit.AUDIT_ARCH:
                    self.rule_arch_present.set_active(True)
                    try:
                        m = util.parse_elf(f.value)
                    except util.ParsingError:
                        assert False, 'Rule should not have been created'
                    util.set_combo_entry_text(self.rule_arch, f.value)
                    break
            else:
                self.rule_arch_present.set_active(False)
                self.rule_arch.set_active(-1)
                self.rule_arch.child.set_text('')
                m = util.audit_machine_id
            assert rule.machine == m
            self.__rule_arch_changed()

        if audit.AUDIT_ARCH not in self.excluded_fields:
            self.syscall_store.clear()
            if Rule.SYSCALLS_ALL in rule.syscalls:
                self.rule_syscalls_not_all.set_active(False)
            else:
                self.rule_syscalls_not_all.set_active(True)
                for sc in rule.syscalls:
                    name = util.syscall_string(sc, self.machine_id)
                    self.syscall_store.append((name,))

        self.fields_store.clear()
        for field in rule.fields:
            if field.var not in (audit.AUDIT_ARCH, audit.AUDIT_FILTERKEY):
                it = self.fields_store.append()
                self.fields_store.set_value(it, 0, field)
                self.__update_fields_store_row(it)