Exemplo n.º 1
0
 def __init__(self, raw_cpe_line):
     from svdb.id.cpe import CPEID
     cpe_n_port = raw_cpe_line.split('|')[1].split('#')
     if CPEID.correct_cpe_str(cpe_n_port[0]):
         self.cpe = cpe_n_port[0]
     try:
         self.port = cpe_n_port[1]
         if self.port is '':
             self.port = None
     except:
         self.port = None
Exemplo n.º 2
0
    def test_cve_should_be_ok(self):
        cpe_str = "CPE:/a:microsoft:ie:8.0.7600.16385"

        self.assertTrue(CPEID.correct_cpe_str(cpe_str))

        cpe = CPEID(cpe_str)

        self.assertEqual(cpe.get_part_info(), "a")
        self.assertEqual(cpe.get_vendor_info(), "microsoft")
        self.assertEqual(cpe.get_product_info(), "ie")
        self.assertEqual(cpe.get_version_info(), "8.0.7600.16385")
        self.assertEqual(cpe.get_edition_info(), "")
        self.assertEqual(cpe.get_language_info(), "")
        self.assertEqual(str(cpe), cpe_str)
Exemplo n.º 3
0
    def test_cve_should_be_ok(self):
        cpe_str = "CPE:/a:microsoft:ie:8.0.7600.16385"

        self.assertTrue(CPEID.correct_cpe_str(cpe_str))

        cpe = CPEID(cpe_str)

        self.assertEqual(cpe.get_part_info(), 'a')
        self.assertEqual(cpe.get_vendor_info(), 'microsoft')
        self.assertEqual(cpe.get_product_info(), 'ie')
        self.assertEqual(cpe.get_version_info(), '8.0.7600.16385')
        self.assertEqual(cpe.get_edition_info(), '')
        self.assertEqual(cpe.get_language_info(), '')
        self.assertEqual(str(cpe), cpe_str)
Exemplo n.º 4
0
 def test_cve_creation_should_not_be_ok_3(self):
     cpe_str = "CPE:/a:microsoft"
     self.assertFalse(CPEID.correct_cpe_str(cpe_str))
     self.assertRaises(ValueError, CPEID, cpe_str)
Exemplo n.º 5
0
 def test_cve_creation_should_not_be_ok_2(self):
     cpe_str = "CPE:/x:microsoft:ie:8.0.7600.16385"
     self.assertFalse(CPEID.correct_cpe_str(cpe_str))
     self.assertRaises(ValueError, CPEID, cpe_str)
Exemplo n.º 6
0
 def test_cve_creation_should_not_be_ok_1(self):
     cpe_str = "CE:/a:microsoft:ie:8.0.7600.16385"
     self.assertFalse(CPEID.correct_cpe_str(cpe_str))
     self.assertRaises(ValueError, CPEID, cpe_str)
Exemplo n.º 7
0
 def test_cve_creation_should_not_be_ok_3(self):
     cpe_str = "CPE:/a:microsoft"
     self.assertFalse(CPEID.correct_cpe_str(cpe_str))
     self.assertRaises(ValueError, CPEID, cpe_str)