| @@ 425-486 (lines=62) @@ | ||
| 422 | ||
| 423 | return self._send_xml_command(cmd) |
|
| 424 | ||
| 425 | def modify_scan_config_set_family_selection( |
|
| 426 | self, |
|
| 427 | config_id: str, |
|
| 428 | families: List[Tuple[str, bool, bool]], |
|
| 429 | *, |
|
| 430 | auto_add_new_families: Optional[bool] = True, |
|
| 431 | ) -> Any: |
|
| 432 | """ |
|
| 433 | Selected the NVTs of a scan config at a family level. |
|
| 434 | ||
| 435 | Arguments: |
|
| 436 | config_id: UUID of scan config to modify. |
|
| 437 | families: A list of tuples (str, bool, bool): |
|
| 438 | str: the name of the NVT family selected, |
|
| 439 | bool: add new NVTs to the family automatically, |
|
| 440 | bool: include all NVTs from the family |
|
| 441 | auto_add_new_families: Whether new families should be added to the |
|
| 442 | scan config automatically. Default: True. |
|
| 443 | """ |
|
| 444 | if not config_id: |
|
| 445 | raise RequiredArgument( |
|
| 446 | function=self.modify_scan_config_set_family_selection.__name__, |
|
| 447 | argument='config_id', |
|
| 448 | ) |
|
| 449 | ||
| 450 | if not is_list_like(families): |
|
| 451 | raise InvalidArgumentType( |
|
| 452 | function=self.modify_scan_config_set_family_selection.__name__, |
|
| 453 | argument='families', |
|
| 454 | arg_type='list', |
|
| 455 | ) |
|
| 456 | ||
| 457 | cmd = XmlCommand("modify_config") |
|
| 458 | cmd.set_attribute("config_id", str(config_id)) |
|
| 459 | ||
| 460 | _xmlfamsel = cmd.add_element("family_selection") |
|
| 461 | _xmlfamsel.add_element("growing", to_bool(auto_add_new_families)) |
|
| 462 | ||
| 463 | for family in families: |
|
| 464 | _xmlfamily = _xmlfamsel.add_element("family") |
|
| 465 | _xmlfamily.add_element("name", family[0]) |
|
| 466 | ||
| 467 | if len(family) != 3: |
|
| 468 | raise InvalidArgument( |
|
| 469 | "Family must be a tuple of 3. (str, bool, bool)" |
|
| 470 | ) |
|
| 471 | ||
| 472 | if not isinstance(family[1], bool) or not isinstance( |
|
| 473 | family[2], bool |
|
| 474 | ): |
|
| 475 | raise InvalidArgumentType( |
|
| 476 | function=( |
|
| 477 | self.modify_scan_config_set_family_selection.__name__ |
|
| 478 | ), |
|
| 479 | argument='families', |
|
| 480 | arg_type='[tuple(str, bool, bool)]', |
|
| 481 | ) |
|
| 482 | ||
| 483 | _xmlfamily.add_element("all", to_bool(family[2])) |
|
| 484 | _xmlfamily.add_element("growing", to_bool(family[1])) |
|
| 485 | ||
| 486 | return self._send_xml_command(cmd) |
|
| 487 | ||
| 488 | def modify_scan_config( |
|
| 489 | self, config_id: str, selection: Optional[str] = None, **kwargs |
|
| @@ 358-418 (lines=61) @@ | ||
| 355 | ||
| 356 | return self._send_xml_command(cmd) |
|
| 357 | ||
| 358 | def modify_policy_set_family_selection( |
|
| 359 | self, |
|
| 360 | policy_id: str, |
|
| 361 | families: List[Tuple[str, bool, bool]], |
|
| 362 | *, |
|
| 363 | auto_add_new_families: Optional[bool] = True, |
|
| 364 | ) -> Any: |
|
| 365 | """ |
|
| 366 | Selected the NVTs of a policy at a family level. |
|
| 367 | ||
| 368 | Arguments: |
|
| 369 | policy_id: UUID of policy to modify. |
|
| 370 | families: A list of tuples with the first entry being the name |
|
| 371 | of the NVT family selected, second entry a boolean indicating |
|
| 372 | whether new NVTs should be added to the family automatically, |
|
| 373 | and third entry a boolean indicating whether all nvts from |
|
| 374 | the family should be included. |
|
| 375 | auto_add_new_families: Whether new families should be added to the |
|
| 376 | policy automatically. Default: True. |
|
| 377 | """ |
|
| 378 | if not policy_id: |
|
| 379 | raise RequiredArgument( |
|
| 380 | function=self.modify_policy_set_family_selection.__name__, |
|
| 381 | argument='policy_id', |
|
| 382 | ) |
|
| 383 | ||
| 384 | if not is_list_like(families): |
|
| 385 | raise InvalidArgumentType( |
|
| 386 | function=self.modify_policy_set_family_selection.__name__, |
|
| 387 | argument='families', |
|
| 388 | arg_type='list', |
|
| 389 | ) |
|
| 390 | ||
| 391 | cmd = XmlCommand("modify_config") |
|
| 392 | cmd.set_attribute("config_id", str(policy_id)) |
|
| 393 | ||
| 394 | _xmlfamsel = cmd.add_element("family_selection") |
|
| 395 | _xmlfamsel.add_element("growing", to_bool(auto_add_new_families)) |
|
| 396 | ||
| 397 | for family in families: |
|
| 398 | _xmlfamily = _xmlfamsel.add_element("family") |
|
| 399 | _xmlfamily.add_element("name", family[0]) |
|
| 400 | ||
| 401 | if len(family) != 3: |
|
| 402 | raise InvalidArgument( |
|
| 403 | "Family must be a tuple of 3. (str, bool, bool)" |
|
| 404 | ) |
|
| 405 | ||
| 406 | if not isinstance(family[1], bool) or not isinstance( |
|
| 407 | family[2], bool |
|
| 408 | ): |
|
| 409 | raise InvalidArgumentType( |
|
| 410 | function=(self.modify_policy_set_family_selection.__name__), |
|
| 411 | argument='families', |
|
| 412 | arg_type='[tuple(str, bool, bool)]', |
|
| 413 | ) |
|
| 414 | ||
| 415 | _xmlfamily.add_element("all", to_bool(family[2])) |
|
| 416 | _xmlfamily.add_element("growing", to_bool(family[1])) |
|
| 417 | ||
| 418 | return self._send_xml_command(cmd) |
|
| 419 | ||