コード例 #1
0
 def test_get_yara_meta_entry(self):
     yara_meta_entry = YaraMetaEntry("test_name", "test_value", 0)
     yara_meta_entry.yara_comment.inline = "test_inline_comment"
     pod_yara_meta_entry = yara_meta_entry.get_yara_meta_entry()
     self.assertEqual(pod_yara_meta_entry["name"], "test_name")
     self.assertEqual(pod_yara_meta_entry["value"], "test_value")
     self.assertEqual(pod_yara_meta_entry["position"], 0)
     self.assertEqual(pod_yara_meta_entry["meta_type"], "text")
     self.assertEqual(pod_yara_meta_entry["comment"]["inline"],
                      "test_inline_comment")
コード例 #2
0
 def test_set_yara_meta_entry(self):
     yara_meta_entry = YaraMetaEntry(None, None, None)
     yara_comment = {"inline": "test_inline_comment"}
     yara_meta_entry.set_yara_meta_entry({
         "name": "test_name",
         "value": "test_value",
         "position": 0,
         "meta_type": "text",
         "comment": yara_comment,
     })
     self.assertEqual(yara_meta_entry.name, "test_name")
     self.assertEqual(yara_meta_entry.value, "test_value")
     self.assertEqual(yara_meta_entry.position, 0)
     self.assertEqual(yara_meta_entry.yara_comment.inline,
                      "test_inline_comment")
コード例 #3
0
    def test_build_meta_entry_bool(self):
        yara_meta_entry = YaraMetaEntry("test_name", True, 0, meta_type="bool")
        yara_meta_entry.build_meta_entry()
        self.assertEqual(yara_meta_entry.raw_meta_entry, "test_name = true")

        yara_meta_entry = YaraMetaEntry("test_name",
                                        False,
                                        0,
                                        meta_type="bool")
        yara_meta_entry.build_meta_entry()
        self.assertEqual(yara_meta_entry.raw_meta_entry, "test_name = false")
コード例 #4
0
 def test_set_yara_meta_entry_invalid_keys(self):
     yara_meta_entry = YaraMetaEntry(None, None, None)
     self.assertRaises(KeyError, yara_meta_entry.set_yara_meta_entry,
                       {"invalid_key": "test"})
コード例 #5
0
 def test_build_meta_entry_int(self):
     yara_meta_entry = YaraMetaEntry("test_name", 10, 0, meta_type="int")
     yara_meta_entry.build_meta_entry()
     self.assertEqual(yara_meta_entry.raw_meta_entry, "test_name = 10")
コード例 #6
0
 def test_build_meta_entry_text(self):
     yara_meta_entry = YaraMetaEntry("test_name", "test_value", 0)
     yara_meta_entry.build_meta_entry()
     self.assertEqual(yara_meta_entry.raw_meta_entry,
                      'test_name = "test_value"')
コード例 #7
0
 def test_yara_meta_entry_constructor(self):
     yara_meta_entry = YaraMetaEntry("test_name", "test_value", 0)
     self.assertEqual(yara_meta_entry.name, "test_name")
     self.assertEqual(yara_meta_entry.value, "test_value")
     self.assertEqual(yara_meta_entry.position, 0)