2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-31 06:16:03 +00:00

[patch] extend and partially rewrite write_header()

- add support for prof_data['header_comment'] (comment after '{')
  and prof_data['profile_keyword'] (to force the 'profile' keyword, even
  if it isn't needed) to write_header().
  (set_profile_flags() will be the only user of these two for now)

- fix a crash if depth is not an integer - for example,
      len('   ')/2   # 3 spaces = 1.5
  would cause a crash.
  Also add a test for 1.5 and 1.3 spaces.

- rewrite the handling of flags to avoid we have to maintain two
  different template lines.

- update the tests to set 'profile_keyword' and 'header_comment' to None.
  This avoids big changes in the test code. I'll send another patch that
  makes sure profile_keyword and header_comment are tested ;-)


Acked-by: Steve Beattie <steve@nxnw.org>
This commit is contained in:
Christian Boltz
2015-04-02 01:30:01 +02:00
parent e0a8ed7673
commit b81400185d
2 changed files with 15 additions and 7 deletions

View File

@@ -327,6 +327,8 @@ class AaTest_write_header(AATest):
(['bar baz', False, True, 1, 'complain', '/foo sp' ], ' profile "bar baz" "/foo sp" flags=(complain) {'),
(['^foo', False, True, 1, 'complain', None ], ' profile ^foo flags=(complain) {'),
(['^foo', True, True, 1, 'complain', None ], ' ^foo flags=(complain) {'),
(['^foo', True, True, 1.5, 'complain', None ], ' ^foo flags=(complain) {'),
(['^foo', True, True, 1.3, 'complain', None ], ' ^foo flags=(complain) {'),
]
def _run_test(self, params, expected):
@@ -334,7 +336,7 @@ class AaTest_write_header(AATest):
embedded_hat = params[1]
write_flags = params[2]
depth = params[3]
prof_data = { 'flags': params[4], 'attachment': params[5] }
prof_data = { 'flags': params[4], 'attachment': params[5], 'profile_keyword': None, 'header_comment': None }
result = write_header(prof_data, depth, name, embedded_hat, write_flags)
self.assertEqual(result, [expected])