Пример #1
0
 def test_parse_policy(self):
     raw = """alert TCP $HOME_NET any -> $EXTERNAL_NET any (msg:"TEST rule"; flow:established,to_server; metadata:policy balanced-ips alert, policy security-ips drop, service http; sid:999999; rev:1;)"""
     rule = rules.parse_rule(raw)
     self.assertTrue("balanced-ips" in rule.policies)
     self.assertEquals("alert", rule.policies["balanced-ips"])
     self.assertTrue("security-ips" in rule.policies)
     self.assertEquals("drop", rule.policies["security-ips"])
Пример #2
0
    def export_rulefile(self, filename, dst):
        print("# Merged from %s by ruleman" % (filename), file=self.merged)
        for line in io.BytesIO(self.files[filename]):
            rule = rules.parse_rule(line)
            if rule:
                print(self.rule_map[rule.key], file=dst)
                print(self.rule_map[rule.key], file=self.merged)
            else:
                print(line.rstrip(), file=dst)
                print(line.rstrip(), file=self.merged)

        # Add a blank lines between merged files.
        print("", file=self.merged)
Пример #3
0
 def setUp(self):
     self.test_rule0 = rules.parse_rule(self.test_rule0_raw)