### Example OSP Get Version Response Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Illustrates a successful XML response from the 'get_version' OSP command, detailing protocol, daemon, and scanner versions. ```xml OSP1.2OSPd1.4b1some-wrapperWrapper 6.0beta+2 ``` -------------------------------- ### Full OSP Example with Unix Socket Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md A complete example demonstrating how to connect to an ospd-wrapper via a Unix domain socket and retrieve version information. ```python from gvm.connections import UnixSocketConnection from gvm.protocols.latest import Osp # path to unix socket path = '/var/run/ospd-wrapper.sock' connection = UnixSocketConnection(path=path) osp = Osp(connection=connection) # using the with statement to automatically connect and disconnect to ospd with osp: # get the response message returned as a utf-8 encoded string response = osp.get_version() # print the response message print(response) ``` -------------------------------- ### Initialize GMPv227 Protocol Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Instantiate the GMPv227 protocol class to establish a connection. This example shows how to get tasks using the initialized protocol. ```python from gvm.protocols.gmp import GMPv227 as GMP with GMP(connection) as gmp: resp = gmp.get_tasks() ``` -------------------------------- ### Scanner Parameters Example Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/ospv1.md Defines a dictionary for scanner parameters used when starting a scan. ```python scanner_parameters = { "scan_param1": "scan_param1_value", "scan_param2": "scan_param2_value", } ``` -------------------------------- ### start_task Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpnext.md Starts an existing task. ```APIDOC ## start_task ### Description Start an existing task ### Parameters #### Path Parameters - **task_id** (str | UUID) - Required - UUID of the task to be started ``` -------------------------------- ### Install python-gvm from source Source: https://github.com/greenbone/python-gvm/blob/main/docs/install.md After cloning the repository, use this command to install python-gvm in editable mode from its source code. ```bash python3 -m pip install -e /path/to/python-gvm ``` -------------------------------- ### Full Example: Simple GMP Request Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md A complete example demonstrating how to connect to gvmd via a Unix domain socket, retrieve the GMP version, and print the UTF-8 encoded response. ```python from gvm.connections import UnixSocketConnection from gvm.protocols.gmp import GMP # path to unix socket path = '/run/gvmd/gvmd.sock' connection = UnixSocketConnection(path=path) # using the with statement to automatically connect and disconnect to gvmd with GMP(connection=connection) as gmp: # get the response message returned as a utf-8 encoded string response = gmp.get_version() # print the response message print(response) ``` -------------------------------- ### GMPNext.get_agent_installer_instruction() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Retrieves instructions for installing an agent. ```APIDOC ## GMPNext.get_agent_installer_instruction() ### Description Retrieves instructions for installing an agent. ### Method GET (assumed, based on naming convention) ### Endpoint Not specified in source, but typically related to agent management. ### Parameters None explicitly specified in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response Details of the agent installer instructions. #### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### GMP Response Example Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Example of a successful XML response from the get_version command, indicating the status and the GMP version. ```xml 9.0 ``` -------------------------------- ### Example Debug Log Output Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md This is an example of the output you might see in 'debug.log' when using DebugConnection with GMP. ```text DEBUG:gvm.connections:Sending 14 characters. Data DEBUG:gvm.connections:Read 97 characters. Data 9.0 ``` -------------------------------- ### Full GMP Example with Unix Socket Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md A comprehensive example of using GMP with a Unix domain socket for local communication. It includes authentication, task retrieval, and error handling. ```python import sys from gvm.connections import UnixSocketConnection from gvm.errors import GvmError from gvm.protocols.gmp import GMP from gvm.transforms import EtreeCheckCommandTransform path = '/run/gvmd/gvmd.sock' connection = UnixSocketConnection(path=path) transform = EtreeCheckCommandTransform() username = 'foo' password = 'bar' try: tasks = [] with GMP(connection=connection, transform=transform) as gmp: gmp.authenticate(username, password) tasks = gmp.get_tasks(filter_string='name~weekly') for task in tasks.xpath('task'): print(task.find('name').text) except GvmError as e: print('An error occurred', e, file=sys.stderr) ``` -------------------------------- ### start_task Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Starts an existing task. Requires the task ID. ```APIDOC ## start_task task_id ### Description Start an existing task ### Parameters #### Path Parameters - **task_id** (str | UUID) - Required - UUID of the task to be started ``` -------------------------------- ### Install python-gvm using pipenv Source: https://github.com/greenbone/python-gvm/blob/main/docs/install.md Use this command to install python-gvm with pipenv. ```bash pipenv install python-gvm ``` -------------------------------- ### start_audit Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpnext.md Starts an existing audit. ```APIDOC ## start_audit ### Description Start an existing audit ### Parameters #### Path Parameters - **audit_id** (str | UUID) - Required - UUID of the audit to be started ``` -------------------------------- ### Install python-gvm using pip Source: https://github.com/greenbone/python-gvm/blob/main/docs/install.md Use this command to install the latest stable release of python-gvm with pip. ```bash python3 -m pip install python-gvm ``` -------------------------------- ### Install python-gvm using pip Source: https://github.com/greenbone/python-gvm/blob/main/README.md Installs the latest stable release of the python-gvm library using pip. Ensure Python 3.10 or later is installed. ```shell python3 -m pip install --user python-gvm ``` -------------------------------- ### Install uv package manager Source: https://github.com/greenbone/python-gvm/blob/main/README.md Installs the uv package manager using pip. uv is recommended for managing Python development environments. ```shell python3 -m pip install --user uv ``` -------------------------------- ### get_agent_installer_instruction() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpnext.md Requests an agent installer instruction for a specified scanner, language type, and origin URL. ```APIDOC ## get_agent_installer_instruction() ### Description Requests an agent installer instruction for a specified scanner, language type, and origin URL. ### Method Not specified (likely a POST or GET operation) ### Endpoint Not specified ### Parameters #### Query Parameters - **scanner_id** (string | UUID) - Required - UUID of the Agent controller to get the installer instruction for. - **language_type** (AgentInstallerInstructionLanguageType) - Required - Language of the installer instruction. - **origin_url** (string) - Required - Origin URL used to generate the executable agent installation command. ``` -------------------------------- ### Basic python-gvm Example Source: https://github.com/greenbone/python-gvm/blob/main/README.md Demonstrates basic usage of the python-gvm library to connect to a Greenbone Management Protocol (GMP) daemon via a Unix socket, retrieve the GMP version, authenticate, and fetch all tasks. Requires a running GMP service accessible via a Unix socket. ```python from gvm.connections import UnixSocketConnection from gvm.protocols.gmp import GMP from gvm.transforms import EtreeTransform from gvm.xml import pretty_print connection = UnixSocketConnection() transform = EtreeTransform() with GMP(connection, transform=transform) as gmp: # Retrieve GMP version supported by the remote daemon version = gmp.get_version() # Prints the XML in beautiful form pretty_print(version) # Login gmp.authenticate('foo', 'bar') # Retrieve all tasks tasks = gmp.get_tasks() # Get names of tasks task_names = tasks.xpath('task/name/text()') pretty_print(task_names) ``` -------------------------------- ### Targets Example Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/ospv1.md Provides a list of dictionaries defining targets for a scan, including hosts, ports, and credentials. ```python targets = [ {"hosts": "localhost", "ports": "80,43"}, { "hosts": "192.168.0.0/24", "ports": "22", }, { "credentials": { "smb": { "password": "pass", "port": "port", "type": "type", "username": "username", } } }, ] ``` -------------------------------- ### start_audit Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Starts an existing audit. Requires the audit ID. ```APIDOC ## start_audit audit_id ### Description Start an existing audit ### Parameters #### Path Parameters - **audit_id** (str | UUID) - Required - UUID of the audit to be started ``` -------------------------------- ### GMPv224.start_task Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Starts a task. This operation initiates a scan or other defined task within the GVM system. ```APIDOC ## GMPv224.start_task ### Description Starts a task. ### Method Not specified in source, assumed to be a method call within the GMPv224 protocol. ### Endpoint Not applicable for SDK method calls. ### Parameters Parameters are not detailed in the source. Refer to the linked documentation for details. ### Request Example Refer to the linked documentation for details. ### Response Refer to the linked documentation for details. ``` -------------------------------- ### Debug Connection Example Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/connections.md Use DebugConnection to wrap an existing connection to log all sent and received data. Ensure logging is configured to DEBUG level to see the output. ```python import logging logging.basicConfig(level=logging.DEBUG) socket_connection = UnixSocketConnection(path="/var/run/gvm.sock") connection = DebugConnection(socket_connection) gmp = GMP(connection=connection) ``` -------------------------------- ### Authenticate and Get Tasks with GMP Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Demonstrates how to authenticate with GMP using provided credentials and retrieve tasks filtered by name. Includes error handling for GvmError. ```python from gvm.errors import GvmError try: with GMP(connection=connection, transform=transform) as gmp: gmp.authenticate(username, password) tasks = gmp.get_tasks(filter_string='name~weekly') for task in tasks.xpath('task'): print(task.find('name').text) except GvmError as e: print('An error occurred', e) ``` -------------------------------- ### VT Selection Example Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/ospv1.md Illustrates the structure for selecting vulnerability tests (VTs) for a scan, including individual VTs and VT groups. ```python vt_selection = { "vt1": {}, "vt2": {"value_id": "value"}, "vt_groups": ["family=debian", "family=general"], } ``` -------------------------------- ### GMPv224.start_audit Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Starts an audit. This operation initiates an audit process within the GVM system. ```APIDOC ## GMPv224.start_audit ### Description Starts an audit. ### Method Not specified in source, assumed to be a method call within the GMPv224 protocol. ### Endpoint Not applicable for SDK method calls. ### Parameters Parameters are not detailed in the source. Refer to the linked documentation for details. ### Request Example Refer to the linked documentation for details. ### Response Refer to the linked documentation for details. ``` -------------------------------- ### OSP Get Version Request Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Demonstrates how to connect to an ospd-wrapper using a Unix domain socket and retrieve the server version information. ```APIDOC ## Get OSP Version ### Description Establishes a connection to an ospd-wrapper using a Unix domain socket and sends a `get_version` request to retrieve information about the OSP protocol, ospd implementation, and scanner version. ### Method `osp.get_version()` ### Parameters This method does not take any parameters. ### Endpoint N/A (This is an SDK method call, not an HTTP endpoint) ### Request Example ```python from gvm.connections import UnixSocketConnection from gvm.protocols.latest import Osp path = '/var/run/ospd-wrapper.sock' connection = UnixSocketConnection(path=path) osp = Osp(connection=connection) with osp: response = osp.get_version() print(response) ``` ### Response #### Success Response Returns a UTF-8 encoded string containing an XML response with version details. #### Response Example ```xml OSP1.2OSPd1.4b1some-wrapperWrapper 6.0beta+2 ``` ``` -------------------------------- ### GMPNext Get and Describe Operations Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md This section details methods for retrieving information about GVM resources and describing authentication details. ```APIDOC ## GMPNext Get and Describe Operations This section details methods for retrieving information about GVM resources and describing authentication details. ### Methods - `get_agent_group()` - `get_agent_groups()` - `describe_auth()` - `disconnect()` - `empty_trashcan()` ### Description These methods allow you to retrieve details about agent groups, list all agent groups, describe authentication mechanisms, disconnect from the GVM service, and empty the trashcan. Refer to the linked documentation for specific parameter and usage details for each method. ``` -------------------------------- ### Make Simple GMP Request (Get Version) Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Establish a connection to gvmd using a with statement for automatic connection and disconnection. Retrieves the GMP protocol version. Responses are UTF-8 encoded strings by default. ```python import GMP from gvm.protocols.gmp with GMP(connection=connection) as gmp: print(gmp.get_version()) ``` -------------------------------- ### Get OSP Version Information Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Uses a 'with' statement to automatically manage the connection and retrieves the OSP version information from the ospd-wrapper. ```python with osp: print(osp.get_version()) ``` -------------------------------- ### __init__ Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Initializes a new GMP protocol instance, setting up the connection and optional response data transformation. ```APIDOC #### __init__(*args, **kwargs) Create a new GMP protocol instance. * **Parameters:** * **connection** – Connection to use to talk with the remote daemon. See [`gvm.connections`](connections.md#module-gvm.connections) for possible connection types. * **transform** – Optional transform [callable](https://docs.python.org/3/library/functions.html#callable) to convert response data. After each request the callable gets passed the plain response data which can be used to check the data and/or conversion into different representations like a xml dom. See [`gvm.transforms`](transforms.md#module-gvm.transforms) for existing transforms. ``` -------------------------------- ### GMPNext Methods Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md This section lists the available methods for the GMPNext class, which allows for interaction with the Greenbone Management Protocol (GMP). These methods cover a wide range of operations including modifying targets, tasks, tickets, users, and more, as well as starting, stopping, and resuming audits and tasks. ```APIDOC ## GMPNext Methods ### Description Provides methods for interacting with the Greenbone Management Protocol (GMP). ### Methods - `modify_target()` - `modify_task()` - `modify_ticket()` - `modify_tls_certificate()` - `modify_user()` - `modify_user_setting()` - `modify_web_application_target()` - `move_task()` - `restore_from_trashcan()` - `resume_audit()` - `resume_task()` - `send_command()` - `start_audit()` - `start_task()` - `stop_audit()` - `stop_task()` - `sync_agents()` - `test_alert()` - `trigger_alert()` - `verify_credential_store()` - `verify_report_format()` - `verify_scanner()` ``` -------------------------------- ### gvm.connections.GvmConnection.connect() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Establishes a connection to the GVM server. ```APIDOC ## GvmConnection.connect() ### Description Initiates the connection to the GVM server using the specific connection details provided by the subclass. ### Method Instance method ### Endpoint N/A (Python method) ### Parameters None directly on this method; connection parameters are typically set during initialization of the subclass. ### Request Example ```python # Assuming 'conn' is an instance of a GvmConnection subclass (e.g., TLSConnection) conn.connect() ``` ### Response #### Success Response (200) Indicates a successful connection establishment. Specific return values may vary by subclass. ``` -------------------------------- ### Initialize and Use GMP Next Protocol Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpnext.md Instantiate the GMP Next protocol and use it to retrieve tasks. Ensure a valid connection object is provided. ```python from gvm.protocols.gmp.next import GMP with GMP(connection) as gmp: resp = gmp.get_tasks() ``` -------------------------------- ### Get Group Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a single group by its ID. ```APIDOC ## get_group ### Description Request a single group. ### Parameters #### Path Parameters - **group_id** (str | UUID) - Required - UUID of an existing group. ``` -------------------------------- ### help Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves help text, with options for format and brevity. ```APIDOC ## help ### Description Get the help text. ### Parameters #### Query Parameters - **help_format** (HelpFormat | str | None) – Format of of the help: “html”, “rnc”, “text” or “xml - **brief** (bool | None) – If True help is brief ``` -------------------------------- ### Get CVE Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a single CVE by its ID. ```APIDOC ## get_cve ### Description Request a single CVE. ### Parameters #### Path Parameters - **cve_id** (str) - Required - ID of an existing CVE. ``` -------------------------------- ### Get CPE Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a single CPE by its ID. ```APIDOC ## get_cpe ### Description Request a single CPE. ### Parameters #### Path Parameters - **cpe_id** (str) - Required - ID of an existing CPE. ``` -------------------------------- ### Get Report Config Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a single report configuration. ```APIDOC ## get_report_config ### Description Request a single report config. ### Parameters #### Path Parameters - **report_config_id** (str | UUID) - UUID of an existing report config ``` -------------------------------- ### Create Username + SSH Key Credential Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpnext.md This snippet demonstrates creating a Username + SSH Key credential. It requires the login, the private key content, and optionally a key phrase. The private key should be read from a file. ```python with open("path/to/private-ssh-key") as f: key = f.read() gmp.create_credential( name="USK Credential", credential_type=CredentialType.USERNAME_SSH_KEY, login="foo", key_phrase="foobar", private_key=key, ) ``` -------------------------------- ### Get Feed Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a single feed of a specified type. ```APIDOC ## get_feed ### Description Request a single feed. ### Parameters #### Path Parameters - **feed_type** (FeedType | str) - Required - Type of single feed to get: NVT, CERT or SCAP. ``` -------------------------------- ### Get Protocol Version Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves the supported GMP protocol version. ```APIDOC ## get_protocol_version ### Description Return the supported GMP version as major, minor version tuple. ### Method GET ### Endpoint /api/v227/protocol/version ``` -------------------------------- ### GMPv227.help() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Provides help information for the GMP protocol. ```APIDOC ## GMPv227.help() ### Description Provides help information for the GMP protocol. ### Method GET (assumed) ### Endpoint /api/v227/help (assumed) ### Parameters None explicitly documented. ``` -------------------------------- ### GMPNext.get_integration_configs() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Retrieves a list of integration configurations. ```APIDOC ## GMPNext.get_integration_configs() ### Description Retrieves a list of integration configurations. ### Method GET (assumed, based on naming convention) ### Endpoint Not specified in source, but typically related to integration management. ### Parameters None explicitly specified in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response A list of integration configurations. #### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### Get Ticket Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves details for a specific ticket using its unique identifier. ```APIDOC ## get_ticket(ticket_id) ### Description Request a single ticket. ### Parameters #### Path Parameters - **ticket_id** (str | UUID) - Required - UUID of an existing ticket ``` -------------------------------- ### Get Task Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves details for a specific task using its unique identifier. ```APIDOC ## get_task(task_id) ### Description Request a single task. ### Parameters #### Path Parameters - **task_id** (str | UUID) - Required - UUID of an existing task ``` -------------------------------- ### Import GMP and UnixSocketConnection Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Import necessary classes for establishing a Unix domain socket connection and using the GMP protocol. ```python from gvm.connections import UnixSocketConnection from gvm.protocols.gmp import GMP ``` -------------------------------- ### Create S/MIME Credential Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpnext.md This snippet shows how to create an S/MIME credential. It requires the certificate content, which should be read from a file. ```python with open("path/to/smime-cert") as f: cert = f.read() gmp.create_credential( name="SMIME Credential", credential_type=CredentialType.SMIME_CERTIFICATE, certificate=cert, ) ``` -------------------------------- ### Get Tag Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves details for a specific tag using its unique identifier. ```APIDOC ## get_tag(tag_id) ### Description Request a single tag. ### Parameters #### Path Parameters - **tag_id** (str | UUID) - Required - UUID of an existing tag ``` -------------------------------- ### gvm.connections.TLSConnection.connect() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Establishes a TLS connection to the GVM server. ```APIDOC ## TLSConnection.connect() ### Description Initiates and establishes the TLS/SSL connection to the GVM server using the host and port information provided during initialization. ### Method Instance method ### Endpoint N/A (Python method) ### Parameters None ### Request Example ```python # Assuming 'tls_conn' is a TLSConnection instance tls_conn.connect() ``` ### Response #### Success Response (200) Indicates a successful TLS connection. ``` -------------------------------- ### Get Scanner Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves details for a specific scanner using its unique identifier. ```APIDOC ## get_scanner(scanner_id) ### Description Request a single scanner. ### Parameters #### Path Parameters - **scanner_id** (str | UUID) - Required - UUID of an existing scanner ``` -------------------------------- ### Get Single DFN-CERT Advisory Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a single DFN-CERT Advisory by its ID. ```APIDOC ## get_dfn_cert_advisory ### Description Request a single DFN-CERT Advisory. ### Parameters #### Path Parameters - **cert_id** (str | UUID) - Required - ID of an existing DFN-CERT Advisory. ``` -------------------------------- ### GMPNext.get_operating_systems() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Retrieves a list of operating systems. ```APIDOC ## GMPNext.get_operating_systems() ### Description Retrieves a list of operating systems. ### Method GET (assumed, based on naming convention) ### Endpoint Not specified in source, but typically related to operating system information. ### Parameters None explicitly specified in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response A list of operating systems. #### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### Get Single CERT-BUND Advisory Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a single CERT-BUND Advisory by its ID. ```APIDOC ## get_cert_bund_advisory ### Description Request a single CERT-BUND Advisory. ### Parameters #### Path Parameters - **cert_id** (str | UUID) - Required - ID of an existing CERT-BUND Advisory. ``` -------------------------------- ### Get Tickets Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a list of tickets, with options for filtering and including trashcan items. ```APIDOC ## get_tickets(, trash=None, filter_string=None, filter_id=None) ### Description Request a list of tickets. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query - **trash** (bool | None) - Optional - True to request the tickets in the trashcan ``` -------------------------------- ### Create Schedule with iCalendar Data Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpnext.md Demonstrates how to create a new schedule using iCalendar data. Requires the 'icalendar' and 'pytz' libraries. The timezone parameter is crucial for interpreting datetime values. ```python import pytz from datetime import datetime from icalendar import Calendar, Event cal = Calendar() cal.add("prodid", "-//Foo Bar//") cal.add("version", "2.0") event = Event() event.add("dtstamp", datetime.now(tz=pytz.UTC)) event.add("dtstart", datetime(2020, 1, 1, tzinfo=pytz.utc)) cal.add_component(event) gmp.create_schedule( name="My Schedule", icalendar=cal.to_ical(), timezone="UTC" ) ``` -------------------------------- ### Get Target Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves details for a specific target, with an option to include associated tasks. ```APIDOC ## get_target(target_id, , tasks=None) ### Description Request a single target. ### Parameters #### Path Parameters - **target_id** (str | UUID) - Required - UUID of the target to request. #### Query Parameters - **tasks** (bool | None) - Optional - Whether to include list of tasks that use the target ``` -------------------------------- ### Get Schedule Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves details for a specific schedule, with an option to include associated tasks. ```APIDOC ## get_schedule(schedule_id, , tasks=None) ### Description Request a single schedule. ### Parameters #### Path Parameters - **schedule_id** (str | UUID) - Required - UUID of an existing schedule #### Query Parameters - **tasks** (bool | None) - Optional - Whether to include tasks using the schedules ``` -------------------------------- ### GMPNext.get_info() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Retrieves general information about the GVM. ```APIDOC ## GMPNext.get_info() ### Description Retrieves general information about the GVM. ### Method GET (assumed, based on naming convention) ### Endpoint Not specified in source, but typically related to system information. ### Parameters None explicitly specified in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response General GVM information. #### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### Get Resource Name Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves the name of a specific resource based on its ID and type. ```APIDOC ## get_resource_name ### Description Request a single resource name. ### Parameters #### Path Parameters - **resource_id** (str) - ID of an existing resource - **resource_type** (ResourceType) - Type must be either ALERT, CERT_BUND_ADV, CONFIG, CPE, CREDENTIAL, CVE, DFN_CERT_ADV, FILTER, GROUP, HOST, NOTE, NVT, OS, OVERRIDE, PERMISSION, PORT_LIST, REPORT_FORMAT, REPORT, REPORT_CONFIG, RESULT, ROLE, SCANNER, SCHEDULE, TARGET, TASK, TLS_CERTIFICATE or USER ``` -------------------------------- ### Get Report Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a single scan report, with options for filtering, comparison, and format. ```APIDOC ## get_report ### Description Request a single scan report. ### Parameters #### Path Parameters - **report_id** (str | UUID) - UUID of an existing report #### Query Parameters - **filter_string** (str | None) - Filter term to use to filter results in the report - **filter_id** (str | None) - UUID of filter to use to filter results in the report - **delta_report_id** (str | UUID | None) - UUID of an existing report to compare report to. - **report_format_id** (str | ReportFormatType | None) - UUID of report format to use or ReportFormatType (enum) - **report_config_id** (str | None) - UUID of report format config to use - **ignore_pagination** (bool | None) - Whether to ignore the filter terms “first” and “rows”. - **details** (bool | None) - Request additional report information details, defaults to True ``` -------------------------------- ### Create Host Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md This function creates a new host entry. Provide a name for the host and an optional comment. ```python gmp.create_host(name="My Host", comment="A sample host") ``` -------------------------------- ### GMPNext.get_info_list() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Retrieves a list of information items from the GVM. ```APIDOC ## GMPNext.get_info_list() ### Description Retrieves a list of information items from the GVM. ### Method GET (assumed, based on naming convention) ### Endpoint Not specified in source, but typically related to system information. ### Parameters None explicitly specified in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response A list of information items. #### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### Osp Class Initialization Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/ospv1.md Initializes the Osp class with a connection object and an optional response transform callable. ```APIDOC ## Osp Class ### __init__(connection, *, transform=str_transform) Create a new GvmProtocol instance. #### Parameters: * **connection** (*GvmConnection*) – Connection to use to talk with the remote daemon. See `gvm.connections` for possible connection types. * **transform** (*Callable* [*Response*]*,* *T* *]*) – Optional transform callable to convert response data. After each request the callable gets passed the plain response data which can be used to check the data and/or conversion into different representations like a xml dom. ``` -------------------------------- ### Get TLS Certificate Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves details for a specific TLS certificate using its unique identifier. ```APIDOC ## get_tls_certificate(tls_certificate_id) ### Description Request a single TLS certificate. ### Parameters #### Path Parameters - **tls_certificate_id** (str | UUID) - Required - UUID of an existing TLS certificate ``` -------------------------------- ### Initialize and Use GMP Protocol Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmp.md Use the GMP class as a context manager to dynamically select the supported GMP protocol of the remote manager daemon. The 'connection' object should be an instance of GvmConnection. ```python from gvm.protocols.gmp import GMP with GMP(connection) as gmp: # gmp can be an instance of # gvm.protocols.gmp.GMPv224, # gvm.protocols.gmp.GMPv225, # gvm.protocols.gmp.GMPv226, # gvm.protocols.gmp.GMPv227, # or gvm.protocols.gmp.GMPNext # depending on the supported GMP version of the remote manager daemon resp = gmp.get_tasks() ``` -------------------------------- ### Get Schedules Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a list of schedules, with options for filtering and including trashcan items or tasks. ```APIDOC ## get_schedules(, filter_string=None, filter_id=None, trash=None, tasks=None) ### Description Request a list of schedules. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query - **trash** (bool | None) - Optional - Whether to get the trashcan schedules instead - **tasks** (bool | None) - Optional - Whether to include tasks using the schedules ``` -------------------------------- ### Get Scanners Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a list of scanners, with options for filtering and including trashcan items or details. ```APIDOC ## get_scanners(, filter_string=None, filter_id=None, trash=None, details=None) ### Description Request a list of scanners. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query - **trash** (bool | None) - Optional - Whether to get the trashcan scanners instead - **details** (bool | None) - Optional - Whether to include extra details like tasks using this scanner ``` -------------------------------- ### Initialize EtreeCheckCommandTransform Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Create an instance of EtreeCheckCommandTransform to be used with GMP for response parsing and error checking. ```python transform = EtreeCheckCommandTransform() ``` -------------------------------- ### Get Reports Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a list of scan reports, with options for filtering and including detailed information. ```APIDOC ## get_reports ### Description Request a list of scan reports. ### Parameters #### Query Parameters - **filter_string** (str | None) - Filter term to use for the query - **filter_id** (str | UUID | None) - UUID of an existing filter to use for the query - **note_details** (bool | None) - If notes are included, whether to include note details - **override_details** (bool | None) - If overrides are included, whether to include override details - **ignore_pagination** (bool | None) - Whether to ignore the filter terms “first” and “rows”. - **details** (bool | None) - Whether to exclude results ``` -------------------------------- ### Get Report Configs Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a list of report configurations, with options for filtering and trash retrieval. ```APIDOC ## get_report_configs ### Description Request a list of report configs. ### Parameters #### Query Parameters - **filter_string** (str | None) - Filter term to use for the query - **filter_id** (str | UUID | None) - UUID of an existing filter to use for the query - **trash** (bool | None) - Whether to get the trashcan report configs instead - **details** (bool | None) - Include report config details ``` -------------------------------- ### gvm.connections.SSHConnection.connect() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Establishes an SSH connection to the GVM server. ```APIDOC ## SSHConnection.connect() ### Description Initiates and establishes the SSH connection to the GVM server using the credentials and host information provided during initialization. ### Method Instance method ### Endpoint N/A (Python method) ### Parameters None ### Request Example ```python # Assuming 'ssh_conn' is an SSHConnection instance ssh_conn.connect() ``` ### Response #### Success Response (200) Indicates a successful SSH connection. ``` -------------------------------- ### Clone python-gvm repository Source: https://github.com/greenbone/python-gvm/blob/main/docs/install.md Clone the public repository of python-gvm from GitHub to get the source code. ```bash git clone git://github.com/greenbone/python-gvm ``` -------------------------------- ### GMPNext.get_operating_system() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Retrieves a specific operating system. ```APIDOC ## GMPNext.get_operating_system() ### Description Retrieves a specific operating system. ### Method GET (assumed, based on naming convention) ### Endpoint Not specified in source, but typically related to operating system information. ### Parameters None explicitly specified in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response Details of the specified operating system. #### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### Get Tags Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a list of tags, with options for filtering, including trashcan items, and retrieving only names. ```APIDOC ## get_tags(, filter_string=None, filter_id=None, trash=None, names_only=None) ### Description Request a list of tags. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query - **trash** (bool | None) - Optional - Whether to get tags from the trashcan instead - **names_only** (bool | None) - Optional - Whether to get only distinct tag names ``` -------------------------------- ### GMPv225 Alert and Command Methods Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md This section includes methods for sending commands and interacting with alerts. ```APIDOC ## GMPv225 Alert and Command Methods ### Description Provides methods for executing arbitrary commands and triggering or testing alerts within the GVM system. ### Methods - `send_command()`: Sends a command to be executed by the GVM. - `test_alert()`: Tests the functionality of an alert. - `trigger_alert()`: Manually triggers an alert. ### Usage These methods are used for advanced control and testing scenarios within the GVM. ``` -------------------------------- ### Get Filter Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a single filter by its ID. Can optionally include a list of alerts that use the filter. ```APIDOC ## get_filter ### Description Request a single filter. ### Parameters #### Path Parameters - **filter_id** (str | UUID) - Required - UUID of an existing filter. #### Query Parameters - **alerts** (bool | None) - Optional - Whether to include list of alerts that use the filter. ``` -------------------------------- ### gvm.connections.UnixSocketConnection.connect() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Establishes a Unix domain socket connection to the GVM server. ```APIDOC ## UnixSocketConnection.connect() ### Description Initiates and establishes the Unix domain socket connection to the GVM server using the socket path provided during initialization. ### Method Instance method ### Endpoint N/A (Python method) ### Parameters None ### Request Example ```python # Assuming 'unix_conn' is a UnixSocketConnection instance unix_conn.connect() ``` ### Response #### Success Response (200) Indicates a successful Unix domain socket connection. ``` -------------------------------- ### Get CVEs Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a list of CVEs. Supports filtering by string or ID, and can include detailed information. ```APIDOC ## get_cves ### Description Request a list of CVEs. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query. - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query. - **name** (str | None) - Optional - Name or identifier of the requested information. - **details** (bool | None) - Optional - Whether to include information about references to this information. ``` -------------------------------- ### GMPv227 Methods Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md This section lists the available methods for the GMPv227 protocol, including initialization, authentication, and cloning operations for alerts, audits, credentials, filters, groups, notes, and overrides. ```APIDOC ## GMPv227 Methods This section lists the available methods for the GMPv227 protocol, including initialization, authentication, and cloning operations for alerts, audits, credentials, filters, groups, notes, and overrides. ### Methods - `__init__()` - `authenticate()` - `clone_alert()` - `clone_audit()` - `clone_credential()` - `clone_filter()` - `clone_group()` - `clone_note()` - `clone_override()` ``` -------------------------------- ### Get CPEs Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a list of CPEs. Supports filtering by string or ID, and can include detailed information. ```APIDOC ## get_cpes ### Description Request a list of CPEs. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query. - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query. - **name** (str | None) - Optional - Name or identifier of the requested information. - **details** (bool | None) - Optional - Whether to include information about references to this information. ``` -------------------------------- ### Get Tasks Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a list of tasks, with options for filtering, including trashcan items, details, and schedule-only information. ```APIDOC ## get_tasks(, filter_string=None, filter_id=None, trash=None, details=None, schedules_only=None, ignore_pagination=None) ### Description Request a list of tasks. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query - **trash** (bool | None) - Optional - Whether to get the trashcan tasks instead - **details** (bool | None) - Optional - Whether to include full task details - **schedules_only** (bool | None) - Optional - Whether to only include id, name and schedule details - **ignore_pagination** (bool | None) - Optional - Whether to ignore pagination settings (filter terms “first” and “rows”). Default is False. ``` -------------------------------- ### create_host Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Creates a new host entry. Allows specifying a name and an optional comment. ```APIDOC ## create_host ### Description Create a new host host ### Parameters * **name** (str) – Name for the new host host * **comment** (str | None) – Comment for the new host host ``` -------------------------------- ### Get Targets Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Retrieves a list of targets, with options for filtering, including trashcan items, and including associated tasks. ```APIDOC ## get_targets(, filter_string=None, filter_id=None, trash=None, tasks=None) ### Description Request a list of targets. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query. - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query. - **trash** (bool | None) - Optional - Whether to include targets in the trashcan. - **tasks** (bool | None) - Optional - Whether to include list of tasks that use the target. ``` -------------------------------- ### GMPNext.get_cert_bund_advisories() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Retrieves a list of Certificate Bundling Advisories (CBAs). ```APIDOC ## GMPNext.get_cert_bund_advisories() ### Description Retrieves a list of Certificate Bundling Advisories (CBAs). ### Method GET (assumed, based on naming convention) ### Endpoint Not specified in source, but typically related to advisory management. ### Parameters None explicitly specified in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response A list of Certificate Bundling Advisories. #### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### Create OSP Connection and Object Source: https://github.com/greenbone/python-gvm/blob/main/docs/usage.md Initializes a UnixSocketConnection and creates an Osp object for interacting with the ospd-wrapper. ```python connection = UnixSocketConnection(path=path) osp = Osp(connection=connection) ``` -------------------------------- ### Get DFN-CERT Advisories Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a list of DFN-CERT Advisories. Supports filtering by string or ID, and can include detailed information. ```APIDOC ## get_dfn_cert_advisories ### Description Request a list of DFN-CERT Advisories. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query. - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query. - **name** (str | None) - Optional - Name or identifier of the requested information. - **details** (bool | None) - Optional - Whether to include information about references to this information. ``` -------------------------------- ### connect Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpnext.md Initiates a protocol connection. This method is typically called automatically or used within a 'with' statement, rather than directly by the user. ```APIDOC ## connect() ### Description Initiates a protocol connection. ### Notes Normally connect is not called directly. Either it is called automatically when sending a protocol command or when using a [with statement](https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers). ``` -------------------------------- ### GMPNext.get_dfn_cert_advisories() Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/api.md Retrieves a list of DFN-CERT Advisories. ```APIDOC ## GMPNext.get_dfn_cert_advisories() ### Description Retrieves a list of DFN-CERT Advisories. ### Method GET (assumed, based on naming convention) ### Endpoint Not specified in source, but typically related to advisory management. ### Parameters None explicitly specified in the source. ### Request Example ```json { "example": "No request example available" } ``` ### Response #### Success Response A list of DFN-CERT Advisories. #### Response Example ```json { "example": "No response example available" } ``` ``` -------------------------------- ### Get CERT-BUND Advisories Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/gmpv227.md Requests a list of CERT-BUND Advisories. Supports filtering by string or ID, and can include detailed information. ```APIDOC ## get_cert_bund_advisories ### Description Request a list of CERT-BUND Advisories. ### Parameters #### Query Parameters - **filter_string** (str | None) - Optional - Filter term to use for the query. - **filter_id** (str | UUID | None) - Optional - UUID of an existing filter to use for the query. - **name** (str | None) - Optional - Name or identifier of the requested information. - **details** (bool | None) - Optional - Whether to include information about references to this information. ``` -------------------------------- ### Create XML Commands Source: https://github.com/greenbone/python-gvm/blob/main/docs/api/other.md The `XmlCommand` class is used to construct XML commands for GVM protocols. Initialize it with the root element name. ```python from gvm.xml import XmlCommand cmd = XmlCommand("get_version") ```