@@ 354-414 (lines=61) @@ | ||
351 | ||
352 | return self._send_xml_command(cmd) |
|
353 | ||
354 | def modify_policy_set_family_selection( |
|
355 | self, |
|
356 | policy_id: str, |
|
357 | families: List[Tuple[str, bool, bool]], |
|
358 | *, |
|
359 | auto_add_new_families: Optional[bool] = True, |
|
360 | ) -> Any: |
|
361 | """ |
|
362 | Selected the NVTs of a policy at a family level. |
|
363 | ||
364 | Arguments: |
|
365 | policy_id: UUID of policy to modify. |
|
366 | families: A list of tuples with the first entry being the name |
|
367 | of the NVT family selected, second entry a boolean indicating |
|
368 | whether new NVTs should be added to the family automatically, |
|
369 | and third entry a boolean indicating whether all nvts from |
|
370 | the family should be included. |
|
371 | auto_add_new_families: Whether new families should be added to the |
|
372 | policy automatically. Default: True. |
|
373 | """ |
|
374 | if not policy_id: |
|
375 | raise RequiredArgument( |
|
376 | function=self.modify_policy_set_family_selection.__name__, |
|
377 | argument='policy_id', |
|
378 | ) |
|
379 | ||
380 | if not is_list_like(families): |
|
381 | raise InvalidArgumentType( |
|
382 | function=self.modify_policy_set_family_selection.__name__, |
|
383 | argument='families', |
|
384 | arg_type='list', |
|
385 | ) |
|
386 | ||
387 | cmd = XmlCommand("modify_config") |
|
388 | cmd.set_attribute("config_id", str(policy_id)) |
|
389 | ||
390 | _xmlfamsel = cmd.add_element("family_selection") |
|
391 | _xmlfamsel.add_element("growing", to_bool(auto_add_new_families)) |
|
392 | ||
393 | for family in families: |
|
394 | _xmlfamily = _xmlfamsel.add_element("family") |
|
395 | _xmlfamily.add_element("name", family[0]) |
|
396 | ||
397 | if len(family) != 3: |
|
398 | raise InvalidArgument( |
|
399 | "Family must be a tuple of 3. (str, bool, bool)" |
|
400 | ) |
|
401 | ||
402 | if not isinstance(family[1], bool) or not isinstance( |
|
403 | family[2], bool |
|
404 | ): |
|
405 | raise InvalidArgumentType( |
|
406 | function=(self.modify_policy_set_family_selection.__name__), |
|
407 | argument='families', |
|
408 | arg_type='[tuple(str, bool, bool)]', |
|
409 | ) |
|
410 | ||
411 | _xmlfamily.add_element("all", to_bool(family[2])) |
|
412 | _xmlfamily.add_element("growing", to_bool(family[1])) |
|
413 | ||
414 | return self._send_xml_command(cmd) |
|
415 |
@@ 484-545 (lines=62) @@ | ||
481 | ||
482 | return self._send_xml_command(cmd) |
|
483 | ||
484 | def modify_scan_config_set_family_selection( |
|
485 | self, |
|
486 | config_id: str, |
|
487 | families: List[Tuple[str, bool, bool]], |
|
488 | *, |
|
489 | auto_add_new_families: Optional[bool] = True, |
|
490 | ) -> Any: |
|
491 | """ |
|
492 | Selected the NVTs of a scan config at a family level. |
|
493 | ||
494 | Arguments: |
|
495 | config_id: UUID of scan config to modify. |
|
496 | families: A list of tuples (str, bool, bool): |
|
497 | str: the name of the NVT family selected, |
|
498 | bool: add new NVTs to the family automatically, |
|
499 | bool: include all NVTs from the family |
|
500 | auto_add_new_families: Whether new families should be added to the |
|
501 | scan config automatically. Default: True. |
|
502 | """ |
|
503 | if not config_id: |
|
504 | raise RequiredArgument( |
|
505 | function=self.modify_scan_config_set_family_selection.__name__, |
|
506 | argument='config_id', |
|
507 | ) |
|
508 | ||
509 | if not is_list_like(families): |
|
510 | raise InvalidArgumentType( |
|
511 | function=self.modify_scan_config_set_family_selection.__name__, |
|
512 | argument='families', |
|
513 | arg_type='list', |
|
514 | ) |
|
515 | ||
516 | cmd = XmlCommand("modify_config") |
|
517 | cmd.set_attribute("config_id", str(config_id)) |
|
518 | ||
519 | _xmlfamsel = cmd.add_element("family_selection") |
|
520 | _xmlfamsel.add_element("growing", to_bool(auto_add_new_families)) |
|
521 | ||
522 | for family in families: |
|
523 | _xmlfamily = _xmlfamsel.add_element("family") |
|
524 | _xmlfamily.add_element("name", family[0]) |
|
525 | ||
526 | if len(family) != 3: |
|
527 | raise InvalidArgument( |
|
528 | "Family must be a tuple of 3. (str, bool, bool)" |
|
529 | ) |
|
530 | ||
531 | if not isinstance(family[1], bool) or not isinstance( |
|
532 | family[2], bool |
|
533 | ): |
|
534 | raise InvalidArgumentType( |
|
535 | function=( |
|
536 | self.modify_scan_config_set_family_selection.__name__ |
|
537 | ), |
|
538 | argument='families', |
|
539 | arg_type='[tuple(str, bool, bool)]', |
|
540 | ) |
|
541 | ||
542 | _xmlfamily.add_element("all", to_bool(family[2])) |
|
543 | _xmlfamily.add_element("growing", to_bool(family[1])) |
|
544 | ||
545 | return self._send_xml_command(cmd) |
|
546 | ||
547 | def modify_scan_config( |
|
548 | self, config_id: str, selection: Optional[str] = None, **kwargs |