@@ 978-1068 (lines=91) @@ | ||
975 | cmd.add_element("copy", note_id) |
|
976 | return self._send_xml_command(cmd) |
|
977 | ||
978 | def create_override( |
|
979 | self, |
|
980 | text: str, |
|
981 | nvt_oid: str, |
|
982 | *, |
|
983 | seconds_active: Optional[int] = None, |
|
984 | hosts: Optional[List[str]] = None, |
|
985 | port: Optional[int] = None, |
|
986 | result_id: Optional[str] = None, |
|
987 | severity: Optional[Severity] = None, |
|
988 | new_severity: Optional[Severity] = None, |
|
989 | task_id: Optional[str] = None, |
|
990 | threat: Optional[SeverityLevel] = None, |
|
991 | new_threat: Optional[SeverityLevel] = None |
|
992 | ) -> Any: |
|
993 | """Create a new override |
|
994 | ||
995 | Arguments: |
|
996 | text: Text of the new override |
|
997 | nvt_id: OID of the nvt to which override applies |
|
998 | seconds_active: Seconds override will be active. -1 on always, 0 off |
|
999 | hosts: A list of host addresses |
|
1000 | port: Port to which the override applies |
|
1001 | result_id: UUID of a result to which override applies |
|
1002 | severity: Severity to which override applies |
|
1003 | new_severity: New severity for result |
|
1004 | task_id: UUID of task to which override applies |
|
1005 | threat: Severity level to which override applies. Will be converted |
|
1006 | to severity. |
|
1007 | new_threat: New severity level for results. Will be converted to |
|
1008 | new_severity. |
|
1009 | ||
1010 | Returns: |
|
1011 | The response. See :py:meth:`send_command` for details. |
|
1012 | """ |
|
1013 | if not text: |
|
1014 | raise RequiredArgument( |
|
1015 | function=self.create_override.__name__, argument='text' |
|
1016 | ) |
|
1017 | ||
1018 | if not nvt_oid: |
|
1019 | raise RequiredArgument( |
|
1020 | function=self.create_override.__name__, argument='nvt_oid' |
|
1021 | ) |
|
1022 | ||
1023 | cmd = XmlCommand("create_override") |
|
1024 | cmd.add_element("text", text) |
|
1025 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
1026 | ||
1027 | if seconds_active is not None: |
|
1028 | cmd.add_element("active", str(seconds_active)) |
|
1029 | ||
1030 | if hosts: |
|
1031 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
1032 | ||
1033 | if port: |
|
1034 | cmd.add_element("port", str(port)) |
|
1035 | ||
1036 | if result_id: |
|
1037 | cmd.add_element("result", attrs={"id": result_id}) |
|
1038 | ||
1039 | if severity: |
|
1040 | cmd.add_element("severity", str(severity)) |
|
1041 | ||
1042 | if new_severity: |
|
1043 | cmd.add_element("new_severity", str(new_severity)) |
|
1044 | ||
1045 | if task_id: |
|
1046 | cmd.add_element("task", attrs={"id": task_id}) |
|
1047 | ||
1048 | if threat is not None: |
|
1049 | if not isinstance(threat, SeverityLevel): |
|
1050 | raise InvalidArgumentType( |
|
1051 | function=self.create_override.__name__, |
|
1052 | argument="threat", |
|
1053 | arg_type=SeverityLevel.__name__, |
|
1054 | ) |
|
1055 | ||
1056 | cmd.add_element("threat", threat.value) |
|
1057 | ||
1058 | if new_threat is not None: |
|
1059 | if not isinstance(new_threat, SeverityLevel): |
|
1060 | raise InvalidArgumentType( |
|
1061 | function=self.create_override.__name__, |
|
1062 | argument="new_threat", |
|
1063 | arg_type=SeverityLevel.__name__, |
|
1064 | ) |
|
1065 | ||
1066 | cmd.add_element("new_threat", new_threat.value) |
|
1067 | ||
1068 | return self._send_xml_command(cmd) |
|
1069 | ||
1070 | def clone_override(self, override_id: str) -> Any: |
|
1071 | """Clone an existing override |
|
@@ 4978-5067 (lines=90) @@ | ||
4975 | ||
4976 | return self._send_xml_command(cmd) |
|
4977 | ||
4978 | def modify_override( |
|
4979 | self, |
|
4980 | override_id: str, |
|
4981 | text: str, |
|
4982 | *, |
|
4983 | seconds_active: Optional[int] = None, |
|
4984 | hosts: Optional[List[str]] = None, |
|
4985 | port: Optional[int] = None, |
|
4986 | result_id: Optional[str] = None, |
|
4987 | severity: Optional[Severity] = None, |
|
4988 | new_severity: Optional[Severity] = None, |
|
4989 | task_id: Optional[str] = None, |
|
4990 | threat: Optional[SeverityLevel] = None, |
|
4991 | new_threat: Optional[SeverityLevel] = None |
|
4992 | ) -> Any: |
|
4993 | """Modifies an existing override. |
|
4994 | ||
4995 | Arguments: |
|
4996 | override_id: UUID of override to modify. |
|
4997 | text: The text of the override. |
|
4998 | seconds_active: Seconds override will be active. -1 on always, |
|
4999 | 0 off. |
|
5000 | hosts: A list of host addresses |
|
5001 | port: Port to which override applies. |
|
5002 | result_id: Result to which override applies. |
|
5003 | severity: Severity to which override applies. |
|
5004 | new_severity: New severity score for result. |
|
5005 | task_id: Task to which override applies. |
|
5006 | threat: Threat level to which override applies. |
|
5007 | Will be converted to severity. |
|
5008 | new_threat: New threat level for results. Will be converted to |
|
5009 | new_severity. |
|
5010 | ||
5011 | Returns: |
|
5012 | The response. See :py:meth:`send_command` for details. |
|
5013 | """ |
|
5014 | if not override_id: |
|
5015 | raise RequiredArgument( |
|
5016 | function=self.modify_override.__name__, argument='override_id' |
|
5017 | ) |
|
5018 | if not text: |
|
5019 | raise RequiredArgument( |
|
5020 | function=self.modify_override.__name__, argument='text' |
|
5021 | ) |
|
5022 | ||
5023 | cmd = XmlCommand("modify_override") |
|
5024 | cmd.set_attribute("override_id", override_id) |
|
5025 | cmd.add_element("text", text) |
|
5026 | ||
5027 | if seconds_active is not None: |
|
5028 | cmd.add_element("active", str(seconds_active)) |
|
5029 | ||
5030 | if hosts: |
|
5031 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
5032 | ||
5033 | if port: |
|
5034 | cmd.add_element("port", str(port)) |
|
5035 | ||
5036 | if result_id: |
|
5037 | cmd.add_element("result", attrs={"id": result_id}) |
|
5038 | ||
5039 | if severity: |
|
5040 | cmd.add_element("severity", str(severity)) |
|
5041 | ||
5042 | if new_severity: |
|
5043 | cmd.add_element("new_severity", str(new_severity)) |
|
5044 | ||
5045 | if task_id: |
|
5046 | cmd.add_element("task", attrs={"id": task_id}) |
|
5047 | ||
5048 | if threat is not None: |
|
5049 | if not isinstance(threat, SeverityLevel): |
|
5050 | raise InvalidArgumentType( |
|
5051 | function=self.modify_override.__name__, |
|
5052 | argument='threat', |
|
5053 | arg_type=SeverityLevel.__name__, |
|
5054 | ) |
|
5055 | cmd.add_element("threat", threat.value) |
|
5056 | ||
5057 | if new_threat is not None: |
|
5058 | if not isinstance(new_threat, SeverityLevel): |
|
5059 | raise InvalidArgumentType( |
|
5060 | function=self.modify_override.__name__, |
|
5061 | argument='new_threat', |
|
5062 | arg_type=SeverityLevel.__name__, |
|
5063 | ) |
|
5064 | ||
5065 | cmd.add_element("new_threat", new_threat.value) |
|
5066 | ||
5067 | return self._send_xml_command(cmd) |
|
5068 | ||
5069 | def modify_permission( |
|
5070 | self, |