1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
# SPDX-FileCopyrightText: 2025 Greenbone AG
#
# SPDX-License-Identifier: GPL-3.0-or-later
"""
API wrapper for interacting with the Notus component of the openvasd HTTP API.
"""
import urllib
import httpx
from ._api import OpenvasdAPI
class NotusAPI(OpenvasdAPI):
"""
Provides access to the Notus-related endpoints of the openvasd HTTP API.
This includes retrieving supported operating systems and triggering
package-based vulnerability scans for a specific OS.
"""
def get_os_list(self) -> httpx.Response:
"""
Retrieve the list of supported operating systems from the Notus service.
Returns:
The full `httpx.Response` on success.
See: GET /notus in the openvasd API documentation.
"""
try:
response = self._client.get("/notus")
response.raise_for_status()
return response
except httpx.HTTPStatusError as e:
if self._suppress_exceptions:
return e.response
raise
def run_scan(
self,
os: str,
package_list: list[str],
) -> httpx.Response:
"""
Trigger a Notus scan for a given OS and list of packages.
Args:
os: Operating system name (e.g., "debian", "alpine").
package_list: List of package names to evaluate for vulnerabilities.
Returns:
The full `httpx.Response` on success.
See: POST /notus/{os} in the openvasd API documentation.
"""
quoted_os = urllib.parse.quote(os)
try:
response = self._client.post(
f"/notus/{quoted_os}", json=package_list
)
response.raise_for_status()
return response
except httpx.HTTPStatusError as e:
if self._suppress_exceptions:
return e.response
raise
|