| @@ 65-137 (lines=73) @@ | ||
| 62 | # Is authenticated on gvmd |
|
| 63 | self._authenticated = False |
|
| 64 | ||
| 65 | def create_note( |
|
| 66 | self, |
|
| 67 | text: str, |
|
| 68 | nvt_oid: str, |
|
| 69 | *, |
|
| 70 | days_active: Optional[int] = None, |
|
| 71 | hosts: Optional[List[str]] = None, |
|
| 72 | port: Optional[int] = None, |
|
| 73 | result_id: Optional[str] = None, |
|
| 74 | severity: Optional[Severity] = None, |
|
| 75 | task_id: Optional[str] = None, |
|
| 76 | threat: Optional[SeverityLevel] = None |
|
| 77 | ) -> Any: |
|
| 78 | """Create a new note |
|
| 79 | ||
| 80 | Arguments: |
|
| 81 | text: Text of the new note |
|
| 82 | nvt_id: OID of the nvt to which note applies |
|
| 83 | days_active: Days note will be active. -1 on |
|
| 84 | always, 0 off |
|
| 85 | hosts: A list of hosts addresses |
|
| 86 | port: Port to which the note applies |
|
| 87 | result_id: UUID of a result to which note applies |
|
| 88 | severity: Severity to which note applies |
|
| 89 | task_id: UUID of task to which note applies |
|
| 90 | threat: Severity level to which note applies. Will be converted to |
|
| 91 | severity. |
|
| 92 | ||
| 93 | Returns: |
|
| 94 | The response. See :py:meth:`send_command` for details. |
|
| 95 | """ |
|
| 96 | if not text: |
|
| 97 | raise RequiredArgument( |
|
| 98 | function=self.create_note.__name__, argument='text' |
|
| 99 | ) |
|
| 100 | ||
| 101 | if not nvt_oid: |
|
| 102 | raise RequiredArgument( |
|
| 103 | function=self.create_note.__name__, argument='nvt_oid' |
|
| 104 | ) |
|
| 105 | ||
| 106 | cmd = XmlCommand("create_note") |
|
| 107 | cmd.add_element("text", text) |
|
| 108 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
| 109 | ||
| 110 | if days_active is not None: |
|
| 111 | cmd.add_element("active", str(days_active)) |
|
| 112 | ||
| 113 | if hosts: |
|
| 114 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
| 115 | ||
| 116 | if port: |
|
| 117 | cmd.add_element("port", str(port)) |
|
| 118 | ||
| 119 | if result_id: |
|
| 120 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 121 | ||
| 122 | if severity: |
|
| 123 | cmd.add_element("severity", str(severity)) |
|
| 124 | ||
| 125 | if task_id: |
|
| 126 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 127 | ||
| 128 | if threat is not None: |
|
| 129 | deprecation( |
|
| 130 | "The threat parameter has been removed in GMP" |
|
| 131 | " version {}{}".format( |
|
| 132 | self.get_protocol_version()[0], |
|
| 133 | self.get_protocol_version()[1], |
|
| 134 | ) |
|
| 135 | ) |
|
| 136 | ||
| 137 | return self._send_xml_command(cmd) |
|
| 138 | ||
| 139 | def create_override( |
|
| 140 | self, |
|
| @@ 229-300 (lines=72) @@ | ||
| 226 | ||
| 227 | return self._send_xml_command(cmd) |
|
| 228 | ||
| 229 | def modify_note( |
|
| 230 | self, |
|
| 231 | note_id: str, |
|
| 232 | text: str, |
|
| 233 | *, |
|
| 234 | days_active: Optional[int] = None, |
|
| 235 | hosts: Optional[List[str]] = None, |
|
| 236 | port: Optional[int] = None, |
|
| 237 | result_id: Optional[str] = None, |
|
| 238 | severity: Optional[Severity] = None, |
|
| 239 | task_id: Optional[str] = None, |
|
| 240 | threat: Optional[SeverityLevel] = None |
|
| 241 | ) -> Any: |
|
| 242 | """Modifies an existing note. |
|
| 243 | ||
| 244 | Arguments: |
|
| 245 | note_id: UUID of note to modify. |
|
| 246 | text: The text of the note. |
|
| 247 | days_active: Days note will be active. -1 on always, 0 off. |
|
| 248 | hosts: A list of hosts addresses |
|
| 249 | port: Port to which note applies. |
|
| 250 | result_id: Result to which note applies. |
|
| 251 | severity: Severity to which note applies. |
|
| 252 | task_id: Task to which note applies. |
|
| 253 | threat: Threat level to which note applies. Will be converted to |
|
| 254 | severity. |
|
| 255 | ||
| 256 | Returns: |
|
| 257 | The response. See :py:meth:`send_command` for details. |
|
| 258 | """ |
|
| 259 | if not note_id: |
|
| 260 | raise RequiredArgument( |
|
| 261 | function=self.modify_note.__name__, argument='note_id' |
|
| 262 | ) |
|
| 263 | ||
| 264 | if not text: |
|
| 265 | raise RequiredArgument( |
|
| 266 | function=self.modify_note.__name__, argument='text' |
|
| 267 | ) |
|
| 268 | ||
| 269 | cmd = XmlCommand("modify_note") |
|
| 270 | cmd.set_attribute("note_id", note_id) |
|
| 271 | cmd.add_element("text", text) |
|
| 272 | ||
| 273 | if days_active is not None: |
|
| 274 | cmd.add_element("active", str(days_active)) |
|
| 275 | ||
| 276 | if hosts: |
|
| 277 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
| 278 | ||
| 279 | if port: |
|
| 280 | cmd.add_element("port", str(port)) |
|
| 281 | ||
| 282 | if result_id: |
|
| 283 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 284 | ||
| 285 | if severity: |
|
| 286 | cmd.add_element("severity", str(severity)) |
|
| 287 | ||
| 288 | if task_id: |
|
| 289 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 290 | ||
| 291 | if threat is not None: |
|
| 292 | deprecation( |
|
| 293 | "The threat parameter has been removed in GMP" |
|
| 294 | " version {}{}".format( |
|
| 295 | self.get_protocol_version()[0], |
|
| 296 | self.get_protocol_version()[1], |
|
| 297 | ) |
|
| 298 | ) |
|
| 299 | ||
| 300 | return self._send_xml_command(cmd) |
|
| 301 | ||
| 302 | def modify_override( |
|
| 303 | self, |
|