@@ 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 |
|
@@ 5049-5138 (lines=90) @@ | ||
5046 | ||
5047 | return self._send_xml_command(cmd) |
|
5048 | ||
5049 | def modify_override( |
|
5050 | self, |
|
5051 | override_id: str, |
|
5052 | text: str, |
|
5053 | *, |
|
5054 | seconds_active: Optional[int] = None, |
|
5055 | hosts: Optional[List[str]] = None, |
|
5056 | port: Optional[int] = None, |
|
5057 | result_id: Optional[str] = None, |
|
5058 | severity: Optional[Severity] = None, |
|
5059 | new_severity: Optional[Severity] = None, |
|
5060 | task_id: Optional[str] = None, |
|
5061 | threat: Optional[SeverityLevel] = None, |
|
5062 | new_threat: Optional[SeverityLevel] = None |
|
5063 | ) -> Any: |
|
5064 | """Modifies an existing override. |
|
5065 | ||
5066 | Arguments: |
|
5067 | override_id: UUID of override to modify. |
|
5068 | text: The text of the override. |
|
5069 | seconds_active: Seconds override will be active. -1 on always, |
|
5070 | 0 off. |
|
5071 | hosts: A list of host addresses |
|
5072 | port: Port to which override applies. |
|
5073 | result_id: Result to which override applies. |
|
5074 | severity: Severity to which override applies. |
|
5075 | new_severity: New severity score for result. |
|
5076 | task_id: Task to which override applies. |
|
5077 | threat: Threat level to which override applies. |
|
5078 | Will be converted to severity. |
|
5079 | new_threat: New threat level for results. Will be converted to |
|
5080 | new_severity. |
|
5081 | ||
5082 | Returns: |
|
5083 | The response. See :py:meth:`send_command` for details. |
|
5084 | """ |
|
5085 | if not override_id: |
|
5086 | raise RequiredArgument( |
|
5087 | function=self.modify_override.__name__, argument='override_id' |
|
5088 | ) |
|
5089 | if not text: |
|
5090 | raise RequiredArgument( |
|
5091 | function=self.modify_override.__name__, argument='text' |
|
5092 | ) |
|
5093 | ||
5094 | cmd = XmlCommand("modify_override") |
|
5095 | cmd.set_attribute("override_id", override_id) |
|
5096 | cmd.add_element("text", text) |
|
5097 | ||
5098 | if seconds_active is not None: |
|
5099 | cmd.add_element("active", str(seconds_active)) |
|
5100 | ||
5101 | if hosts: |
|
5102 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
5103 | ||
5104 | if port: |
|
5105 | cmd.add_element("port", str(port)) |
|
5106 | ||
5107 | if result_id: |
|
5108 | cmd.add_element("result", attrs={"id": result_id}) |
|
5109 | ||
5110 | if severity: |
|
5111 | cmd.add_element("severity", str(severity)) |
|
5112 | ||
5113 | if new_severity: |
|
5114 | cmd.add_element("new_severity", str(new_severity)) |
|
5115 | ||
5116 | if task_id: |
|
5117 | cmd.add_element("task", attrs={"id": task_id}) |
|
5118 | ||
5119 | if threat is not None: |
|
5120 | if not isinstance(threat, SeverityLevel): |
|
5121 | raise InvalidArgumentType( |
|
5122 | function=self.modify_override.__name__, |
|
5123 | argument='threat', |
|
5124 | arg_type=SeverityLevel.__name__, |
|
5125 | ) |
|
5126 | cmd.add_element("threat", threat.value) |
|
5127 | ||
5128 | if new_threat is not None: |
|
5129 | if not isinstance(new_threat, SeverityLevel): |
|
5130 | raise InvalidArgumentType( |
|
5131 | function=self.modify_override.__name__, |
|
5132 | argument='new_threat', |
|
5133 | arg_type=SeverityLevel.__name__, |
|
5134 | ) |
|
5135 | ||
5136 | cmd.add_element("new_threat", new_threat.value) |
|
5137 | ||
5138 | return self._send_xml_command(cmd) |
|
5139 | ||
5140 | def modify_permission( |
|
5141 | self, |