Commit 593f2b8b authored by PidgeyL's avatar PidgeyL
Browse files

fully implement dblayer in minimal.py

parent 9f559ac0
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -255,20 +255,17 @@ def browse(vendor=None):
@app.route('/search', methods=['POST'])
def searchText():
    search = request.form.get('search')
    collection = db.cves
    try:
        cvelist = db.command("text", "cves", search=search)["results"]
        cve=dbLayer.getFreeText(search)
    except:
        return render_template('error.html', status={'except':'textsearch-not-enabled'})
    cve=[x["obj"] for x in cvelist]
    return render_template('search.html', cve=cve, minimal=True)


@app.route('/search/<vendor>/<path:product>')
def search(vendor=None, product=None):
    collection = db.cves
    search = vendor + ":" + product
    cve = collection.find({"vulnerable_configuration": {'$regex': search}}).sort("Modified", -1)
    cve = dbLayer.cvesForCPE(search)
    return render_template('search.html', vendor=vendor, product=product, cve=cve, minimal=True)

@app.route('/link/<vFeedMap>/<field>/<path:value>')
@@ -278,8 +275,7 @@ def link(vFeedMap=None,field=None,value=None):
    value=htmlDedode(value)
    search="%s.%s"%(vFeedMap,field)
    regex = re.compile(re.escape(value), re.I)
    cveList=[x['id'] for x in db.vfeed.find({search: regex}).sort("Modified",-1)]
    cve = list(db.cves.find({'id':{'$in': cveList}}).sort("Modified",-1))
    cve=dbLayer.vFeedLinked(search, regex)
    cvssList=[float(x['cvss']) for x in cve if 'cvss' in x]
    stats={'maxCVSS': max(cvssList), 'minCVSS': min(cvssList),'count':len(cve)}
    return render_template('linked.html', vFeedMap=vFeedMap, field=field, value=value, cve=cve, stats=stats, minimal=True)