Ejemplo n.º 1
0
 def __rule_syscall_add_clicked(self, *_):
     name = self.rule_syscall_name.child.get_text()
     try:
         util.parse_syscall(name, self.machine_id)
     except util.ParsingError, e:
         self._modal_error_dialog(str(e))
         self.rule_syscall_name.grab_focus()
         return
Ejemplo n.º 2
0
    def _save_rule(self, rule):
        '''Modify rule to reflect dialog state.'''
        rule.action = self._radio_get(self.__action_map)

        del rule.fields[:]
        if (audit.AUDIT_FILTERKEY not in self.excluded_fields and
            self.rule_keys_present.get_active()):
            for key in self.keys:
                f = Field()
                f.var = audit.AUDIT_FILTERKEY
                f.op = Field.OP_EQ
                f.value = key
                rule.fields.append(f)
        if audit.AUDIT_ARCH not in self.excluded_fields:
            if self.rule_arch_present.get_active():
                f = Field()
                f.var = audit.AUDIT_ARCH
                f.op = Field.OP_EQ
                f.value = self.rule_arch.child.get_text()
                try:
                    rule.machine = util.parse_elf(f.value)
                except util.ParsingError:
                    assert False, 'Should have been validated'
                rule.fields.append(f)
            else:
                rule.machine = util.audit_machine_id
        it = self.fields_store.get_iter_first()
        while it is not None:
            rule.fields.append(self.fields_store.get_value(it, 0))
            it = self.fields_store.iter_next(it)

        if audit.AUDIT_ARCH not in self.excluded_fields:
            del rule.syscalls[:]
            if self.rule_syscalls_not_all.get_active():
                it = self.syscall_store.get_iter_first()
                while it is not None:
                    name = self.syscall_store.get_value(it, 0)
                    try:
                        sc = util.parse_syscall(name, self.machine_id)
                    except util.ParsingError:
                        assert False, 'Should have been validated'
                    rule.syscalls.append(sc)
                    it = self.syscall_store.iter_next(it)
                assert len(rule.syscalls) > 0
            else:
                rule.syscalls.append(Rule.SYSCALLS_ALL)