@@ 852-920 (lines=69) @@ | ||
849 | cmd.add_element('copy', note_id) |
|
850 | return self._send_xml_command(cmd) |
|
851 | ||
852 | def create_override(self, text, nvt_oid, *, seconds_active=None, hosts=None, |
|
853 | port=None, result_id=None, severity=None, comment=None, |
|
854 | new_severity=None, task_id=None, threat=None, |
|
855 | new_threat=None): |
|
856 | """Create a new override |
|
857 | ||
858 | Arguments: |
|
859 | text (str): Text of the new override |
|
860 | nvt_id (str): OID of the nvt to which override applies |
|
861 | seconds_active (int, optional): Seconds override will be active. |
|
862 | -1 on always, 0 off |
|
863 | comment (str, optional): Comment for the override |
|
864 | hosts (list, optional): A list of host addresses |
|
865 | port (str, optional): Port to which the override applies |
|
866 | result_id (str, optional): UUID of a result to which override |
|
867 | applies |
|
868 | severity (decimal, optional): Severity to which override applies |
|
869 | new_severity (decimal, optional): New severity for result |
|
870 | task_id (str, optional): UUID of task to which override applies |
|
871 | threat (str, optional): Threat level to which override applies. Will |
|
872 | be converted to severity |
|
873 | new_threat (str, optional): New threat level for result, will be |
|
874 | converted to a new_severity |
|
875 | ||
876 | Returns: |
|
877 | The response. See :py:meth:`send_command` for details. |
|
878 | """ |
|
879 | if not text: |
|
880 | raise RequiredArgument('create_override requires a text argument') |
|
881 | ||
882 | if not nvt_oid: |
|
883 | raise RequiredArgument('create_override requires a nvt_oid ' |
|
884 | 'argument') |
|
885 | ||
886 | cmd = XmlCommand('create_override') |
|
887 | cmd.add_element('text', text) |
|
888 | cmd.add_element('nvt', attrs={'oid': nvt_oid}) |
|
889 | ||
890 | if not seconds_active is None: |
|
891 | cmd.add_element('active', str(seconds_active)) |
|
892 | ||
893 | if comment: |
|
894 | cmd.add_element('comment', comment) |
|
895 | ||
896 | if hosts: |
|
897 | cmd.add_element('hosts', ', '.join(hosts)) |
|
898 | ||
899 | if port: |
|
900 | cmd.add_element('port', port) |
|
901 | ||
902 | if result_id: |
|
903 | cmd.add_element('result', attrs={'id': result_id}) |
|
904 | ||
905 | if severity: |
|
906 | cmd.add_element('severity', severity) |
|
907 | ||
908 | if new_severity: |
|
909 | cmd.add_element('new_severity', new_severity) |
|
910 | ||
911 | if task_id: |
|
912 | cmd.add_element('task', attrs={'id': task_id}) |
|
913 | ||
914 | if threat: |
|
915 | cmd.add_element('threat', threat) |
|
916 | ||
917 | if new_threat: |
|
918 | cmd.add_element('new_threat', new_threat) |
|
919 | ||
920 | return self._send_xml_command(cmd) |
|
921 | ||
922 | def clone_override(self, override_id): |
|
923 | """Clone an existing override |
|
@@ 3818-3875 (lines=58) @@ | ||
3815 | ||
3816 | return self._send_xml_command(cmd) |
|
3817 | ||
3818 | def modify_override(self, override_id, text, *, seconds_active=None, |
|
3819 | hosts=None, port=None, result_id=None, severity=None, |
|
3820 | new_severity=None, task_id=None, threat=None, |
|
3821 | new_threat=None): |
|
3822 | """Modifies an existing override. |
|
3823 | ||
3824 | Arguments: |
|
3825 | override_id (str): UUID of override to modify. |
|
3826 | text (str): The text of the override. |
|
3827 | seconds_active (int, optional): Seconds override will be active. |
|
3828 | -1 on always, 0 off. |
|
3829 | hosts (list, optional): A list of host addresses |
|
3830 | port (str, optional): Port to which override applies. |
|
3831 | result_id (str, optional): Result to which override applies. |
|
3832 | severity (str, optional): Severity to which override applies. |
|
3833 | new_severity (str, optional): New severity score for result. |
|
3834 | task_id (str, optional): Task to which override applies. |
|
3835 | threat (str, optional): Threat level to which override applies. |
|
3836 | new_threat (str, optional): New threat level for results. |
|
3837 | ||
3838 | Returns: |
|
3839 | The response. See :py:meth:`send_command` for details. |
|
3840 | """ |
|
3841 | if not override_id: |
|
3842 | raise RequiredArgument('modify_override requires a override_id ' |
|
3843 | 'argument') |
|
3844 | if not text: |
|
3845 | raise RequiredArgument('modify_override requires a text argument') |
|
3846 | ||
3847 | cmd = XmlCommand('modify_override') |
|
3848 | cmd.set_attribute('override_id', override_id) |
|
3849 | cmd.add_element('text', text) |
|
3850 | ||
3851 | if not seconds_active is None: |
|
3852 | cmd.add_element('active', str(seconds_active)) |
|
3853 | ||
3854 | if hosts: |
|
3855 | cmd.add_element('hosts', ', '.join(hosts)) |
|
3856 | ||
3857 | if port: |
|
3858 | cmd.add_element('port', port) |
|
3859 | ||
3860 | if result_id: |
|
3861 | cmd.add_element('result', attrs={'id': result_id}) |
|
3862 | ||
3863 | if severity: |
|
3864 | cmd.add_element('severity', severity) |
|
3865 | ||
3866 | if new_severity: |
|
3867 | cmd.add_element('new_severity', new_severity) |
|
3868 | ||
3869 | if task_id: |
|
3870 | cmd.add_element('task', attrs={'id': task_id}) |
|
3871 | ||
3872 | if threat: |
|
3873 | cmd.add_element('threat', threat) |
|
3874 | ||
3875 | if new_threat: |
|
3876 | cmd.add_element('new_threat', new_threat) |
|
3877 | ||
3878 | return self._send_xml_command(cmd) |