@@ 721-789 (lines=69) @@ | ||
718 | cmd.add_element('copy', note_id) |
|
719 | return self._send_xml_command(cmd) |
|
720 | ||
721 | def create_override(self, text, nvt_oid, *, seconds_active=None, hosts=None, |
|
722 | port=None, result_id=None, severity=None, comment=None, |
|
723 | new_severity=None, task_id=None, threat=None, |
|
724 | new_threat=None): |
|
725 | """Create a new override |
|
726 | ||
727 | Arguments: |
|
728 | text (str): Text of the new override |
|
729 | nvt_id (str): OID of the nvt to which override applies |
|
730 | seconds_active (int, optional): Seconds override will be active. |
|
731 | -1 on always, 0 off |
|
732 | comment (str, optional): Comment for the override |
|
733 | hosts (list, optional): A list of host addresses |
|
734 | port (str, optional): Port to which the override applies |
|
735 | result_id (str, optional): UUID of a result to which override |
|
736 | applies |
|
737 | severity (decimal, optional): Severity to which override applies |
|
738 | new_severity (decimal, optional): New severity for result |
|
739 | task_id (str, optional): UUID of task to which override applies |
|
740 | threat (str, optional): Threat level to which override applies. Will |
|
741 | be converted to severity |
|
742 | new_threat (str, optional): New threat level for result, will be |
|
743 | converted to a new_severity |
|
744 | ||
745 | Returns: |
|
746 | The response. See :py:meth:`send_command` for details. |
|
747 | """ |
|
748 | if not text: |
|
749 | raise RequiredArgument('create_override requires a text argument') |
|
750 | ||
751 | if not nvt_oid: |
|
752 | raise RequiredArgument('create_override requires a nvt_oid ' |
|
753 | 'argument') |
|
754 | ||
755 | cmd = XmlCommand('create_override') |
|
756 | cmd.add_element('text', text) |
|
757 | cmd.add_element('nvt', attrs={'oid': nvt_oid}) |
|
758 | ||
759 | if not seconds_active is None: |
|
760 | cmd.add_element('active', str(seconds_active)) |
|
761 | ||
762 | if comment: |
|
763 | cmd.add_element('comment', comment) |
|
764 | ||
765 | if hosts: |
|
766 | cmd.add_element('hosts', ', '.join(hosts)) |
|
767 | ||
768 | if port: |
|
769 | cmd.add_element('port', port) |
|
770 | ||
771 | if result_id: |
|
772 | cmd.add_element('result', attrs={'id': result_id}) |
|
773 | ||
774 | if severity: |
|
775 | cmd.add_element('severity', severity) |
|
776 | ||
777 | if new_severity: |
|
778 | cmd.add_element('new_severity', new_severity) |
|
779 | ||
780 | if task_id: |
|
781 | cmd.add_element('task', attrs={'id': task_id}) |
|
782 | ||
783 | if threat: |
|
784 | cmd.add_element('threat', threat) |
|
785 | ||
786 | if new_threat: |
|
787 | cmd.add_element('new_threat', new_threat) |
|
788 | ||
789 | return self._send_xml_command(cmd) |
|
790 | ||
791 | def clone_override(self, override_id): |
|
792 | """Clone an existing override |
|
@@ 3658-3715 (lines=58) @@ | ||
3655 | ||
3656 | return self._send_xml_command(cmd) |
|
3657 | ||
3658 | def modify_override(self, override_id, text, *, seconds_active=None, |
|
3659 | hosts=None, port=None, result_id=None, severity=None, |
|
3660 | new_severity=None, task_id=None, threat=None, |
|
3661 | new_threat=None): |
|
3662 | """Modifies an existing override. |
|
3663 | ||
3664 | Arguments: |
|
3665 | override_id (str): UUID of override to modify. |
|
3666 | text (str): The text of the override. |
|
3667 | seconds_active (int, optional): Seconds override will be active. |
|
3668 | -1 on always, 0 off. |
|
3669 | hosts (list, optional): A list of host addresses |
|
3670 | port (str, optional): Port to which override applies. |
|
3671 | result_id (str, optional): Result to which override applies. |
|
3672 | severity (str, optional): Severity to which override applies. |
|
3673 | new_severity (str, optional): New severity score for result. |
|
3674 | task_id (str, optional): Task to which override applies. |
|
3675 | threat (str, optional): Threat level to which override applies. |
|
3676 | new_threat (str, optional): New threat level for results. |
|
3677 | ||
3678 | Returns: |
|
3679 | The response. See :py:meth:`send_command` for details. |
|
3680 | """ |
|
3681 | if not override_id: |
|
3682 | raise RequiredArgument('modify_override requires a override_id ' |
|
3683 | 'argument') |
|
3684 | if not text: |
|
3685 | raise RequiredArgument('modify_override requires a text argument') |
|
3686 | ||
3687 | cmd = XmlCommand('modify_override') |
|
3688 | cmd.set_attribute('override_id', override_id) |
|
3689 | cmd.add_element('text', text) |
|
3690 | ||
3691 | if not seconds_active is None: |
|
3692 | cmd.add_element('active', str(seconds_active)) |
|
3693 | ||
3694 | if hosts: |
|
3695 | cmd.add_element('hosts', ', '.join(hosts)) |
|
3696 | ||
3697 | if port: |
|
3698 | cmd.add_element('port', port) |
|
3699 | ||
3700 | if result_id: |
|
3701 | cmd.add_element('result', attrs={'id': result_id}) |
|
3702 | ||
3703 | if severity: |
|
3704 | cmd.add_element('severity', severity) |
|
3705 | ||
3706 | if new_severity: |
|
3707 | cmd.add_element('new_severity', new_severity) |
|
3708 | ||
3709 | if task_id: |
|
3710 | cmd.add_element('task', attrs={'id': task_id}) |
|
3711 | ||
3712 | if threat: |
|
3713 | cmd.add_element('threat', threat) |
|
3714 | ||
3715 | if new_threat: |
|
3716 | cmd.add_element('new_threat', new_threat) |
|
3717 | ||
3718 | return self._send_xml_command(cmd) |