mirror of
https://github.com/cve-search/PyVulnerabilityLookup.git
synced 2024-11-25 16:27:23 +00:00
new: create user, get config
Some checks are pending
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.10) (push) Waiting to run
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.11) (push) Waiting to run
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.12) (push) Waiting to run
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.8) (push) Waiting to run
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.9) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.10) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.11) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.12) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.8) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.9) (push) Waiting to run
Some checks are pending
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.10) (push) Waiting to run
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.11) (push) Waiting to run
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.12) (push) Waiting to run
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.8) (push) Waiting to run
Python application - MyPy / Python ${{ matrix.python-version }} sample (3.9) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.10) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.11) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.12) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.8) (push) Waiting to run
Python application - Test Public Interface / Python ${{ matrix.python-version }} sample (3.9) (push) Waiting to run
This commit is contained in:
parent
4e5146142c
commit
7a93e8ad8c
1 changed files with 25 additions and 4 deletions
|
@ -34,6 +34,10 @@ class PyVulnerabilityLookup():
|
|||
if proxies:
|
||||
self.session.proxies.update(proxies)
|
||||
|
||||
def set_apikey(self, apikey: str) -> None:
|
||||
'''Set the API key to use for the requests'''
|
||||
self.session.headers['X-API-KEY'] = apikey
|
||||
|
||||
@property
|
||||
def is_up(self) -> bool:
|
||||
'''Test if the given instance is accessible'''
|
||||
|
@ -61,6 +65,11 @@ class PyVulnerabilityLookup():
|
|||
r = self.session.get(urljoin(self.root_url, 'info'))
|
||||
return r.json()
|
||||
|
||||
def get_config_info(self) -> dict[str, Any]:
|
||||
'''Get more information about the current databases in use and when it was updated'''
|
||||
r = self.session.get(urljoin(self.root_url, 'configInfo'))
|
||||
return r.json()
|
||||
|
||||
def get_last(self, number: int | None=None, source: str | None = None) -> list[dict[str, Any]]:
|
||||
'''Get the last vulnerabilities
|
||||
|
||||
|
@ -99,13 +108,13 @@ class PyVulnerabilityLookup():
|
|||
|
||||
# NOTE: endpoints /api/cve/*, /api/dbInfo, /api/last are alises for backward compat.
|
||||
|
||||
def create_comment(self, comment: Dict[str, Any]) -> Dict[str, Any]:
|
||||
def create_comment(self, comment: dict[str, Any]) -> dict[str, Any]:
|
||||
'''Create a comment.
|
||||
|
||||
:param comment: The comment
|
||||
'''
|
||||
r = self.session.post(urljoin(self.root_url, str(PurePosixPath('api', 'comment'))),
|
||||
json=comment)
|
||||
json=comment)
|
||||
return r.json()
|
||||
|
||||
def get_comments(self, uuid: str | None = None, vuln_id: str | None = None,
|
||||
|
@ -128,13 +137,13 @@ class PyVulnerabilityLookup():
|
|||
r = self.session.delete(urljoin(self.root_url, str(PurePosixPath('api', 'comment', comment_uuid))))
|
||||
return r.status_code
|
||||
|
||||
def create_bundle(self, bundle: Dict[str, Any]) -> Dict[str, Any]:
|
||||
def create_bundle(self, bundle: dict[str, Any]) -> dict[str, Any]:
|
||||
'''Create a bundle.
|
||||
|
||||
:param bundle: The bundle
|
||||
'''
|
||||
r = self.session.post(urljoin(self.root_url, str(PurePosixPath('api', 'bundle'))),
|
||||
json=bundle)
|
||||
json=bundle)
|
||||
return r.json()
|
||||
|
||||
def get_bundles(self, uuid: str | None = None, vuln_id: str | None = None,
|
||||
|
@ -156,3 +165,15 @@ class PyVulnerabilityLookup():
|
|||
'''
|
||||
r = self.session.delete(urljoin(self.root_url, str(PurePosixPath('api', 'bundle', bundle_uuid))))
|
||||
return r.status_code
|
||||
|
||||
def create_user(self, login: str, name: str, organisation: str, email: str) -> dict[str, Any]:
|
||||
'''Create a user.
|
||||
|
||||
:param login: The login of the user
|
||||
:param name: The name of the user
|
||||
:param organisation: The organisation of the user
|
||||
:param email: The email of the user
|
||||
'''
|
||||
r = self.session.post(urljoin(self.root_url, str(PurePosixPath('api', 'user'))),
|
||||
json={'login': login, 'name': name, 'organisation': organisation, 'email': email})
|
||||
return r.json()
|
||||
|
|
Loading…
Reference in a new issue