• Home
  • Raw
  • Download

Lines Matching refs:parser

30 import parser  # pylint: disable=wrong-import-order
42 parser_state = parser.ParserState('<memory>')
90 with self.assertRaisesRegex(parser.ParseException,
102 self.parser = parser.PolicyParser(
107 return list(self.parser._parser_state.tokenize([line]))[0]
112 self.parser.parse_value(self._tokenize('0x80000000')), 0x80000000)
115 self.parser.parse_value(self._tokenize('0x8000000000000000')),
121 with self.assertRaisesRegex(parser.ParseException,
123 self.parser.parse_value(self._tokenize('0x100000000'))
124 with self.assertRaisesRegex(parser.ParseException,
126 self.parser.parse_value(self._tokenize('0x10000000000000000'))
131 self.parser.parse_value(self._tokenize('-1')),
137 with self.assertRaisesRegex(parser.ParseException,
139 self.parser.parse_value(self._tokenize('-0x800000001'))
140 with self.assertRaisesRegex(parser.ParseException, 'signed underflow'):
141 self.parser.parse_value(self._tokenize('-0x8000000000000001'))
146 self.parser.parse_value(self._tokenize('0x1|0x2|0x4|0x8')), 0xf)
161 with self.assertRaises(parser.ParseException, msg=expression):
162 self.parser.parse_value(self._tokenize(expression))
171 self.parser.parse_value(tokens)
185 self.parser.parse_value(self._tokenize(expression)), 3)
190 self.parser.parse_value(self._tokenize('~0')),
193 self.parser.parse_value(self._tokenize('~0|~0')),
197 self.parser.parse_value(
200 self.parser.parse_value(
205 self.parser.parse_value(
209 self.parser.parse_value(
216 with self.assertRaisesRegex(parser.ParseException,
218 self.parser.parse_value(self._tokenize('~~0'))
222 with self.assertRaisesRegex(parser.ParseException, 'empty complement'):
223 self.parser.parse_value(self._tokenize('0|~'))
228 self.parser.parse_value(self._tokenize('O_RDONLY')), 0)
232 with self.assertRaisesRegex(parser.ParseException, 'empty constant'):
233 self.parser.parse_value([])
234 with self.assertRaisesRegex(parser.ParseException, 'empty constant'):
235 self.parser.parse_value(self._tokenize('0|'))
239 with self.assertRaisesRegex(parser.ParseException, 'invalid constant'):
240 self.parser.parse_value(self._tokenize('foo'))
248 self.parser = parser.PolicyParser(
253 return list(self.parser._parser_state.tokenize([line]))[0]
258 self.parser.parse_argument_expression(
262 [parser.Atom(0, 'in', 0xffff)],
263 [parser.Atom(0, '==', 4),
264 parser.Atom(1, '==', 2)],
269 with self.assertRaisesRegex(parser.ParseException,
271 self.parser.parse_argument_expression(
276 with self.assertRaisesRegex(parser.ParseException, 'empty clause'):
277 self.parser.parse_argument_expression(
282 with self.assertRaisesRegex(parser.ParseException, 'invalid argument'):
283 self.parser.parse_argument_expression(
288 with self.assertRaisesRegex(parser.ParseException, 'invalid operator'):
289 self.parser.parse_argument_expression(
294 with self.assertRaisesRegex(parser.ParseException, 'missing operator'):
295 self.parser.parse_argument_expression(self._tokenize('arg0'))
299 with self.assertRaisesRegex(parser.ParseException, 'empty constant'):
300 self.parser.parse_argument_expression(self._tokenize('arg0 =='))
308 self.parser = parser.PolicyParser(
313 return list(self.parser._parser_state.tokenize([line]))[0]
318 self.parser.parse_filter(self._tokenize('arg0 == 0')), [
319 parser.Filter([[parser.Atom(0, '==', 0)]], bpf.Allow()),
322 self.parser.parse_filter(self._tokenize('kill-process')), [
323 parser.Filter(None, bpf.KillProcess()),
326 self.parser.parse_filter(self._tokenize('kill-thread')), [
327 parser.Filter(None, bpf.KillThread()),
330 self.parser.parse_filter(self._tokenize('trap')), [
331 parser.Filter(None, bpf.Trap()),
334 self.parser.parse_filter(self._tokenize('return ENOSYS')), [
335 parser.Filter(None,
339 self.parser.parse_filter(self._tokenize('trace')), [
340 parser.Filter(None, bpf.Trace()),
343 self.parser.parse_filter(self._tokenize('log')), [
344 parser.Filter(None, bpf.Log()),
347 self.parser.parse_filter(self._tokenize('allow')), [
348 parser.Filter(None, bpf.Allow()),
351 self.parser.parse_filter(self._tokenize('1')), [
352 parser.Filter(None, bpf.Allow()),
355 self.parser.parse_filter(
359 parser.Filter([[parser.Atom(0, '==', 0)]], bpf.Allow()),
360 parser.Filter([[parser.Atom(0, '==', 1)]],
362 parser.Filter(None, bpf.Trap()),
367 with self.assertRaisesRegex(parser.ParseException,
369 self.parser.parse_filter(self._tokenize('return'))
373 with self.assertRaisesRegex(parser.ParseException, 'invalid constant'):
374 self.parser.parse_filter(self._tokenize('return arg0'))
378 with self.assertRaisesRegex(parser.ParseException, 'unclosed brace'):
379 self.parser.parse_filter(self._tokenize('{ allow'))
387 self.parser = parser.PolicyParser(
392 return list(self.parser._parser_state.tokenize([line]))[0]
397 self.parser.parse_filter_statement(
399 parser.ParsedFilterStatement((parser.Syscall('read', 0), ), [
400 parser.Filter([[parser.Atom(0, '==', 0)]], bpf.Allow()),
403 self.parser.parse_filter_statement(
405 parser.ParsedFilterStatement((
406 parser.Syscall('read', 0),
407 parser.Syscall('write', 1),
409 parser.Filter([[parser.Atom(0, '==', 0)]], bpf.Allow()),
412 self.parser.parse_filter_statement(
414 parser.ParsedFilterStatement((
415 parser.Syscall('read', 0),
416 parser.Syscall('write', 1),
418 parser.Filter([[parser.Atom(0, '==', 0)]], bpf.Allow()),
421 self.parser.parse_filter_statement(
423 parser.ParsedFilterStatement((
424 parser.Syscall('read', 0),
425 parser.Syscall('write', 1),
427 parser.Filter([[parser.Atom(0, '==', 0)]], bpf.Allow()),
433 self.parser.parse_filter_statement(
435 parser.ParsedFilterStatement((parser.Syscall('read', 0), ), [
436 parser.Filter([[parser.Atom(0, '==', 0)]], bpf.Allow()),
439 self.parser.parse_filter_statement(
442 parser.ParsedFilterStatement((parser.Syscall('read', 0), ), [
443 parser.Filter([[parser.Atom(0, '==', 0)]], bpf.Allow()),
448 with self.assertRaisesRegex(parser.ParseException, 'unclosed brace'):
449 self.parser.parse_filter(self._tokenize('{ allow'))
453 with self.assertRaisesRegex(parser.ParseException, 'unclosed brace'):
454 self.parser.parse_filter_statement(
459 with self.assertRaisesRegex(parser.ParseException, 'missing colon'):
460 self.parser.parse_filter_statement(self._tokenize('read'))
464 with self.assertRaisesRegex(parser.ParseException, 'invalid colon'):
465 self.parser.parse_filter_statement(self._tokenize('read arg0'))
469 with self.assertRaisesRegex(parser.ParseException, 'missing filter'):
470 self.parser.parse_filter_statement(self._tokenize('read:'))
478 self.parser = parser.PolicyParser(
502 self.parser.parse_file(path),
503 parser.ParsedPolicy(
506 parser.FilterStatement(
507 syscall=parser.Syscall('read', 0),
510 parser.Filter(None, bpf.Allow()),
512 parser.FilterStatement(
513 syscall=parser.Syscall('write', 1),
516 parser.Filter(None, bpf.Allow()),
531 self.parser.parse_file(path),
532 parser.ParsedPolicy(
535 parser.FilterStatement(
536 syscall=parser.Syscall('read', 0),
539 parser.Filter(None, bpf.Allow()),
541 parser.FilterStatement(
542 syscall=parser.Syscall('write', 1),
545 parser.Filter(None, bpf.Allow()),
558 self.parser.parse_file(path),
559 parser.ParsedPolicy(
562 parser.FilterStatement(
563 syscall=parser.Syscall('read', 0),
566 parser.Filter(None, bpf.Allow()),
578 with self.assertRaisesRegex(parser.ParseException,
580 self.parser.parse_file(path)
591 self.parser.parse_file(path),
592 parser.ParsedPolicy(
595 parser.FilterStatement(
596 syscall=parser.Syscall('read', 0),
599 parser.Filter(None, bpf.Allow()),
601 parser.FilterStatement(
602 syscall=parser.Syscall('write', 1),
605 parser.Filter(None, bpf.Allow()),
619 self.parser.parse_file(path),
620 parser.ParsedPolicy(
623 parser.FilterStatement(
624 syscall=parser.Syscall('write', 1),
627 parser.Filter(None, bpf.Allow()),
644 self.parser.parse_file(path),
645 parser.ParsedPolicy(
648 parser.FilterStatement(
649 syscall=parser.Syscall('read', 0),
652 parser.Filter([[parser.Atom(0, '==', 0)]],
654 parser.Filter(
659 parser.FilterStatement(
660 syscall=parser.Syscall('write', 1),
663 parser.Filter([[parser.Atom(0, '==', 0)]],
665 parser.Filter(None, bpf.KillProcess()),
671 with self.assertRaisesRegex(parser.ParseException,
677 self.parser.parse_file(path)
679 with self.assertRaisesRegex(parser.ParseException,
685 self.parser.parse_file(path)
687 with self.assertRaisesRegex(parser.ParseException,
693 self.parser.parse_file(path)
695 with self.assertRaisesRegex(parser.ParseException,
701 self.parser.parse_file(path)
717 self.parser.parse_file(path),
718 parser.ParsedPolicy(
721 parser.FilterStatement(
722 syscall=parser.Syscall('read', 0),
725 parser.Filter(None, bpf.Allow()),
734 with self.assertRaisesRegex(parser.ParseException, r'missing colon'):
738 self.parser.parse_file(path)
740 with self.assertRaisesRegex(parser.ParseException, r'invalid colon'):
744 self.parser.parse_file(path)
746 with self.assertRaisesRegex(parser.ParseException, r'missing number'):
750 self.parser.parse_file(path)
752 with self.assertRaisesRegex(parser.ParseException, r'invalid number'):
756 self.parser.parse_file(path)
758 with self.assertRaisesRegex(parser.ParseException, r'invalid number'):
762 self.parser.parse_file(path)
764 with self.assertRaisesRegex(parser.ParseException,
770 self.parser.parse_file(path)
772 with self.assertRaisesRegex(parser.ParseException,
778 self.parser.parse_file(path)
780 with self.assertRaisesRegex(parser.ParseException,
786 self.parser.parse_file(path)
797 parser.ParseException,
799 self.parser.parse_file(path)
808 parser.ParseException,
810 self.parser.parse_file(path)