本文整理汇总了Python中setools.PermissionMap类的典型用法代码示例。如果您正苦于以下问题:Python PermissionMap类的具体用法?Python PermissionMap怎么用?Python PermissionMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PermissionMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_123_include_perm
def test_123_include_perm(self):
"""PermMap include permission."""
permmap = PermissionMap("tests/perm_map")
permmap.exclude_permission("infoflow", "med_w")
self.validate_permmap_entry(permmap.permmap, 'infoflow', 'med_w', 'w', 5, False)
permmap.include_permission("infoflow", "med_w")
self.validate_permmap_entry(permmap.permmap, 'infoflow', 'med_w', 'w', 5, True)
开发者ID:GitForNeo,项目名称:setools,代码行数:8,代码来源:permmap.py
示例2: test_102_set_weight_low
def test_102_set_weight_low(self):
"""PermMap set weight high"""
permmap = PermissionMap("tests/perm_map")
with self.assertRaises(ValueError):
permmap.set_weight("infoflow2", "low_w", 11)
with self.assertRaises(ValueError):
permmap.set_weight("infoflow2", "low_w", 50)
开发者ID:GitForNeo,项目名称:setools,代码行数:8,代码来源:permmap.py
示例3: test_132_include_class
def test_132_include_class(self):
"""PermMap exclude class."""
permmap = PermissionMap("tests/perm_map")
permmap.exclude_class("file")
self.validate_permmap_entry(permmap.permmap, 'file', 'execute', 'r', 10, False)
self.validate_permmap_entry(permmap.permmap, 'file', 'entrypoint', 'r', 10, False)
permmap.include_class("file")
self.validate_permmap_entry(permmap.permmap, 'file', 'execute', 'r', 10, True)
self.validate_permmap_entry(permmap.permmap, 'file', 'entrypoint', 'r', 10, True)
开发者ID:GitForNeo,项目名称:setools,代码行数:10,代码来源:permmap.py
示例4: test_140_weight_read_only
def test_140_weight_read_only(self):
"""PermMap get weight of read-only rule."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["med_r", "hi_r"])
permmap = PermissionMap("tests/perm_map")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 10)
self.assertEqual(w, 0)
开发者ID:GitForNeo,项目名称:setools,代码行数:11,代码来源:permmap.py
示例5: test_141_weight_write_only
def test_141_weight_write_only(self):
"""PermMap get weight of write-only rule."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["low_w", "med_w"])
permmap = PermissionMap("tests/perm_map")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 0)
self.assertEqual(w, 5)
开发者ID:GitForNeo,项目名称:setools,代码行数:11,代码来源:permmap.py
示例6: test_142_weight_both
def test_142_weight_both(self):
"""PermMap get weight of both rule."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["low_r", "hi_w"])
permmap = PermissionMap("tests/perm_map")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 1)
self.assertEqual(w, 10)
开发者ID:GitForNeo,项目名称:setools,代码行数:11,代码来源:permmap.py
示例7: test_143_weight_none
def test_143_weight_none(self):
"""PermMap get weight of none rule."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow3"
rule.perms = set(["null"])
permmap = PermissionMap("tests/perm_map")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 0)
self.assertEqual(w, 0)
开发者ID:GitForNeo,项目名称:setools,代码行数:11,代码来源:permmap.py
示例8: test_150_map_policy
def test_150_map_policy(self):
"""PermMap create mappings for classes/perms in a policy."""
policy = SELinuxPolicy("tests/permmap.conf")
permmap = PermissionMap("tests/perm_map")
permmap.map_policy(policy)
self.validate_permmap_entry(permmap.permmap, 'infoflow2', 'new_perm', 'u', 1, True)
self.assertIn("new_class", permmap.permmap)
self.assertEqual(1, len(permmap.permmap['new_class']))
self.validate_permmap_entry(permmap.permmap, 'new_class', 'new_class_perm', 'u', 1, True)
开发者ID:GitForNeo,项目名称:setools,代码行数:11,代码来源:permmap.py
示例9: test_147_weight_excluded_permission
def test_147_weight_excluded_permission(self):
"""PermMap get weight of a rule with excluded permission."""
rule = Mock()
rule.ruletype = TERuletype.allow
rule.tclass = "infoflow"
rule.perms = set(["med_r", "hi_r"])
permmap = PermissionMap("tests/perm_map")
permmap.exclude_permission("infoflow", "hi_r")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 5)
self.assertEqual(w, 0)
开发者ID:TresysTechnology,项目名称:setools,代码行数:12,代码来源:permmap.py
示例10: test_148_weight_excluded_class
def test_148_weight_excluded_class(self):
"""PermMap get weight of a rule with excluded class."""
rule = Mock()
rule.ruletype = "allow"
rule.tclass = "infoflow"
rule.perms = set(["low_r", "med_r", "hi_r", "low_w", "med_w", "hi_w"])
permmap = PermissionMap("tests/perm_map")
permmap.exclude_class("infoflow")
r, w = permmap.rule_weight(rule)
self.assertEqual(r, 0)
self.assertEqual(w, 0)
开发者ID:GitForNeo,项目名称:setools,代码行数:12,代码来源:permmap.py
示例11: load_permmap
def load_permmap(self, filename=None):
try:
self._permmap = PermissionMap(filename)
except Exception as ex:
self.log.critical("Failed to load default permission map: {0}".format(ex))
self.error_msg.critical(self, "Permission map loading error", str(ex))
else:
if self._policy:
self._permmap.map_policy(self._policy)
self.apply_permmap()
开发者ID:TresysTechnology,项目名称:setools,代码行数:10,代码来源:mainwindow.py
示例12: select_permmap
def select_permmap(self):
filename = QFileDialog.getOpenFileName(self, "Open permission map file", ".")[0]
if filename:
try:
self._permmap = PermissionMap(filename)
except Exception as ex:
self.error_msg.critical(self, "Permission map loading error", str(ex))
else:
if self._policy:
self._permmap.map_policy(self._policy)
开发者ID:stevedlawrence,项目名称:setools,代码行数:11,代码来源:mainwindow.py
示例13: __init__
def __init__(self, filename):
super(ApolMainWindow, self).__init__()
self.log = logging.getLogger(__name__)
if filename:
self._policy = SELinuxPolicy(filename)
else:
self._policy = None
try:
# try to load default permission map
self._permmap = PermissionMap()
except (IOError, OSError) as ex:
self.log.info("Failed to load default permission map: {0}".format(ex))
self._permmap = None
self.setupUi()
开发者ID:stevedlawrence,项目名称:setools,代码行数:17,代码来源:mainwindow.py
示例14: ApolMainWindow
class ApolMainWindow(SEToolsWidget, QMainWindow):
def __init__(self, filename):
super(ApolMainWindow, self).__init__()
self.log = logging.getLogger(__name__)
if filename:
self._policy = SELinuxPolicy(filename)
else:
self._policy = None
try:
# try to load default permission map
self._permmap = PermissionMap()
except (IOError, OSError) as ex:
self.log.info("Failed to load default permission map: {0}".format(ex))
self._permmap = None
self.setupUi()
def setupUi(self):
self.load_ui("apol.ui")
self.tab_counter = 0
self.update_window_title()
# set up error message dialog
self.error_msg = QMessageBox(self)
self.error_msg.setStandardButtons(QMessageBox.Ok)
# set up tab name editor
self.tab_editor = QLineEdit(self.AnalysisTabs)
self.tab_editor.setWindowFlags(Qt.Popup)
# configure tab bar context menu
tabBar = self.AnalysisTabs.tabBar()
tabBar.addAction(self.rename_tab_action)
tabBar.addAction(self.close_tab_action)
tabBar.setContextMenuPolicy(Qt.ActionsContextMenu)
# capture INFO and higher Python messages from setools lib for status bar
handler = LogHandlerToSignal()
handler.message.connect(self.statusbar.showMessage)
logging.getLogger("setools").addHandler(handler)
logging.getLogger("setoolsgui").addHandler(handler)
# connect signals
self.open_policy.triggered.connect(self.select_policy)
self.open_permmap.triggered.connect(self.select_permmap)
self.new_analysis.triggered.connect(self.choose_analysis)
self.AnalysisTabs.tabCloseRequested.connect(self.close_tab)
self.AnalysisTabs.tabBarDoubleClicked.connect(self.tab_name_editor)
self.tab_editor.editingFinished.connect(self.rename_tab)
self.rename_tab_action.triggered.connect(self.rename_active_tab)
self.close_tab_action.triggered.connect(self.close_active_tab)
self.copy_action.triggered.connect(self.copy)
self.cut_action.triggered.connect(self.cut)
self.paste_action.triggered.connect(self.paste)
self.show()
def update_window_title(self):
if self._policy:
self.setWindowTitle("{0} - apol".format(self._policy))
else:
self.setWindowTitle("apol")
def select_policy(self):
filename = QFileDialog.getOpenFileName(self, "Open policy file", ".")[0]
if filename:
try:
self._policy = SELinuxPolicy(filename)
except Exception as ex:
self.error_msg.critical(self, "Policy loading error", str(ex))
else:
self.update_window_title()
if self._permmap:
self._permmap.map_policy(self._policy)
def select_permmap(self):
filename = QFileDialog.getOpenFileName(self, "Open permission map file", ".")[0]
if filename:
try:
self._permmap = PermissionMap(filename)
except Exception as ex:
self.error_msg.critical(self, "Permission map loading error", str(ex))
else:
if self._policy:
self._permmap.map_policy(self._policy)
def choose_analysis(self):
if not self._policy:
self.error_msg.critical(self, "No open policy",
"Cannot start a new analysis. Please open a policy first.")
self.select_policy()
#.........这里部分代码省略.........
开发者ID:stevedlawrence,项目名称:setools,代码行数:101,代码来源:mainwindow.py
示例15: ApolMainWindow
class ApolMainWindow(SEToolsWidget, QMainWindow):
def __init__(self, filename):
super(ApolMainWindow, self).__init__()
self.log = logging.getLogger(__name__)
self._permmap = None
self._policy = None
self.setupUi()
self.load_permmap()
if filename:
self.load_policy(filename)
if self._policy:
self.create_new_analysis("Summary", SummaryTab)
self.update_window_title()
def setupUi(self):
self.load_ui("apol.ui")
self.tab_counter = 0
# set up analysis menu
self.chooser = ChooseAnalysis(self)
# set up error message dialog
self.error_msg = QMessageBox(self)
self.error_msg.setStandardButtons(QMessageBox.Ok)
# set up permission map editor
self.permmap_editor = PermissionMapEditor(self, True)
# set up tab name editor
self.tab_editor = QLineEdit(self.AnalysisTabs)
self.tab_editor.setWindowFlags(Qt.Popup)
# configure tab bar context menu
tabBar = self.AnalysisTabs.tabBar()
tabBar.addAction(self.rename_tab_action)
tabBar.addAction(self.close_tab_action)
tabBar.setContextMenuPolicy(Qt.ActionsContextMenu)
# capture INFO and higher Python messages from setools lib for status bar
handler = LogHandlerToSignal()
handler.message.connect(self.statusbar.showMessage)
logging.getLogger("setools").addHandler(handler)
logging.getLogger("setoolsgui").addHandler(handler)
# set up help browser process
self.help_process = QProcess()
# connect signals
self.open_policy.triggered.connect(self.select_policy)
self.close_policy_action.triggered.connect(self.close_policy)
self.open_permmap.triggered.connect(self.select_permmap)
self.new_analysis.triggered.connect(self.choose_analysis)
self.AnalysisTabs.tabCloseRequested.connect(self.close_tab)
self.AnalysisTabs.tabBarDoubleClicked.connect(self.tab_name_editor)
self.tab_editor.editingFinished.connect(self.rename_tab)
self.rename_tab_action.triggered.connect(self.rename_active_tab)
self.close_tab_action.triggered.connect(self.close_active_tab)
self.copy_action.triggered.connect(self.copy)
self.cut_action.triggered.connect(self.cut)
self.paste_action.triggered.connect(self.paste)
self.edit_permmap_action.triggered.connect(self.edit_permmap)
self.save_permmap_action.triggered.connect(self.save_permmap)
self.about_apol_action.triggered.connect(self.about_apol)
self.apol_help_action.triggered.connect(self.apol_help)
self.show()
def update_window_title(self):
if self._policy:
self.setWindowTitle("{0} - apol".format(self._policy))
else:
self.setWindowTitle("apol")
#
# Policy handling
#
def select_policy(self):
old_policy = self._policy
if old_policy and self.AnalysisTabs.count() > 0:
reply = QMessageBox.question(
self, "Continue?",
"Loading a policy will close all existing analyses. Continue?",
QMessageBox.Yes | QMessageBox.No)
if reply == QMessageBox.No:
return
filename = QFileDialog.getOpenFileName(self, "Open policy file", ".",
"SELinux Policies (policy.* sepolicy);;"
"All Files (*)")[0]
if filename:
self.load_policy(filename)
#.........这里部分代码省略.........
开发者ID:jakev,项目名称:setools,代码行数:101,代码来源:mainwindow.py
示例16: test_133_include_class_unmapped_class
def test_133_include_class_unmapped_class(self):
"""PermMap include class unmapped class."""
permmap = PermissionMap("tests/perm_map")
with self.assertRaises(UnmappedClass):
permmap.include_class("UNMAPPED")
开发者ID:GitForNeo,项目名称:setools,代码行数:5,代码来源:permmap.py
示例17: ApolMainWindow
class ApolMainWindow(SEToolsWidget, QMainWindow):
def __init__(self, filename):
super(ApolMainWindow, self).__init__()
self.log = logging.getLogger(__name__)
self._permmap = None
self._policy = None
self.setupUi()
self.load_permmap()
if filename:
self.load_policy(filename)
if self._policy:
self.create_new_analysis("Summary", SummaryTab)
self.update_window_title()
self.toggle_workspace_actions()
def setupUi(self):
self.load_ui("apol/apol.ui")
self.tab_counter = 0
# set up analysis menu
self.chooser = ChooseAnalysis(self)
# set up error message dialog
self.error_msg = QMessageBox(self)
self.error_msg.setStandardButtons(QMessageBox.Ok)
# set up permission map editor
self.permmap_editor = PermissionMapEditor(self, True)
# set up tab name editor
self.tab_editor = QLineEdit(self.AnalysisTabs)
self.tab_editor.setWindowFlags(Qt.Popup)
# configure tab bar context menu
tabBar = self.AnalysisTabs.tabBar()
tabBar.addAction(self.rename_tab_action)
tabBar.addAction(self.close_tab_action)
tabBar.setContextMenuPolicy(Qt.ActionsContextMenu)
# capture INFO and higher Python messages from setools lib for status bar
handler = LogHandlerToSignal()
handler.message.connect(self.statusbar.showMessage)
logging.getLogger("setools").addHandler(handler)
logging.getLogger("setoolsgui").addHandler(handler)
# set up help browser process
self.help_process = QProcess()
# connect signals
self.open_policy.triggered.connect(self.select_policy)
self.close_policy_action.triggered.connect(self.close_policy)
self.open_permmap.triggered.connect(self.select_permmap)
self.new_analysis.triggered.connect(self.choose_analysis)
self.AnalysisTabs.currentChanged.connect(self.toggle_workspace_actions)
self.AnalysisTabs.tabCloseRequested.connect(self.close_tab)
self.AnalysisTabs.tabBarDoubleClicked.connect(self.tab_name_editor)
self.tab_editor.editingFinished.connect(self.rename_tab)
self.rename_tab_action.triggered.connect(self.rename_active_tab)
self.close_tab_action.triggered.connect(self.close_active_tab)
self.new_from_settings_action.triggered.connect(self.new_analysis_from_config)
self.load_settings_action.triggered.connect(self.load_settings)
self.save_settings_action.triggered.connect(self.save_settings)
self.load_workspace_action.triggered.connect(self.load_workspace)
self.save_workspace_action.triggered.connect(self.save_workspace)
self.copy_action.triggered.connect(self.copy)
self.cut_action.triggered.connect(self.cut)
self.paste_action.triggered.connect(self.paste)
self.edit_permmap_action.triggered.connect(self.edit_permmap)
self.save_permmap_action.triggered.connect(self.save_permmap)
self.about_apol_action.triggered.connect(self.about_apol)
self.apol_help_action.triggered.connect(self.apol_help)
self.show()
def update_window_title(self):
if self._policy:
self.setWindowTitle("{0} - apol".format(self._policy))
else:
self.setWindowTitle("apol")
#
# Policy handling
#
def select_policy(self):
old_policy = self._policy
if old_policy and self.AnalysisTabs.count() > 0:
reply = QMessageBox.question(
self, "Continue?",
"Loading a policy will close all existing analyses. Continue?",
QMessageBox.Yes | QMessageBox.No)
if reply == QMessageBox.No:
return
#.........这里部分代码省略.........
开发者ID:TresysTechnology,项目名称:setools,代码行数:101,代码来源:mainwindow.py
示例18: test_104_set_weight_unmapped_permission
def test_104_set_weight_unmapped_permission(self):
"""PermMap set weight unmapped class"""
permmap = PermissionMap("tests/perm_map")
with self.assertRaises(UnmappedPermission):
permmap.set_weight("infoflow2", "UNMAPPED", 10)
开发者ID:GitForNeo,项目名称:setools,代码行数:5,代码来源:permmap.py
示例19: test_124_include_perm_unmapped_class
def test_124_include_perm_unmapped_class(self):
"""PermMap include permission unmapped class."""
permmap = PermissionMap("tests/perm_map")
with self.assertRaises(UnmappedClass):
permmap.include_permission("UNMAPPED", "med_w")
开发者ID:GitForNeo,项目名称:setools,代码行数:5,代码来源:permmap.py
示例20: test_100_set_weight
def test_100_set_weight(self):
"""PermMap set weight"""
permmap = PermissionMap("tests/perm_map")
self.validate_permmap_entry(permmap.permmap, 'infoflow2', 'low_w', 'w', 1, True)
permmap.set_weight("infoflow2", "low_w", 10)
self.validate_permmap_entry(permmap.permmap, 'infoflow2', 'low_w', 'w', 10, True)
开发者ID:GitForNeo,项目名称:setools,代码行数:6,代码来源:permmap.py
注:本文中的setools.PermissionMap类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论