Code Duplication    Length = 79-82 lines in 2 locations

gvm/protocols/gmpv7.py 2 locations

@@ 957-1038 (lines=82) @@
954
        cmd.add_element("copy", note_id)
955
        return self._send_xml_command(cmd)
956
957
    def create_override(
958
        self,
959
        text,
960
        nvt_oid,
961
        *,
962
        seconds_active=None,
963
        hosts=None,
964
        port=None,
965
        result_id=None,
966
        severity=None,
967
        new_severity=None,
968
        task_id=None,
969
        threat=None,
970
        new_threat=None
971
    ):
972
        """Create a new override
973
974
        Arguments:
975
            text (str): Text of the new override
976
            nvt_id (str): OID of the nvt to which override applies
977
            seconds_active (int, optional): Seconds override will be active.
978
                -1 on always, 0 off
979
            hosts (list, optional): A list of host addresses
980
            port (int, optional): Port to which the override applies
981
            result_id (str, optional): UUID of a result to which override
982
                applies
983
            severity (decimal, optional): Severity to which override applies
984
            new_severity (decimal, optional): New severity for result
985
            task_id (str, optional): UUID of task to which override applies
986
            threat (str, optional): Threat level to which override applies. One
987
                of High, Medium, Low, Alarm, Log or Debug. Will be converted to
988
                severity.
989
            new_threat (str, optional): New threat level for results. One
990
                of High, Medium, Low, Alarm, Log or Debug. Will be converted to
991
                new_severity.
992
993
        Returns:
994
            The response. See :py:meth:`send_command` for details.
995
        """
996
        if not text:
997
            raise RequiredArgument("create_override requires a text argument")
998
999
        if not nvt_oid:
1000
            raise RequiredArgument(
1001
                "create_override requires a nvt_oid " "argument"
1002
            )
1003
1004
        cmd = XmlCommand("create_override")
1005
        cmd.add_element("text", text)
1006
        cmd.add_element("nvt", attrs={"oid": nvt_oid})
1007
1008
        if not seconds_active is None:
1009
            cmd.add_element("active", str(seconds_active))
1010
1011
        if hosts:
1012
            cmd.add_element("hosts", _to_comma_list(hosts))
1013
1014
        if port:
1015
            cmd.add_element("port", str(port))
1016
1017
        if result_id:
1018
            cmd.add_element("result", attrs={"id": result_id})
1019
1020
        if severity:
1021
            cmd.add_element("severity", str(severity))
1022
1023
        if new_severity:
1024
            cmd.add_element("new_severity", str(new_severity))
1025
1026
        if task_id:
1027
            cmd.add_element("task", attrs={"id": task_id})
1028
1029
        if threat is not None:
1030
            if threat not in THREAD_TYPES:
1031
                raise InvalidArgument(
1032
                    "create_override threat argument {0} is invalid. threat"
1033
                    "must be one of {1}".format(threat, ", ".join(THREAD_TYPES))
1034
                )
1035
1036
            cmd.add_element("threat", threat)
1037
1038
        if new_threat is not None:
1039
            if new_threat not in THREAD_TYPES:
1040
                raise InvalidArgument(
1041
                    "create_override new_threat argument {0} is invalid. "
@@ 4686-4764 (lines=79) @@
4683
4684
        return self._send_xml_command(cmd)
4685
4686
    def modify_override(
4687
        self,
4688
        override_id,
4689
        text,
4690
        *,
4691
        seconds_active=None,
4692
        hosts=None,
4693
        port=None,
4694
        result_id=None,
4695
        severity=None,
4696
        new_severity=None,
4697
        task_id=None,
4698
        threat=None,
4699
        new_threat=None
4700
    ):
4701
        """Modifies an existing override.
4702
4703
        Arguments:
4704
            override_id (str): UUID of override to modify.
4705
            text (str): The text of the override.
4706
            seconds_active (int, optional): Seconds override will be active.
4707
                -1 on always, 0 off.
4708
            hosts (list, optional): A list of host addresses
4709
            port (int, optional): Port to which override applies.
4710
            result_id (str, optional): Result to which override applies.
4711
            severity (decimal, optional): Severity to which override applies.
4712
            new_severity (decimal, optional): New severity score for result.
4713
            task_id (str, optional): Task to which override applies.
4714
            threat (str, optional): Threat level to which override applies. One
4715
                of High, Medium, Low, Alarm, Log or Debug. Will be converted to
4716
                severity.
4717
            new_threat (str, optional): New threat level for results. One
4718
                of High, Medium, Low, Alarm, Log or Debug. Will be converted to
4719
                new_severity.
4720
4721
        Returns:
4722
            The response. See :py:meth:`send_command` for details.
4723
        """
4724
        if not override_id:
4725
            raise RequiredArgument(
4726
                "modify_override requires a override_id " "argument"
4727
            )
4728
        if not text:
4729
            raise RequiredArgument("modify_override requires a text argument")
4730
4731
        cmd = XmlCommand("modify_override")
4732
        cmd.set_attribute("override_id", override_id)
4733
        cmd.add_element("text", text)
4734
4735
        if not seconds_active is None:
4736
            cmd.add_element("active", str(seconds_active))
4737
4738
        if hosts:
4739
            cmd.add_element("hosts", _to_comma_list(hosts))
4740
4741
        if port:
4742
            cmd.add_element("port", str(port))
4743
4744
        if result_id:
4745
            cmd.add_element("result", attrs={"id": result_id})
4746
4747
        if severity:
4748
            cmd.add_element("severity", str(severity))
4749
4750
        if new_severity:
4751
            cmd.add_element("new_severity", str(new_severity))
4752
4753
        if task_id:
4754
            cmd.add_element("task", attrs={"id": task_id})
4755
4756
        if threat is not None:
4757
            if threat not in THREAD_TYPES:
4758
                raise InvalidArgument(
4759
                    "modify_override threat argument {0} is invalid. threat"
4760
                    "must be one of {1}".format(threat, ", ".join(THREAD_TYPES))
4761
                )
4762
            cmd.add_element("threat", threat)
4763
4764
        if new_threat is not None:
4765
            if new_threat not in THREAD_TYPES:
4766
                raise InvalidArgument(
4767
                    "modify_override new_threat argument {0} is invalid. "