예제 #1
0
    def parse_products_detail(self, buKey, bu, vul, productsContentBlockList):
        bu_prod_block_list = []
        for productsContentBlock in productsContentBlockList:
            bu_prod_block_list = productsContentBlock.find_all('div', itemindex=buKey)
            if len(bu_prod_block_list) != 0:
                break

        if len(bu_prod_block_list) != 0:
            products_table = bu_prod_block_list[0].table
            products_rows = products_table.find_all('tr')
            if len(products_rows) > 0:
                for index in range(1, len(products_rows)):
                    row = products_rows[index]
                    columns = row.find_all('td')
                    product, created = Product.objects.get_or_create(
                        name=StringUtil.normalize(columns[0].get_text()))
                    product.save()

                    bp, created = BUAndProdRelationship.objects.get_or_create(bu=bu, product=product)
                    if created: bp.save()

                    pv, created = ProdAndVulRelationship.objects.get_or_create(product=product, vul=vul)
                    if created:
                        if len(columns) == 2:
                            pv.status = DataConvert.convert_status_to_integer(columns[1].get_text())
                        elif len(columns) == 4:
                            pv.status = DataConvert.convert_status_to_integer(columns[1].get_text())
                            pv.fixedVersion = StringUtil.normalize(columns[2].get_text())
                            pv.downloadLink = StringUtil.normalize(columns[3].get_text(), ep=False)
                        else:
                            pass
                        pv.save()
예제 #2
0
 def test_url_verify_function(self):
     url1 = "www.google.com"
     url2 = "http://www.google.com"
     url3 = "http//www.google.com"
     url4 = "http:/www.google.com"
     self.assertEqual(StringUtil.verifyUrl(url1), False)
     self.assertEqual(StringUtil.verifyUrl(url2), True)
     self.assertEqual(StringUtil.verifyUrl(url3), False)
     self.assertEqual(StringUtil.verifyUrl(url4), False)
예제 #3
0
    def deal_with_bu_info(self, vul, content):
        bu_map = {}
        bu_block_elem = content.find_all(id='NewTileListComponent')
        if bu_block_elem is not None and len(bu_block_elem) > 0:
            for ulElem in bu_block_elem[0].find_all('ul'):
                for liElem in ulElem.find_all('li'):
                    bu, created = BusinessUnit.objects.get_or_create(name=StringUtil.normalize(liElem.get_text()))
                    bu.save()
                    bu_map[StringUtil.normalize(liElem['itemindex'])] = bu

        return bu_map
예제 #4
0
    def parse_tbl_row(self, table_row):
        td_elems = table_row.find_all('td')
        if len(td_elems) == 0: return None

        strs = list(td_elems[0].strings)
        lenovo_code = StringUtil.normalize(strs[0])
        description = StringUtil.normalize(strs[1])

        a_elems = td_elems[0].find_all('a')
        link = self.lenovoSupportHome + a_elems[0]['href']

        firstDate = StringUtil.normalize(td_elems[1].string)
        lastDate = StringUtil.normalize(td_elems[2].string)

        return Vulnerability(lenovoCode=lenovo_code, description=description,
                             link=link, firstPublishedDate=firstDate,
                             lastUpdatedDate=lastDate)