Code Duplication    Length = 58-69 lines in 2 locations

gvm/protocols/gmpv7.py 2 locations

@@ 749-817 (lines=69) @@
746
        cmd.add_element('copy', note_id)
747
        return self._send_xml_command(cmd)
748
749
    def create_override(self, text, nvt_oid, *, seconds_active=None, hosts=None,
750
                        port=None, result_id=None, severity=None, comment=None,
751
                        new_severity=None, task_id=None, threat=None,
752
                        new_threat=None):
753
        """Create a new override
754
755
        Arguments:
756
            text (str): Text of the new override
757
            nvt_id (str): OID of the nvt to which override applies
758
            seconds_active (int, optional): Seconds override will be active.
759
                -1 on always, 0 off
760
            comment (str, optional): Comment for the override
761
            hosts (list, optional): A list of host addresses
762
            port (str, optional): Port to which the override applies
763
            result_id (str, optional): UUID of a result to which override
764
                applies
765
            severity (decimal, optional): Severity to which override applies
766
            new_severity (decimal, optional): New severity for result
767
            task_id (str, optional): UUID of task to which override applies
768
            threat (str, optional): Threat level to which override applies. Will
769
                be converted to severity
770
            new_threat (str, optional): New threat level for result, will be
771
                converted to a new_severity
772
773
        Returns:
774
            The response. See :py:meth:`send_command` for details.
775
        """
776
        if not text:
777
            raise RequiredArgument('create_override requires a text argument')
778
779
        if not nvt_oid:
780
            raise RequiredArgument('create_override requires a nvt_oid '
781
                                   'argument')
782
783
        cmd = XmlCommand('create_override')
784
        cmd.add_element('text', text)
785
        cmd.add_element('nvt', attrs={'oid': nvt_oid})
786
787
        if not seconds_active is None:
788
            cmd.add_element('active', str(seconds_active))
789
790
        if comment:
791
            cmd.add_element('comment', comment)
792
793
        if hosts:
794
            cmd.add_element('hosts', ', '.join(hosts))
795
796
        if port:
797
            cmd.add_element('port', port)
798
799
        if result_id:
800
            cmd.add_element('result', attrs={'id': result_id})
801
802
        if severity:
803
            cmd.add_element('severity', severity)
804
805
        if new_severity:
806
            cmd.add_element('new_severity', new_severity)
807
808
        if task_id:
809
            cmd.add_element('task', attrs={'id': task_id})
810
811
        if threat:
812
            cmd.add_element('threat', threat)
813
814
        if new_threat:
815
            cmd.add_element('new_threat', new_threat)
816
817
        return self._send_xml_command(cmd)
818
819
    def clone_override(self, override_id):
820
        """Clone an existing override
@@ 3702-3759 (lines=58) @@
3699
3700
        return self._send_xml_command(cmd)
3701
3702
    def modify_override(self, override_id, text, *, seconds_active=None,
3703
                        hosts=None, port=None, result_id=None, severity=None,
3704
                        new_severity=None, task_id=None, threat=None,
3705
                        new_threat=None):
3706
        """Modifies an existing override.
3707
3708
        Arguments:
3709
            override_id (str): UUID of override to modify.
3710
            text (str): The text of the override.
3711
            seconds_active (int, optional): Seconds override will be active.
3712
                -1 on always, 0 off.
3713
            hosts (list, optional): A list of host addresses
3714
            port (str, optional): Port to which override applies.
3715
            result_id (str, optional): Result to which override applies.
3716
            severity (str, optional): Severity to which override applies.
3717
            new_severity (str, optional): New severity score for result.
3718
            task_id (str, optional): Task to which override applies.
3719
            threat (str, optional): Threat level to which override applies.
3720
            new_threat (str, optional): New threat level for results.
3721
3722
        Returns:
3723
            The response. See :py:meth:`send_command` for details.
3724
        """
3725
        if not override_id:
3726
            raise RequiredArgument('modify_override requires a override_id '
3727
                                   'argument')
3728
        if not text:
3729
            raise RequiredArgument('modify_override requires a text argument')
3730
3731
        cmd = XmlCommand('modify_override')
3732
        cmd.set_attribute('override_id', override_id)
3733
        cmd.add_element('text', text)
3734
3735
        if not seconds_active is None:
3736
            cmd.add_element('active', str(seconds_active))
3737
3738
        if hosts:
3739
            cmd.add_element('hosts', ', '.join(hosts))
3740
3741
        if port:
3742
            cmd.add_element('port', port)
3743
3744
        if result_id:
3745
            cmd.add_element('result', attrs={'id': result_id})
3746
3747
        if severity:
3748
            cmd.add_element('severity', severity)
3749
3750
        if new_severity:
3751
            cmd.add_element('new_severity', new_severity)
3752
3753
        if task_id:
3754
            cmd.add_element('task', attrs={'id': task_id})
3755
3756
        if threat:
3757
            cmd.add_element('threat', threat)
3758
3759
        if new_threat:
3760
            cmd.add_element('new_threat', new_threat)
3761
3762
        return self._send_xml_command(cmd)