| @@ 6245-6318 (lines=74) @@ | ||
| 6242 | ||
| 6243 | return self._send_xml_command(cmd) |
|
| 6244 | ||
| 6245 | def modify_note( |
|
| 6246 | self, |
|
| 6247 | note_id: str, |
|
| 6248 | text: str, |
|
| 6249 | *, |
|
| 6250 | days_active: Optional[int] = None, |
|
| 6251 | hosts: Optional[List[str]] = None, |
|
| 6252 | port: Optional[int] = None, |
|
| 6253 | result_id: Optional[str] = None, |
|
| 6254 | severity: Optional[Severity] = None, |
|
| 6255 | task_id: Optional[str] = None, |
|
| 6256 | threat: Optional[SeverityLevel] = None, |
|
| 6257 | ) -> Any: |
|
| 6258 | """Modifies an existing note. |
|
| 6259 | ||
| 6260 | Arguments: |
|
| 6261 | note_id: UUID of note to modify. |
|
| 6262 | text: The text of the note. |
|
| 6263 | days_active: Days note will be active. -1 on always, 0 off. |
|
| 6264 | hosts: A list of hosts addresses |
|
| 6265 | port: Port to which note applies. |
|
| 6266 | result_id: Result to which note applies. |
|
| 6267 | severity: Severity to which note applies. |
|
| 6268 | task_id: Task to which note applies. |
|
| 6269 | threat: Threat level to which note applies. Will be converted to |
|
| 6270 | severity. |
|
| 6271 | ||
| 6272 | Returns: |
|
| 6273 | The response. See :py:meth:`send_command` for details. |
|
| 6274 | """ |
|
| 6275 | if not note_id: |
|
| 6276 | raise RequiredArgument( |
|
| 6277 | function=self.modify_note.__name__, argument='note_id' |
|
| 6278 | ) |
|
| 6279 | ||
| 6280 | if not text: |
|
| 6281 | raise RequiredArgument( |
|
| 6282 | function=self.modify_note.__name__, argument='text' |
|
| 6283 | ) |
|
| 6284 | ||
| 6285 | cmd = XmlCommand("modify_note") |
|
| 6286 | cmd.set_attribute("note_id", note_id) |
|
| 6287 | cmd.add_element("text", text) |
|
| 6288 | ||
| 6289 | if days_active is not None: |
|
| 6290 | cmd.add_element("active", str(days_active)) |
|
| 6291 | ||
| 6292 | if hosts: |
|
| 6293 | cmd.add_element("hosts", to_comma_list(hosts)) |
|
| 6294 | ||
| 6295 | if port: |
|
| 6296 | cmd.add_element("port", str(port)) |
|
| 6297 | ||
| 6298 | if result_id: |
|
| 6299 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 6300 | ||
| 6301 | if severity: |
|
| 6302 | cmd.add_element("severity", str(severity)) |
|
| 6303 | ||
| 6304 | if task_id: |
|
| 6305 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 6306 | ||
| 6307 | if threat is not None: |
|
| 6308 | ||
| 6309 | if not isinstance(threat, SeverityLevel): |
|
| 6310 | raise InvalidArgumentType( |
|
| 6311 | function=self.modify_note.__name__, |
|
| 6312 | argument='threat', |
|
| 6313 | arg_type=SeverityLevel.__name__, |
|
| 6314 | ) |
|
| 6315 | ||
| 6316 | cmd.add_element("threat", threat.value) |
|
| 6317 | ||
| 6318 | return self._send_xml_command(cmd) |
|
| 6319 | ||
| 6320 | def modify_override( |
|
| 6321 | self, |
|
| @@ 3346-3419 (lines=74) @@ | ||
| 3343 | ||
| 3344 | return self._send_xml_command(cmd) |
|
| 3345 | ||
| 3346 | def create_note( |
|
| 3347 | self, |
|
| 3348 | text: str, |
|
| 3349 | nvt_oid: str, |
|
| 3350 | *, |
|
| 3351 | days_active: Optional[int] = None, |
|
| 3352 | hosts: Optional[List[str]] = None, |
|
| 3353 | port: Optional[int] = None, |
|
| 3354 | result_id: Optional[str] = None, |
|
| 3355 | severity: Optional[Severity] = None, |
|
| 3356 | task_id: Optional[str] = None, |
|
| 3357 | threat: Optional[SeverityLevel] = None, |
|
| 3358 | ) -> Any: |
|
| 3359 | """Create a new note |
|
| 3360 | ||
| 3361 | Arguments: |
|
| 3362 | text: Text of the new note |
|
| 3363 | nvt_id: OID of the nvt to which note applies |
|
| 3364 | days_active: Days note will be active. -1 on |
|
| 3365 | always, 0 off |
|
| 3366 | hosts: A list of hosts addresses |
|
| 3367 | port: Port to which the note applies |
|
| 3368 | result_id: UUID of a result to which note applies |
|
| 3369 | severity: Severity to which note applies |
|
| 3370 | task_id: UUID of task to which note applies |
|
| 3371 | threat: Severity level to which note applies. Will be converted to |
|
| 3372 | severity. |
|
| 3373 | ||
| 3374 | Returns: |
|
| 3375 | The response. See :py:meth:`send_command` for details. |
|
| 3376 | """ |
|
| 3377 | if not text: |
|
| 3378 | raise RequiredArgument( |
|
| 3379 | function=self.create_note.__name__, argument='text' |
|
| 3380 | ) |
|
| 3381 | ||
| 3382 | if not nvt_oid: |
|
| 3383 | raise RequiredArgument( |
|
| 3384 | function=self.create_note.__name__, argument='nvt_oid' |
|
| 3385 | ) |
|
| 3386 | ||
| 3387 | cmd = XmlCommand("create_note") |
|
| 3388 | cmd.add_element("text", text) |
|
| 3389 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
| 3390 | ||
| 3391 | if days_active is not None: |
|
| 3392 | cmd.add_element("active", str(days_active)) |
|
| 3393 | ||
| 3394 | if hosts: |
|
| 3395 | cmd.add_element("hosts", to_comma_list(hosts)) |
|
| 3396 | ||
| 3397 | if port: |
|
| 3398 | cmd.add_element("port", str(port)) |
|
| 3399 | ||
| 3400 | if result_id: |
|
| 3401 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 3402 | ||
| 3403 | if severity: |
|
| 3404 | cmd.add_element("severity", str(severity)) |
|
| 3405 | ||
| 3406 | if task_id: |
|
| 3407 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 3408 | ||
| 3409 | if threat is not None: |
|
| 3410 | if not isinstance(threat, SeverityLevel): |
|
| 3411 | raise InvalidArgumentType( |
|
| 3412 | function="create_note", |
|
| 3413 | argument="threat", |
|
| 3414 | arg_type=SeverityLevel.__name__, |
|
| 3415 | ) |
|
| 3416 | ||
| 3417 | cmd.add_element("threat", threat.value) |
|
| 3418 | ||
| 3419 | return self._send_xml_command(cmd) |
|
| 3420 | ||
| 3421 | def clone_note(self, note_id: str) -> Any: |
|
| 3422 | """Clone an existing note |
|