2014-04-23 15:40:20 -05:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# ------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Copyright (C) 2014 Canonical Ltd.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of version 2 of the GNU General Public
|
|
|
|
# License published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# ------------------------------------------------------------------
|
|
|
|
|
|
|
|
import unittest
|
2015-12-27 01:16:55 +01:00
|
|
|
from common_test import AATest, setup_all_loops
|
2014-09-03 18:32:59 -07:00
|
|
|
|
2015-12-27 01:16:55 +01:00
|
|
|
from apparmor.rule.ptrace import PtraceRule
|
|
|
|
|
|
|
|
class AAParsePtraceTest(AATest):
|
|
|
|
def _run_test(self, params, expected):
|
|
|
|
rule_obj = PtraceRule.parse(params)
|
|
|
|
self.assertEqual(rule_obj.get_clean(), expected)
|
2014-09-03 18:32:59 -07:00
|
|
|
|
|
|
|
tests = [
|
2015-12-27 01:16:55 +01:00
|
|
|
('ptrace,', 'ptrace,'),
|
|
|
|
('ptrace (readby),', 'ptrace readby,'),
|
|
|
|
('ptrace (trace),', 'ptrace trace,'),
|
|
|
|
('ptrace (trace read),', 'ptrace (read trace),'),
|
|
|
|
('ptrace r,', 'ptrace r,'),
|
|
|
|
('ptrace w,', 'ptrace w,'),
|
|
|
|
('ptrace rw,', 'ptrace rw,'),
|
|
|
|
('ptrace read peer=foo,', 'ptrace read peer=foo,'),
|
|
|
|
('ptrace (trace read) peer=/usr/bin/bar,', 'ptrace (read trace) peer=/usr/bin/bar,'),
|
|
|
|
('ptrace wr peer=/sbin/baz,', 'ptrace wr peer=/sbin/baz,'),
|
2014-09-03 18:32:59 -07:00
|
|
|
]
|
2014-04-23 15:40:20 -05:00
|
|
|
|
2015-12-27 01:16:55 +01:00
|
|
|
setup_all_loops(__name__)
|
2014-04-23 15:40:20 -05:00
|
|
|
if __name__ == '__main__':
|
2014-07-25 17:49:06 -07:00
|
|
|
unittest.main(verbosity=2)
|