| @@ 890-963 (lines=74) @@ | ||
| 887 | ||
| 888 | return self._send_xml_command(cmd) |
|
| 889 | ||
| 890 | def create_note( |
|
| 891 | self, |
|
| 892 | text: str, |
|
| 893 | nvt_oid: str, |
|
| 894 | *, |
|
| 895 | days_active: Optional[int] = None, |
|
| 896 | hosts: Optional[List[str]] = None, |
|
| 897 | port: Optional[int] = None, |
|
| 898 | result_id: Optional[str] = None, |
|
| 899 | severity: Optional[Severity] = None, |
|
| 900 | task_id: Optional[str] = None, |
|
| 901 | threat: Optional[SeverityLevel] = None |
|
| 902 | ) -> Any: |
|
| 903 | """Create a new note |
|
| 904 | ||
| 905 | Arguments: |
|
| 906 | text: Text of the new note |
|
| 907 | nvt_id: OID of the nvt to which note applies |
|
| 908 | days_active: Days note will be active. -1 on |
|
| 909 | always, 0 off |
|
| 910 | hosts: A list of hosts addresses |
|
| 911 | port: Port to which the note applies |
|
| 912 | result_id: UUID of a result to which note applies |
|
| 913 | severity: Severity to which note applies |
|
| 914 | task_id: UUID of task to which note applies |
|
| 915 | threat: Severity level to which note applies. Will be converted to |
|
| 916 | severity. |
|
| 917 | ||
| 918 | Returns: |
|
| 919 | The response. See :py:meth:`send_command` for details. |
|
| 920 | """ |
|
| 921 | if not text: |
|
| 922 | raise RequiredArgument( |
|
| 923 | function=self.create_note.__name__, argument='text' |
|
| 924 | ) |
|
| 925 | ||
| 926 | if not nvt_oid: |
|
| 927 | raise RequiredArgument( |
|
| 928 | function=self.create_note.__name__, argument='nvt_oid' |
|
| 929 | ) |
|
| 930 | ||
| 931 | cmd = XmlCommand("create_note") |
|
| 932 | cmd.add_element("text", text) |
|
| 933 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
| 934 | ||
| 935 | if days_active is not None: |
|
| 936 | cmd.add_element("active", str(days_active)) |
|
| 937 | ||
| 938 | if hosts: |
|
| 939 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
| 940 | ||
| 941 | if port: |
|
| 942 | cmd.add_element("port", str(port)) |
|
| 943 | ||
| 944 | if result_id: |
|
| 945 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 946 | ||
| 947 | if severity: |
|
| 948 | cmd.add_element("severity", str(severity)) |
|
| 949 | ||
| 950 | if task_id: |
|
| 951 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 952 | ||
| 953 | if threat is not None: |
|
| 954 | if not isinstance(threat, SeverityLevel): |
|
| 955 | raise InvalidArgumentType( |
|
| 956 | function="create_note", |
|
| 957 | argument="threat", |
|
| 958 | arg_type=SeverityLevel.__name__, |
|
| 959 | ) |
|
| 960 | ||
| 961 | cmd.add_element("threat", threat.value) |
|
| 962 | ||
| 963 | return self._send_xml_command(cmd) |
|
| 964 | ||
| 965 | def clone_note(self, note_id: str) -> Any: |
|
| 966 | """Clone an existing note |
|
| @@ 5058-5131 (lines=74) @@ | ||
| 5055 | ||
| 5056 | return self._send_xml_command(cmd) |
|
| 5057 | ||
| 5058 | def modify_note( |
|
| 5059 | self, |
|
| 5060 | note_id: str, |
|
| 5061 | text: str, |
|
| 5062 | *, |
|
| 5063 | days_active: Optional[int] = None, |
|
| 5064 | hosts: Optional[List[str]] = None, |
|
| 5065 | port: Optional[int] = None, |
|
| 5066 | result_id: Optional[str] = None, |
|
| 5067 | severity: Optional[Severity] = None, |
|
| 5068 | task_id: Optional[str] = None, |
|
| 5069 | threat: Optional[SeverityLevel] = None |
|
| 5070 | ) -> Any: |
|
| 5071 | """Modifies an existing note. |
|
| 5072 | ||
| 5073 | Arguments: |
|
| 5074 | note_id: UUID of note to modify. |
|
| 5075 | text: The text of the note. |
|
| 5076 | days_active: Days note will be active. -1 on always, 0 off. |
|
| 5077 | hosts: A list of hosts addresses |
|
| 5078 | port: Port to which note applies. |
|
| 5079 | result_id: Result to which note applies. |
|
| 5080 | severity: Severity to which note applies. |
|
| 5081 | task_id: Task to which note applies. |
|
| 5082 | threat: Threat level to which note applies. Will be converted to |
|
| 5083 | severity. |
|
| 5084 | ||
| 5085 | Returns: |
|
| 5086 | The response. See :py:meth:`send_command` for details. |
|
| 5087 | """ |
|
| 5088 | if not note_id: |
|
| 5089 | raise RequiredArgument( |
|
| 5090 | function=self.modify_note.__name__, argument='note_id' |
|
| 5091 | ) |
|
| 5092 | ||
| 5093 | if not text: |
|
| 5094 | raise RequiredArgument( |
|
| 5095 | function=self.modify_note.__name__, argument='text' |
|
| 5096 | ) |
|
| 5097 | ||
| 5098 | cmd = XmlCommand("modify_note") |
|
| 5099 | cmd.set_attribute("note_id", note_id) |
|
| 5100 | cmd.add_element("text", text) |
|
| 5101 | ||
| 5102 | if days_active is not None: |
|
| 5103 | cmd.add_element("active", str(days_active)) |
|
| 5104 | ||
| 5105 | if hosts: |
|
| 5106 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
| 5107 | ||
| 5108 | if port: |
|
| 5109 | cmd.add_element("port", str(port)) |
|
| 5110 | ||
| 5111 | if result_id: |
|
| 5112 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 5113 | ||
| 5114 | if severity: |
|
| 5115 | cmd.add_element("severity", str(severity)) |
|
| 5116 | ||
| 5117 | if task_id: |
|
| 5118 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 5119 | ||
| 5120 | if threat is not None: |
|
| 5121 | ||
| 5122 | if not isinstance(threat, SeverityLevel): |
|
| 5123 | raise InvalidArgumentType( |
|
| 5124 | function=self.modify_note.__name__, |
|
| 5125 | argument='threat', |
|
| 5126 | arg_type=SeverityLevel.__name__, |
|
| 5127 | ) |
|
| 5128 | ||
| 5129 | cmd.add_element("threat", threat.value) |
|
| 5130 | ||
| 5131 | return self._send_xml_command(cmd) |
|
| 5132 | ||
| 5133 | def modify_override( |
|
| 5134 | self, |
|