本文整理汇总了Python中setools.MLSRuleQuery类的典型用法代码示例。如果您正苦于以下问题:Python MLSRuleQuery类的具体用法?Python MLSRuleQuery怎么用?Python MLSRuleQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MLSRuleQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_045_range_proper_superset2
def test_045_range_proper_superset2(self):
"""MLS rule query with context range proper superset match (equal)"""
q = MLSRuleQuery(self.p,
default="s45:c1 - s45:c1.c3", default_superset=True, default_proper=True)
r = sorted(q.results())
self.assertEqual(len(r), 0)
示例2: test_020_class
def test_020_class(self):
"""MLS rule query with exact object class match."""
q = MLSRuleQuery(self.p, tclass="infoflow7", tclass_regex=False)
r = sorted(q.results())
self.assertEqual(len(r), 1)
self.validate_rule(r[0], RT.range_transition, "test20", "test20", "infoflow7", "s1")
示例3: test_012_target_direct_regex
def test_012_target_direct_regex(self):
"""MLS rule query with regex, direct, target match."""
q = MLSRuleQuery(
self.p, target="test12a.*", target_regex=True)
r = sorted(q.results())
self.assertEqual(len(r), 1)
self.validate_rule(r[0], RT.range_transition, "test12s", "test12aFAIL", "infoflow", "s2")
示例4: test_001_source_direct
def test_001_source_direct(self):
"""MLS rule query with exact, direct, source match."""
q = MLSRuleQuery(
self.p, source="test1s", source_regex=False)
r = sorted(q.results())
self.assertEqual(len(r), 1)
self.validate_rule(r[0], RT.range_transition, "test1s", "test1t", "infoflow", "s0")
示例5: test_044_range_proper_subset1
def test_044_range_proper_subset1(self):
"""MLS rule query with context range proper subset match"""
q = MLSRuleQuery(self.p, default="s44:c1,c2", default_subset=True, default_proper=True)
r = sorted(q.results())
self.assertEqual(len(r), 1)
self.validate_rule(r[0], RT.range_transition, "test44", "test44", "infoflow",
"s44:c1 - s44:c1.c3")
示例6: test_043_range_superset2
def test_043_range_superset2(self):
"""MLS rule query with context range superset match (equal)"""
q = MLSRuleQuery(self.p, default="s43:c1 - s43:c1.c3", default_superset=True)
r = sorted(q.results())
self.assertEqual(len(r), 1)
self.validate_rule(r[0], RT.range_transition, "test43", "test43", "infoflow",
"s43:c1 - s43:c1.c3")
示例7: test_042_range_subset1
def test_042_range_subset1(self):
"""MLS rule query with context range subset match"""
q = MLSRuleQuery(self.p, default="s42:c1,c2 - s42:c0.c3", default_overlap=True)
r = sorted(q.results())
self.assertEqual(len(r), 1)
self.validate_rule(r[0], RT.range_transition, "test42", "test42", "infoflow",
"s42:c1 - s42:c1.c3")
示例8: test_041_range_overlap5
def test_041_range_overlap5(self):
"""MLS rule query with context range overlap match (overlap high level)"""
q = MLSRuleQuery(self.p, default="s41:c1,c2 - s41:c0.c4", default_overlap=True)
r = sorted(q.results())
self.assertEqual(len(r), 1)
self.validate_rule(r[0], RT.range_transition, "test41", "test41", "infoflow",
"s41:c1 - s41:c1.c3")
示例9: test_040_range_exact
def test_040_range_exact(self):
"""MLS rule query with context range exact match"""
q = MLSRuleQuery(self.p, default="s40:c1 - s40:c0.c4")
r = sorted(q.results())
self.assertEqual(len(r), 1)
self.validate_rule(r[0], RT.range_transition, "test40", "test40", "infoflow",
"s40:c1 - s40:c0.c4")
示例10: test_022_class_regex
def test_022_class_regex(self):
"""MLS rule query with object class regex match."""
q = MLSRuleQuery(self.p, tclass="infoflow(5|6)", tclass_regex=True)
r = sorted(q.results())
self.assertEqual(len(r), 2)
self.validate_rule(r[0], RT.range_transition, "test22", "test22", "infoflow5", "s1")
self.validate_rule(r[1], RT.range_transition, "test22", "test22", "infoflow6", "s2")
示例11: test_014_issue111
def test_014_issue111(self):
"""MLS rule query with attribute target criteria, indirect match."""
# https://github.com/TresysTechnology/setools/issues/111
q = MLSRuleQuery(self.p, target="test14b", target_indirect=True)
r = sorted(q.results())
self.assertEqual(len(r), 2)
self.validate_rule(r[0], RT.range_transition, "test14source", "test14t1", "infoflow", "s1")
self.validate_rule(r[1], RT.range_transition, "test14source", "test14t2", "infoflow7", "s2")
示例12: test_010_target_direct
def test_010_target_direct(self):
"""MLS rule query with exact, direct, target match."""
q = MLSRuleQuery(
self.p, target="test10t", target_regex=False)
r = sorted(q.results())
self.assertEqual(len(r), 2)
self.validate_rule(r[0], RT.range_transition, "test10s", "test10t", "infoflow", "s0")
self.validate_rule(r[1], RT.range_transition, "test10s", "test10t", "infoflow2", "s1")
示例13: test_003_source_direct_regex
def test_003_source_direct_regex(self):
"""MLS rule query with regex, direct, source match."""
q = MLSRuleQuery(
self.p, source="test3(s|aS)", source_regex=True)
r = sorted(q.results())
self.assertEqual(len(r), 2)
self.validate_rule(r[0], RT.range_transition, "test3s", "test3t", "infoflow", "s1")
self.validate_rule(r[1], RT.range_transition, "test3s", "test3t", "infoflow2", "s2")
示例14: test_000_unset
def test_000_unset(self):
"""MLS rule query with no criteria."""
# query with no parameters gets all MLS rules.
rules = sorted(self.p.mlsrules())
q = MLSRuleQuery(self.p)
q_rules = sorted(q.results())
self.assertListEqual(rules, q_rules)
示例15: test_021_class_list
def test_021_class_list(self):
"""MLS rule query with object class list match."""
q = MLSRuleQuery(
self.p, tclass=["infoflow3", "infoflow4"], tclass_regex=False)
r = sorted(q.results())
self.assertEqual(len(r), 2)
self.validate_rule(r[0], RT.range_transition, "test21", "test21", "infoflow3", "s2")
self.validate_rule(r[1], RT.range_transition, "test21", "test21", "infoflow4", "s1")