Skip to content

Commit 56d5945

Browse files
committed
new: CAPEC / CWE Endpoints, check system status calls
Fix #75
1 parent b8bee4c commit 56d5945

File tree

1 file changed

+57
-8
lines changed

1 file changed

+57
-8
lines changed

pyvulnerabilitylookup/api.py

+57-8
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,40 @@ def is_up(self) -> bool:
6565
return False
6666
return r.status_code == 200
6767

68-
def redis_up(self) -> bool:
69-
'''Check if redis is up and running'''
70-
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'system', 'redis_up'))))
68+
# #### DB & system status ####
69+
70+
def check_process(self) -> dict[str, Any]:
71+
'''[Authentication Required] Checks the hearbeats of the various processes.'''
72+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('system', 'checkProcess'))))
73+
return r.json()
74+
75+
def check_smtp(self) -> dict[str, Any]:
76+
'''[Authentication Required] Checks the SMTP connection.'''
77+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('system', 'checkSMTP'))))
7178
return r.json()
7279

73-
# #### DB status ####
80+
def get_config_info(self) -> dict[str, Any]:
81+
'''Returns non-sensitive information about the configuration of the system.'''
82+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'system', 'configInfo'))))
83+
return r.json()
7484

7585
def get_info(self) -> dict[str, Any]:
76-
'''Get more information about the current databases in use and when it was updated'''
86+
'''Returns information about the current sources in the Kvrocks database in use and when it was updated.'''
7787
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'system', 'dbInfo'))))
7888
return r.json()
7989

80-
def get_config_info(self) -> dict[str, Any]:
81-
'''Get more information about the current databases in use and when it was updated'''
82-
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'system', 'configInfo'))))
90+
def get_pg_info(self) -> dict[str, Any]:
91+
'''[Authentication Required] Returns information about the PostgreSQL database.'''
92+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'system', 'pgInfo'))))
93+
return r.json()
94+
95+
def redis_up(self) -> bool:
96+
'''[Deprecated] Check if redis/valkey is up and running'''
97+
return self.valkey_up()
98+
99+
def valkey_up(self) -> bool:
100+
'''Check if valkey is up and running'''
101+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'system', 'redis_up'))))
83102
return r.json()
84103

85104
# #### Vulnerabilities ####
@@ -432,3 +451,33 @@ def get_epss(self, vulnerability: str) -> dict[str, Any]:
432451
'''
433452
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'epss', vulnerability))))
434453
return r.json()
454+
455+
# #### CWE ####
456+
457+
def get_cwes(self) -> dict[str, Any]:
458+
'''Get the list of CWEs'''
459+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'cwe'))))
460+
return r.json()
461+
462+
def get_cwe(self, cwe_id: str) -> dict[str, Any]:
463+
'''Get a CWE
464+
465+
:param cwe_id: The CWE ID
466+
'''
467+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'cwe', cwe_id))))
468+
return r.json()
469+
470+
# #### CAPEC ####
471+
472+
def get_capecs(self) -> dict[str, Any]:
473+
'''Get the list of CAPECs'''
474+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'capec'))))
475+
return r.json()
476+
477+
def get_capec(self, capec_id: str) -> dict[str, Any]:
478+
'''Get a CAPEC
479+
480+
:param capec_id: The CAPEC ID
481+
'''
482+
r = self.session.get(urljoin(self.root_url, str(PurePosixPath('api', 'capec', capec_id))))
483+
return r.json()

0 commit comments

Comments
 (0)