Example #1
0
def write2file(vinfo):
    print "task======",vinfo
    if vinfo[6]:
        desc=lib_rule.getdesc4cnvd(vinfo[6],'gbk')[1]
    elif vinfo[4]:
        desc=lib_rule.getdesc4cve(vinfo[4])[1]
        desc=lib_rule.transen2zh(desc,'gbk')
    elif vinfo[5]:
        desc=lib_rule.getdesc4bid(vinfo[5])[1]
        desc=lib_rule.transen2zh(desc,'gbk')
    else:
        #printerror("Error in %s" %vinfo[1])
        #exit(0)
        desc=""
    mylock.acquire()
    outinfo.write('@=========================\n')
    outinfo.write('msg:%s\n' %vinfo[0])
    outinfo.write('sid:%s\n' %vinfo[1])
    outinfo.write('gid:%s\n' %vinfo[2])
    outinfo.write('rev:%s\n' %vinfo[3])
    outinfo.write('cve:%s\n' %vinfo[4])
    outinfo.write('bid:%s\n' %vinfo[5])
    outinfo.write('cnvd:%s\n' %vinfo[6])
    outinfo.write('desc:%s\n' %desc)
    mylock.release()
Example #2
0
def opera_crule(rinstan):
    if rinstan.cve and (rinstan.bid=='' or rinstan.desc=='') and (argvs['-gbid'] or argvs['-gauto']):
        bid,desc=lib_rule.getdesc4cve(rinstan.cve)
        if not rinstan.bid:
            rinstan.bid=bid
        rinstan.edesc=desc
    if rinstan.cve and rinstan.cnnvd=='' and argvs['-gauto']:
        cnnvd=lib_rule.getCNNVD(rinstan.cve)
        rinstan.cnnvd=cnnvd
    if (argvs['-gcnvd'] or argvs['-gauto']) and (rinstan.cnvd=="" and rinstan.msg=="") and rinstan.cve:
        cname,cnvd=lib_rule.getCNVD(rinstan.cve)
        rinstan.cname=cname
        rinstan.cnvd=cnvd
    if (argvs['-gauto'] or argvs['-gversion']) and rinstan.version=="" and rinstan.bid:
        ename,version=lib_rule.getversion4bid(rinstan.bid)
        if rinstan.ename=='':
            rinstan.ename=ename
        rinstan.version=version
    if (argvs['-gauto'] and rinstan.desc=="") or argvs['-gdesc']:
        if rinstan.cnvd:
            cname,desc=lib_rule.getdesc4cnvd(rinstan.cnvd)
            rinstan.desc=desc
            if not rinstan.cname:
                rinstan.cname=cname
        if rinstan.desc=='' and rinstan.edesc:
                rinstan.desc=rinstan.edesc
    if (argvs['-gauto'] or argvs['-gmsg']) and rinstan.msg=="":
        if rinstan.cname:
            rinstan.msg=rinstan.cname
        elif rinstan.ename:
            rinstan.msg=rinstan.ename
        elif rinstan.bid:
            ename,version=lib_rule.getversion4bid(rinstan.bid)
            rinstan.msg=ename
    if argvs['-tran'] or argvs['-gauto']:
        if argvs['-tran'] or (not rinstan.cnvd):
            if rinstan.desc:
                rinstan.desc=lib_rule.transen2zh(rinstan.desc)
            if rinstan.msg:
                rinstan.msg=lib_rule.transen2zh(rinstan.msg)
   
    if argvs['-work']=="2":
        rinstan.output(ofile)
    elif argvs['-work']=="1":
        outdata(rinstan)