7fcbf3e1e8b59897042e01c8c07236ce7bc4c010,sbin/db_mgmt_ms.py,,,#,23

Before Change


    sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(msbulletinurl))

// check modification date
i = info.find_one({"db": "ms"})
if i is not None:
    if f.headers["last-modified"] == i["last-modified"]:
        print("Not modified")
        sys.exit(0)

if not os.path.exists(tmppath):
    os.mkdir(tmppath)
with open(tmppath+"/BulletinSearch.xlsx", "wb") as fp:
    shutil.copyfileobj(f, fp)
fp.close()
     
// parse xlsx and store in database
wb = xlrd.open_workbook(tmppath+"/BulletinSearch.xlsx")
sh = wb.sheet_by_name("Bulletin Search")
header = [s.replace("\n", " ") for s in sh.row_values(0)]
bulletin = {}
software = {}
prev_id = ""

for rownum in range(sh.nrows-1):    
    row =  sh.row_values(rownum + 1)
    if row[1] == prev_id:
        software = {}
        software["product"] = row[6]
        software["KB"] = str(row[7]).strip(".0")
        software["component"] = row[8]
        software["impact"] = row[9]
        software["severity"] = row[10]        
        software["replace_id"] = row[11][:8]
        software["replace_bk"] = row[11][9:-1]
        software["reeboot"] = row[12]
        bulletin["software"].append(software)
    else:
        if bulletin :
            msbulletin.update({"id": bulletin["id"]}, {"$set": bulletin}, upsert=True)
        bulletin = {}
        software = {}
        bulletin["Published"] = minimalist_xldate_as_datetime(row[0], 0).isoformat()
        bulletin["id"] = row[1]
        bulletin["KB"] = str(row[2]).strip(".0")
        bulletin["severity"] = row[3]
        bulletin["impact"] = row[4]
        bulletin["title"] = row[5]
        software["product"] = row[6]
        software["KB"] = str(row[7]).strip(".0")
        software["component"] = row[8]
        software["impact"] = row[9]
        software["severity"] = row[10]
        software["replace_id"] = row[11][:8]
        software["replace_bk"] = row[11][9:-1]
        software["reeboot"] = row[12]
        bulletin["CVE"] = row[13].split(",")
        bulletin["software"] = [software]
        bulletin["url"] = bulletinurl + row[1].lower()
        
        prev_id = row[1]

//update database info after successful program-run
info.update({"db": "ms"}, {"$set": {"last-modified": f.headers["last-modified"]}}, upsert=True)
// shutil.rmtree("./tmp")


After Change


    sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(msbulletinurl))

// check modification date
i=dbLayer.getInfo("ms")
if i is not None:
    if f.headers["last-modified"] == i["last-modified"]:
        print("Not modified")
        sys.exit(0)

if not os.path.exists(tmppath):
    os.mkdir(tmppath)
with open(tmppath+"/BulletinSearch.xlsx", "wb") as fp:
    shutil.copyfileobj(f, fp)
fp.close()
     
// parse xlsx and store in database
wb = xlrd.open_workbook(tmppath+"/BulletinSearch.xlsx")
sh = wb.sheet_by_name("Bulletin Search")
header = [s.replace("\n", " ") for s in sh.row_values(0)]
bulletin = {}
software = {}
prev_id = ""

for rownum in range(sh.nrows-1):    
    row =  sh.row_values(rownum + 1)
    if row[1] == prev_id:
        software = {}
        software["product"] = row[6]
        software["KB"] = str(row[7]).strip(".0")
        software["component"] = row[8]
        software["impact"] = row[9]
        software["severity"] = row[10]        
        software["replace_id"] = row[11][:8]
        software["replace_bk"] = row[11][9:-1]
        software["reeboot"] = row[12]
        bulletin["software"].append(software)
    else:
        if bulletin :
            dbLayer.updateMSBulletin(bulletin)
        bulletin = {}
        software = {}
        bulletin["Published"] = minimalist_xldate_as_datetime(row[0], 0).isoformat()
        bulletin["id"] = row[1]
        bulletin["KB"] = str(row[2]).strip(".0")
        bulletin["severity"] = row[3]
        bulletin["impact"] = row[4]
        bulletin["title"] = row[5]
        software["product"] = row[6]
        software["KB"] = str(row[7]).strip(".0")
        software["component"] = row[8]
        software["impact"] = row[9]
        software["severity"] = row[10]
        software["replace_id"] = row[11][:8]
        software["replace_bk"] = row[11][9:-1]
        software["reeboot"] = row[12]
        bulletin["CVE"] = row[13].split(",")
        bulletin["software"] = [software]
        bulletin["url"] = bulletinurl + row[1].lower()
        
        prev_id = row[1]

//update database info after successful program-run
dbLayer.setColUpdate("ms", f.headers["last-modified"])
// shutil.rmtree("./tmp")


Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 11

Instances


Project Name: cve-search/cve-search
Commit Name: 7fcbf3e1e8b59897042e01c8c07236ce7bc4c010
Time: 2015-09-25
Author: pieterjan.moreels@gmail.com
File Name: sbin/db_mgmt_ms.py
Class Name:
Method Name:


Project Name: cve-search/cve-search
Commit Name: f59302d0d8aafc18d42d0e56e8c8a1d9b30f5af6
Time: 2015-10-21
Author: pieterjan.moreels@gmail.com
File Name: sbin/db_mgmt_vendorstatements.py
Class Name:
Method Name:


Project Name: cve-search/cve-search
Commit Name: 7fcbf3e1e8b59897042e01c8c07236ce7bc4c010
Time: 2015-09-25
Author: pieterjan.moreels@gmail.com
File Name: sbin/db_mgmt_ms.py
Class Name:
Method Name:


Project Name: cve-search/cve-search
Commit Name: f59302d0d8aafc18d42d0e56e8c8a1d9b30f5af6
Time: 2015-10-21
Author: pieterjan.moreels@gmail.com
File Name: sbin/db_mgmt_exploitdb.py
Class Name:
Method Name: