Skip to content

Commit edaa450

Browse files
nobody43roddhjav
authored andcommitted
fix exec_path bug, ignore skipable files
1 parent 8f4b330 commit edaa450

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

tests/profile_check.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,8 @@ def readApparmorFile(fullpath):
186186
if m.get('profile'):
187187
nestingStacker.append(m.get('profile')) # set early
188188

189-
if m.get('attachment') != '@{exec_path}' and not gotAttach: # can be only singular
189+
if m.get('attachment') == '@{exec_path}' and not gotAttach: # can be only singular
190190
gotAttach = True
191-
messages.append({'filename': fullpath,
192-
'profile': getCurrentProfile(nestingStacker),
193-
'severity': 'WARNING',
194-
'line': n,
195-
'reason': "'@{exec_path}' must be defined as main path attachment",
196-
'suggestion': None})
197191

198192
profileMsg = {'filename': fullpath,
199193
'profile': getCurrentProfile(nestingStacker),
@@ -324,6 +318,15 @@ def readApparmorFile(fullpath):
324318
'reason': 'ABI is required',
325319
'suggestion': abi})
326320

321+
# Ensure singular '@{exec_path}'
322+
if not gotAttach:
323+
messages.append({'filename': fullpath,
324+
'profile': None,
325+
'severity': 'WARNING',
326+
'line': None,
327+
'reason': "'@{exec_path}' must be defined as main path attachment",
328+
'suggestion': None})
329+
327330
# Ensure trailing vim syntax
328331
if line:
329332
trailingSyntax = '# vim:syntax=apparmor\n'
@@ -450,10 +453,11 @@ def main(argv):
450453

451454
profile_data = {}
452455
for path in sorted(profiles):
453-
readApparmorFile_Out = readApparmorFile(path)
454-
profilesInFile = readApparmorFile_Out[1]
455-
messages.extend(readApparmorFile_Out[0])
456-
profile_data.update(profilesInFile)
456+
if not is_skippable_file(path):
457+
readApparmorFile_Out = readApparmorFile(path)
458+
profilesInFile = readApparmorFile_Out[1]
459+
messages.extend(readApparmorFile_Out[0])
460+
profile_data.update(profilesInFile)
457461

458462
for m in messages:
459463
if m.get('suggestion'):

0 commit comments

Comments
 (0)