-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
191 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import requests | ||
from requests.exceptions import HTTPError | ||
|
||
|
||
from connectors.credential import Credential | ||
from connector_interface import ConnectorInterface | ||
|
||
|
||
class Connector(ConnectorInterface): | ||
""" | ||
http://cve-search.org/api/ | ||
""" | ||
def __init__(self, credentials): | ||
super().__init__(credentials) | ||
|
||
def search_by_cve_code(self, cve_code): | ||
url = f'{self.cve}{cve_code}' | ||
print(url) | ||
response = requests.get(url) | ||
return response | ||
|
||
def get_last_30_cves(self): | ||
response = requests.get(self.last) | ||
return response | ||
|
||
def get_vendors_list(self): | ||
response = requests.get(self.vendor) | ||
return response | ||
|
||
def get_vendor_products(self, vendor): | ||
url = f'{self.vendor}{vendor}/' | ||
response = requests.get(url) | ||
return response | ||
|
||
def get_product(self, vendor, product): | ||
url = f'{self.vendor}{vendor}/{product}' | ||
response = requests.get(url) | ||
return response | ||
|
||
def get_db_info(self): | ||
response = requests.get(self.db_info) | ||
return response | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
# \sarenka\backend>python connectors\cve_search\connector.py | ||
credentials = Credential().cve_search | ||
connector = Connector(credentials) | ||
print(connector.search_by_cve_code("CVE-2010-3333")) | ||
print(connector.get_last_30_cves()) | ||
print(connector.get_vendors_list()) | ||
print(connector.get_vendor_products("microsoft")) | ||
print(connector.get_product("microsoft","office")) | ||
print(connector.get_db_info()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from typing import Dict, Tuple, Sequence, List, NoReturn | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class ConnectorInterface(ABC): | ||
def __init__(self, credentials): | ||
print(credentials) | ||
self.__base_url = credentials.base_url | ||
self.__cve = credentials.cve | ||
self.__vendor = credentials.vendor | ||
self.__last = credentials.last | ||
self.__db_info = credentials.db_info | ||
|
||
@property | ||
def base_url(self): | ||
return self.__base_url | ||
|
||
@property | ||
def vendor(self): | ||
return self.__vendor | ||
|
||
@property | ||
def cve(self): | ||
return self.__cve | ||
|
||
@property | ||
def db_info(self): | ||
return self.__db_info | ||
|
||
@property | ||
def last(self): | ||
return self.__last | ||
|
||
@abstractmethod | ||
def search_by_cve_code(self, cve_code): | ||
""" | ||
curl https://cve.circl.lu/api/cve/CVE-2010-3333 | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def get_last_30_cves(self): | ||
pass | ||
|
||
@abstractmethod | ||
def get_vendors_list(self): | ||
""" | ||
curl https://cve.circl.lu/api/browse | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def get_vendor_products(self, vendor): | ||
""" | ||
curl https://cve.circl.lu/api/browse/microsoft | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def get_product(self, vendor, product): | ||
""" | ||
curl https://cve.circl.lu/api/search/microsoft/office | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def get_db_info(self): | ||
""" | ||
curl https://cve.circl.lu/api/dbInfo | ||
""" | ||
pass |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters