Commit 5b2a66b9 authored by PidgeyL's avatar PidgeyL
Browse files

replacing dblayer with dblayer2

parent 087286a3
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ def bsonConverter(data=None):
        convertDatetime(val)
      elif isinstance(val, (CWE, CAPEC)):
        data[key] = val.dict()
  elif isinstance(data, CAPEC):
    data = data.dict()
  return data


@@ -69,7 +71,7 @@ class APIError(Exception):

class API():
  app = Flask(__name__, static_folder='static', static_url_path='/static')
  app.config['MONGO_DBNAME'] = Configuration.getMongoDB()
  app.config['MONGO_DBNAME'] = Configuration.getDatabaseName()
  app.config['SECRET_KEY'] = str(random.getrandbits(256))

  def __init__(self):
@@ -115,6 +117,7 @@ class API():
        error = ({'status': 'error', 'reason': 'Internal server error'}, 500)
      # Check if data should be returned as html or data
      try:
        returnType = 'application/json'
        if (request.url_rule.rule.lower().startswith("/api/") or
           request.url_rule.rule.lower().endswith(".json") ):
          # Support JSONP
@@ -227,7 +230,7 @@ class API():
  # /api/capec/<cweid>
  @api
  def api_capec(self, cweid):
    return db.getCAPEC(cweid)
    return self.db.CAPEC.get(cweid)

  # /api/last
  # /api/last/
@@ -284,7 +287,7 @@ class API():
    search = vendor + ":" + product
    # Not using query.cvesForCPE, because that one gives too much info
    #return json.dumps(db.cvesForCPE(search), default=json_util.default)
    return db.cvesForCPE(search)
    return self.db.CVE.forCPE(search)

  # /api/search/<path:search>
  @api