Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
P-T-I committed Dec 19, 2023
1 parent 78c9f8a commit 52acf55
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
13 changes: 10 additions & 3 deletions bin/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,9 @@ def search_in_summary(item):

# Search text in summary
if summary_text:
listCve = searchCVE(find_params={"summary": re.compile(summary_text, re.IGNORECASE)}, limit=nlimit)
listCve = searchCVE(
find_params={"summary": re.compile(summary_text, re.IGNORECASE)}, limit=nlimit
)
for item in listCve:
item = cves.getCveFromMongoDbDoc(item)

Expand All @@ -527,11 +529,16 @@ def search_in_summary(item):
# print(type (item['published']))
# print("Last n day " +str(last_ndays))
try:
if datetime.strptime(item["published"], "%Y-%m-%d %H:%M:%S.%f") > date_n_days_ago:
if (
datetime.strptime(item["published"], "%Y-%m-%d %H:%M:%S.%f")
> date_n_days_ago
):
if vOutput:
printCVE_id(item)
else:
print(json.dumps(item, sort_keys=True, default=json_util.default))
print(
json.dumps(item, sort_keys=True, default=json_util.default)
)
except:
pass
if htmlOutput:
Expand Down
6 changes: 5 additions & 1 deletion lib/CVEs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ def getCveFromMongoDbDoc(self, cve_doc):
return cve_doc

def getcve(self, cveid=None):
return None if cveid is None else self.getCveFromMongoDbDoc(getCVE(cveid, collection=self.collection))
return (
None
if cveid is None
else self.getCveFromMongoDbDoc(getCVE(cveid, collection=self.collection))
)

def getranking(self, cpeid=None, loosy=True):
from lib.DatabaseLayer import (
Expand Down
9 changes: 6 additions & 3 deletions lib/DatabaseLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,14 @@ def getCVEIDs(limit=-1):
for x in colCVE.find().limit(limit).sort("modified", pymongo.DESCENDING)
]


def searchCVE(find_params=None, limit=-1):
return colCVE \
.find({} if find_params is None else find_params) \
.limit(limit) \
return (
colCVE.find({} if find_params is None else find_params)
.limit(limit)
.sort("modified", pymongo.DESCENDING)
)


def getCVE(id, collection=None):
col = colCVE if not collection else db[collection]
Expand Down
1 change: 1 addition & 0 deletions web/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ACCESS_EXPIRES = timedelta(minutes=15)
REFRESH_EXPIRES = timedelta(days=30)


def create_app(version, run_path):
global app, token_blacklist, oidcClient, config

Expand Down

0 comments on commit 52acf55

Please sign in to comment.