Code Duplication    Length = 24-24 lines in 2 locations

gvm/protocols/gmpv7.py 1 location

@@ 672-695 (lines=24) @@
669
            _xmlkey = cmd.add_element("key")
670
            _xmlkey.add_element("private", private_key)
671
672
        if credential_type == "snmp":
673
            if auth_algorithm not in ("md5", "sha1"):
674
                raise InvalidArgument(
675
                    "create_credential requires auth_algorithm to be either "
676
                    "md5 or sha1"
677
                )
678
679
            cmd.add_element("auth_algorithm", auth_algorithm)
680
681
            if community:
682
                cmd.add_element("community", community)
683
684
            if privacy_algorithm is not None or privacy_password:
685
                _xmlprivacy = cmd.add_element("privacy")
686
687
                if privacy_algorithm is not None:
688
                    if privacy_algorithm not in ("aes", "des"):
689
                        raise InvalidArgument(
690
                            "create_credential requires algorithm to be either "
691
                            "aes or des"
692
                        )
693
694
                    _xmlprivacy.add_element("algorithm", privacy_algorithm)
695
696
                if privacy_password:
697
                    _xmlprivacy.add_element("password", privacy_password)
698

gvm/protocols/gmpv8.py 1 location

@@ 235-258 (lines=24) @@
232
            _xmlkey = cmd.add_element("key")
233
            _xmlkey.add_element("private", private_key)
234
235
        if credential_type == "snmp":
236
            if auth_algorithm not in ("md5", "sha1"):
237
                raise InvalidArgument(
238
                    "create_credential requires auth_algorithm to be either "
239
                    "md5 or sha1"
240
                )
241
242
            cmd.add_element("auth_algorithm", auth_algorithm)
243
244
            if community:
245
                cmd.add_element("community", community)
246
247
            if privacy_algorithm is not None or privacy_password:
248
                _xmlprivacy = cmd.add_element("privacy")
249
250
                if privacy_algorithm is not None:
251
                    if privacy_algorithm not in ("aes", "des"):
252
                        raise InvalidArgument(
253
                            "create_credential requires algorithm to be either "
254
                            "aes or des"
255
                        )
256
257
                    _xmlprivacy.add_element("algorithm", privacy_algorithm)
258
259
                if privacy_password:
260
                    _xmlprivacy.add_element("password", privacy_password)
261