Commit d1974e20 authored by Alexandre Dulaunoy's avatar Alexandre Dulaunoy
Browse files

Merge pull request #136 from adulau/master

vfeed fixes
parents be2446a1 483f2aa6
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -241,14 +241,22 @@ def getFreeText(text):
def getSearchResults(search):
  result={'data':[]}
  regSearch = re.compile(re.escape(search), re.I)
  vFeedLinks=['map_cve_ms.msid', 'map_cve_redhat.redhatid',
              'map_redhat_bugzilla.redhatid', 'map_cve_ubuntu.ubuntuid',
              'map_cve_suse.suseid', 'map_cve_fedora.fedoraid', 'map_cve_hp.hpid',
              'map_cve_cisco.ciscoid']
  threat=  {'n': 'Threat',   'd': sanitize(colMISP.find({'threats': {'$in': [regSearch]}}))}
  misp_tag={'n': 'MISP tag', 'd': sanitize(colMISP.find({'tags':    {'$in': [regSearch]}}))}
  links =  {'n': 'Link',     'd': []}
  for vLink in vFeedLinks:
    links['d'].extend(sanitize(colVFEED.find({vLink: {'$in': [regSearch]}})))
  
  try:
    textsearch={'n': 'Text search', 'd': getFreeText(search)}
  except:
    textsearch={'n': 'Text search', 'd': []}
    result['errors']=['textsearch']
  for collection in [threat, misp_tag, textsearch]:
  for collection in [threat, misp_tag, textsearch, links]:
    for item in collection['d']:
      # Check if already in result data
      if not any(item['id']==entry['id'] for entry in result['data']):