def get_schema_writer(): indexpath = Configuration.getIndexdir() if not os.path.exists(indexpath): os.mkdir(indexpath) if not exists_in(indexpath): schema = Schema(title=TEXT(stored=True), path=ID(stored=True, unique=True), content=TEXT) ix = create_in(indexpath, schema) else: ix = open_dir(indexpath) try: return ix.writer() except: print("Index is locked. Another db_fulltext process running?") sys.exit(1)
import os from whoosh import index from whoosh.fields import Schema, TEXT, ID from whoosh.qparser import QueryParser import sys import argparse import json from bson import json_util runPath = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(runPath, "..")) from lib.Config import Configuration indexpath = Configuration.getIndexdir() schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT) ix = index.open_dir("indexdir") argParser = argparse.ArgumentParser(description='Full text search for cve-search') argParser.add_argument('-q', action='append', help='query to lookup (one or more)') argParser.add_argument('-t', action='store_true', help='output title of the match CVE(s)') argParser.add_argument('-f', action='store_true', help='output matching CVE(s) in JSON') argParser.add_argument('-m', type=int, default=False, help='most frequent terms in CVE description (m is top-m values)') argParser.add_argument('-l', action='store_true', default=False, help='dump all terms encountered in CVE description') argParser.add_argument('-g', action='store_true', default=False, help='graph of most frequent terms with each matching CVE (JSON output)') argParser.add_argument('-s', action='store_true', default=False, help='enable stemming on graph JSON output (default is False)') argParser.add_argument('-n', action='store_true', help='lookup complete cpe (Common Platform Enumeration) name for vulnerable configuration') argParser.add_argument('-r', action='store_true', help='lookup ranking of vulnerable configuration')
import os from whoosh import index, qparser from whoosh.fields import Schema, TEXT, ID from whoosh.qparser import QueryParser import sys import argparse import json from bson import json_util runPath = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(runPath, "..")) from lib.Config import Configuration indexpath = Configuration.getIndexdir() #basepath = os.path.join(os.sep, *os.path.dirname(os.path.realpath(__file__)).rsplit('/')[:-1]) #print (os.path.split(os.path.join(basepath,indexpath))) schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT) ix = index.open_dir(indexpath) argParser = argparse.ArgumentParser( description='Full text search for cve-search') argParser.add_argument('-q', action='append', help='query to lookup (one or more)') argParser.add_argument('-o', action='store_true', help='OR of the query to lookup (default is AND')