mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-02 23:35:37 +00:00
Use AbiRule in ProfileStorage (for abi rules inside profiles)
This also drops the last usage of write_abi(), drop it.
This commit is contained in:
@@ -1919,7 +1919,7 @@ def parse_profile_data(data, file, do_include):
|
|||||||
|
|
||||||
elif AbiRule.match(line):
|
elif AbiRule.match(line):
|
||||||
if profile:
|
if profile:
|
||||||
profile_data[profile][hat]['abi'].append(line)
|
profile_data[profile][hat]['abi'].add(AbiRule.parse(line))
|
||||||
else:
|
else:
|
||||||
active_profiles.add_abi(file, AbiRule.parse(line))
|
active_profiles.add_abi(file, AbiRule.parse(line))
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
from apparmor.common import AppArmorBug, type_is_str
|
from apparmor.common import AppArmorBug, type_is_str
|
||||||
|
|
||||||
|
from apparmor.rule.abi import AbiRuleset
|
||||||
from apparmor.rule.capability import CapabilityRuleset
|
from apparmor.rule.capability import CapabilityRuleset
|
||||||
from apparmor.rule.change_profile import ChangeProfileRuleset
|
from apparmor.rule.change_profile import ChangeProfileRuleset
|
||||||
from apparmor.rule.dbus import DbusRuleset
|
from apparmor.rule.dbus import DbusRuleset
|
||||||
@@ -33,6 +34,7 @@ from apparmor.translations import init_translation
|
|||||||
_ = init_translation()
|
_ = init_translation()
|
||||||
|
|
||||||
ruletypes = {
|
ruletypes = {
|
||||||
|
'abi': {'ruleset': AbiRuleset},
|
||||||
'inc_ie': {'ruleset': IncludeRuleset},
|
'inc_ie': {'ruleset': IncludeRuleset},
|
||||||
'capability': {'ruleset': CapabilityRuleset},
|
'capability': {'ruleset': CapabilityRuleset},
|
||||||
'change_profile': {'ruleset': ChangeProfileRuleset},
|
'change_profile': {'ruleset': ChangeProfileRuleset},
|
||||||
@@ -60,7 +62,6 @@ class ProfileStorage:
|
|||||||
data[rule] = ruletypes[rule]['ruleset']()
|
data[rule] = ruletypes[rule]['ruleset']()
|
||||||
|
|
||||||
data['alias'] = dict()
|
data['alias'] = dict()
|
||||||
data['abi'] = []
|
|
||||||
data['include'] = dict()
|
data['include'] = dict()
|
||||||
data['lvar'] = dict()
|
data['lvar'] = dict()
|
||||||
|
|
||||||
@@ -141,7 +142,6 @@ class ProfileStorage:
|
|||||||
|
|
||||||
# "old" write functions for rule types not implemented as *Rule class yet
|
# "old" write functions for rule types not implemented as *Rule class yet
|
||||||
write_functions = {
|
write_functions = {
|
||||||
'abi': write_abi,
|
|
||||||
'alias': write_alias,
|
'alias': write_alias,
|
||||||
'include': write_includes,
|
'include': write_includes,
|
||||||
'lvar': write_list_vars,
|
'lvar': write_list_vars,
|
||||||
@@ -221,17 +221,6 @@ def write_list_vars(ref, depth):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def write_abi(ref, depth):
|
|
||||||
pre = ' ' * depth
|
|
||||||
data = []
|
|
||||||
|
|
||||||
if ref.get('abi'):
|
|
||||||
for line in ref.get('abi'):
|
|
||||||
data.append('%s%s' % (pre, line))
|
|
||||||
data.append('')
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def write_alias(prof_data, depth):
|
def write_alias(prof_data, depth):
|
||||||
pre = ' ' * depth
|
pre = ' ' * depth
|
||||||
data = []
|
data = []
|
||||||
|
@@ -13,7 +13,7 @@ include if exists <tunables/nothing>
|
|||||||
|
|
||||||
|
|
||||||
/usr/bin/a/simple/cleanprof/test/profile {
|
/usr/bin/a/simple/cleanprof/test/profile {
|
||||||
abi "abi/4.20" ,
|
abi "abi/4.20",
|
||||||
|
|
||||||
#include <abstractions/base>
|
#include <abstractions/base>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user