Would anyone know how to do this using the python-gvm library. Specifically GMP V22.4?
Here is a link to the GMP functions that you may use to achieve this:
modify_scan_config_set_family_selection()
for GMP V22.4: GMP v22.4 - python-gvm
modify_scan_config_set_nvt_selection()
for GMP v22.4: GMP v22.4 - python-gvm
The implementation would look something like this code below but will need the
config ID that you want to add/modify and the name of the family or NVT OID to enable.
from gvm.connections import UnixSocketConnection
from gvm.protocols.gmp import Gmp
from gvm.transforms import EtreeCheckCommandTransform
# Auth creds
username = 'foo'
password = 'bar'
# If gvmd is provided by a package of the distribution, it should be /run/gvmd/gvmd.sock.
# If gvmd was built from source and did not set a prefix, the default path can be used by setting path = None.
#
path = '/run/gvmd/gvmd.sock'
# Create a connection and a gmp object
connection = UnixSocketConnection(path=path)
# Connect and perform task
with Gmp(connection=connection) as gmp:
# Authenticate
gmp.authenticate(username, password)
#
# Add a specific Family
#
# From https://python-gvm.readthedocs.io/en/latest/api/gmpv224.html#gvm.protocols.gmpv224.Gmp.modify_scan_config_set_family_selection
# Selected the NVTs of a scan config at a family level.
# PARAMETERS
# `config_id` (str) – UUID of scan config to modify.
# `families` (List[Tuple[str, bool, bool]]) –
# A list of tuples (str, bool, bool):
# str: the name of the NVT family selected,
# bool: add new NVTs to the family automatically,
# bool: include all NVTs from the family
# `auto_add_new_families` (Optional[bool]) – Whether new families should be added to the scan config automatically. Default: True.
response = modify_scan_config_set_family_selection(config_id, families, *, auto_add_new_families=True)
#
# Add a specific NVT
#
# From: https://python-gvm.readthedocs.io/en/latest/api/gmpv224.html#gvm.protocols.gmpv224.Gmp.modify_scan_config_set_nvt_selection
# Modifies the selected nvts of an existing scan config
# The manager updates the given family in the config to include only the given NVTs.
# PARAMETERS
# `config_id` (str) – UUID of scan config to modify.
# `family` (str) – Name of the NVT family to include NVTs from
# `nvt_oids` (List[str]) – List of NVTs to select for the family.
modify_scan_config_set_nvt_selection(config_id, family, nvt_oids)
1 Like