Code Duplication    Length = 60-60 lines in 2 locations

gvm/protocols/gmpv7/gmpv7.py 1 location

@@ 4767-4826 (lines=60) @@
4764
4765
        return self._send_xml_command(cmd)
4766
4767
    def modify_config_set_family_selection(
4768
        self,
4769
        config_id: str,
4770
        families: List[Tuple[str, bool, bool]],
4771
        *,
4772
        auto_add_new_families: Optional[bool] = True,
4773
    ) -> Any:
4774
        """
4775
        Selected the NVTs of a scan config at a family level.
4776
4777
        Arguments:
4778
            config_id: UUID of scan config to modify.
4779
            families: A list of tuples (str, bool, bool):
4780
                str: the name of the NVT family selected,
4781
                bool: add new NVTs  to the family automatically,
4782
                bool: include all NVTs from the family
4783
            auto_add_new_families: Whether new families should be added to the
4784
                scan config automatically. Default: True.
4785
        """
4786
        if not config_id:
4787
            raise RequiredArgument(
4788
                function=self.modify_config_set_family_selection.__name__,
4789
                argument='config_id',
4790
            )
4791
4792
        if not _is_list_like(families):
4793
            raise InvalidArgumentType(
4794
                function=self.modify_config_set_family_selection.__name__,
4795
                argument='families',
4796
                arg_type='list',
4797
            )
4798
4799
        cmd = XmlCommand("modify_config")
4800
        cmd.set_attribute("config_id", str(config_id))
4801
4802
        _xmlfamsel = cmd.add_element("family_selection")
4803
        _xmlfamsel.add_element("growing", _to_bool(auto_add_new_families))
4804
4805
        for family in families:
4806
            _xmlfamily = _xmlfamsel.add_element("family")
4807
            _xmlfamily.add_element("name", family[0])
4808
4809
            if len(family) != 3:
4810
                raise InvalidArgument(
4811
                    "Family must be a tuple of 3. (str, bool, bool)"
4812
                )
4813
4814
            if not isinstance(family[1], bool) or not isinstance(
4815
                family[2], bool
4816
            ):
4817
                raise InvalidArgumentType(
4818
                    function=self.modify_config_set_family_selection.__name__,
4819
                    argument='families',
4820
                    arg_type='[tuple(str, bool, bool)]',
4821
                )
4822
4823
            _xmlfamily.add_element("all", _to_bool(family[2]))
4824
            _xmlfamily.add_element("growing", _to_bool(family[1]))
4825
4826
        return self._send_xml_command(cmd)
4827
4828
    def modify_config(
4829
        self, config_id: str, selection: Optional[str] = None, **kwargs

gvm/protocols/gmpv208/gmpv208.py 1 location

@@ 6233-6292 (lines=60) @@
6230
6231
        return self._send_xml_command(cmd)
6232
6233
    def modify_config_set_family_selection(
6234
        self,
6235
        config_id: str,
6236
        families: List[Tuple[str, bool, bool]],
6237
        *,
6238
        auto_add_new_families: Optional[bool] = True,
6239
    ) -> Any:
6240
        """
6241
        Selected the NVTs of a scan config at a family level.
6242
6243
        Arguments:
6244
            config_id: UUID of scan config to modify.
6245
            families: A list of tuples (str, bool, bool):
6246
                str: the name of the NVT family selected,
6247
                bool: add new NVTs  to the family automatically,
6248
                bool: include all NVTs from the family
6249
            auto_add_new_families: Whether new families should be added to the
6250
                scan config automatically. Default: True.
6251
        """
6252
        if not config_id:
6253
            raise RequiredArgument(
6254
                function=self.modify_config_set_family_selection.__name__,
6255
                argument='config_id',
6256
            )
6257
6258
        if not _is_list_like(families):
6259
            raise InvalidArgumentType(
6260
                function=self.modify_config_set_family_selection.__name__,
6261
                argument='families',
6262
                arg_type='list',
6263
            )
6264
6265
        cmd = XmlCommand("modify_config")
6266
        cmd.set_attribute("config_id", str(config_id))
6267
6268
        _xmlfamsel = cmd.add_element("family_selection")
6269
        _xmlfamsel.add_element("growing", _to_bool(auto_add_new_families))
6270
6271
        for family in families:
6272
            _xmlfamily = _xmlfamsel.add_element("family")
6273
            _xmlfamily.add_element("name", family[0])
6274
6275
            if len(family) != 3:
6276
                raise InvalidArgument(
6277
                    "Family must be a tuple of 3. (str, bool, bool)"
6278
                )
6279
6280
            if not isinstance(family[1], bool) or not isinstance(
6281
                family[2], bool
6282
            ):
6283
                raise InvalidArgumentType(
6284
                    function=self.modify_config_set_family_selection.__name__,
6285
                    argument='families',
6286
                    arg_type='[tuple(str, bool, bool)]',
6287
                )
6288
6289
            _xmlfamily.add_element("all", _to_bool(family[2]))
6290
            _xmlfamily.add_element("growing", _to_bool(family[1]))
6291
6292
        return self._send_xml_command(cmd)
6293
6294
    def modify_config(
6295
        self, config_id: str, selection: Optional[str] = None, **kwargs