Esempio n. 1
0
 def test_load_section_with_xforms(self):
     xforms = {"int-value": int,
               "a list of strings": config.xform_stringlist}
     section = config.get_section("load section test", xforms=xforms)
     self.assertEquals(int, type(section["int-value"]))
     self.assertEquals(list, type(section["a list of strings"]))
     self.assertEquals(3, len(section["a list of strings"]))
     self.assertEquals("one", section["a list of strings"][0])
Esempio n. 2
0
 def test_load_section_bool_xform(self):
     xforms = {"bool-yes": config.xform_bool,
               "bool-no": config.xform_bool,
               "bool-one": config.xform_bool,
               "bool-zero": config.xform_bool,
               "bool-true": config.xform_bool,
               "bool-false": config.xform_bool,
               }
     section = config.get_section("load section test", xforms=xforms)
     self.assertTrue(section["bool-yes"])
     self.assertFalse(section["bool-no"])
     self.assertTrue(section["bool-one"])
     self.assertFalse(section["bool-zero"])
     self.assertTrue(section["bool-true"])
     self.assertFalse(section["bool-false"])
Esempio n. 3
0
 def run(self):
     if not self.init_args():
         return 1
     try:
         snort_config = config.get_section("snort")
     except configparser.NoSectionError:
         logger.error(
             "Snort not configured.  Unabled to dump dynamic rules.")
         return 1;
     ruleset_filename = "./rulesets/%s/ruleset.tar.gz" % (self.ruleset_name)
     if not os.path.exists(ruleset_filename):
         logger.error("Error: Ruleset %s has no files." % (
                 self.ruleset_name))
     if not os.path.exists(self.output):
         logger.info("Creating directory %s." % (self.output))
         os.makedirs(self.output)
     if not snort.dump_stubs(
         ruleset_filename, snort_config["path"], 
         snort_config["dynamic-engine"], snort_config["os-type"],
         dest_dir=self.output, verbose=True):
         logger.error("Failed to dump dynamic rule stubs.")
         return 1
     logger.info("Dynamic rule stubs dumped to %s." % (self.output))
Esempio n. 4
0
 def test_load_section_basic(self):
     section = config.get_section("load section test")
     self.assertEquals("some string value", section["string"])