| @@ 3123-3196 (lines=74) @@ | ||
| 3120 | ||
| 3121 | return self._send_xml_command(cmd) |
|
| 3122 | ||
| 3123 | def create_note( |
|
| 3124 | self, |
|
| 3125 | text: str, |
|
| 3126 | nvt_oid: str, |
|
| 3127 | *, |
|
| 3128 | days_active: Optional[int] = None, |
|
| 3129 | hosts: Optional[List[str]] = None, |
|
| 3130 | port: Optional[int] = None, |
|
| 3131 | result_id: Optional[str] = None, |
|
| 3132 | severity: Optional[Severity] = None, |
|
| 3133 | task_id: Optional[str] = None, |
|
| 3134 | threat: Optional[SeverityLevel] = None, |
|
| 3135 | ) -> Any: |
|
| 3136 | """Create a new note |
|
| 3137 | ||
| 3138 | Arguments: |
|
| 3139 | text: Text of the new note |
|
| 3140 | nvt_id: OID of the nvt to which note applies |
|
| 3141 | days_active: Days note will be active. -1 on |
|
| 3142 | always, 0 off |
|
| 3143 | hosts: A list of hosts addresses |
|
| 3144 | port: Port to which the note applies |
|
| 3145 | result_id: UUID of a result to which note applies |
|
| 3146 | severity: Severity to which note applies |
|
| 3147 | task_id: UUID of task to which note applies |
|
| 3148 | threat: Severity level to which note applies. Will be converted to |
|
| 3149 | severity. |
|
| 3150 | ||
| 3151 | Returns: |
|
| 3152 | The response. See :py:meth:`send_command` for details. |
|
| 3153 | """ |
|
| 3154 | if not text: |
|
| 3155 | raise RequiredArgument( |
|
| 3156 | function=self.create_note.__name__, argument='text' |
|
| 3157 | ) |
|
| 3158 | ||
| 3159 | if not nvt_oid: |
|
| 3160 | raise RequiredArgument( |
|
| 3161 | function=self.create_note.__name__, argument='nvt_oid' |
|
| 3162 | ) |
|
| 3163 | ||
| 3164 | cmd = XmlCommand("create_note") |
|
| 3165 | cmd.add_element("text", text) |
|
| 3166 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
| 3167 | ||
| 3168 | if days_active is not None: |
|
| 3169 | cmd.add_element("active", str(days_active)) |
|
| 3170 | ||
| 3171 | if hosts: |
|
| 3172 | cmd.add_element("hosts", to_comma_list(hosts)) |
|
| 3173 | ||
| 3174 | if port: |
|
| 3175 | cmd.add_element("port", str(port)) |
|
| 3176 | ||
| 3177 | if result_id: |
|
| 3178 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 3179 | ||
| 3180 | if severity: |
|
| 3181 | cmd.add_element("severity", str(severity)) |
|
| 3182 | ||
| 3183 | if task_id: |
|
| 3184 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 3185 | ||
| 3186 | if threat is not None: |
|
| 3187 | if not isinstance(threat, SeverityLevel): |
|
| 3188 | raise InvalidArgumentType( |
|
| 3189 | function="create_note", |
|
| 3190 | argument="threat", |
|
| 3191 | arg_type=SeverityLevel.__name__, |
|
| 3192 | ) |
|
| 3193 | ||
| 3194 | cmd.add_element("threat", threat.value) |
|
| 3195 | ||
| 3196 | return self._send_xml_command(cmd) |
|
| 3197 | ||
| 3198 | def clone_note(self, note_id: str) -> Any: |
|
| 3199 | """Clone an existing note |
|
| @@ 5473-5546 (lines=74) @@ | ||
| 5470 | ||
| 5471 | return self._send_xml_command(cmd) |
|
| 5472 | ||
| 5473 | def modify_note( |
|
| 5474 | self, |
|
| 5475 | note_id: str, |
|
| 5476 | text: str, |
|
| 5477 | *, |
|
| 5478 | days_active: Optional[int] = None, |
|
| 5479 | hosts: Optional[List[str]] = None, |
|
| 5480 | port: Optional[int] = None, |
|
| 5481 | result_id: Optional[str] = None, |
|
| 5482 | severity: Optional[Severity] = None, |
|
| 5483 | task_id: Optional[str] = None, |
|
| 5484 | threat: Optional[SeverityLevel] = None, |
|
| 5485 | ) -> Any: |
|
| 5486 | """Modifies an existing note. |
|
| 5487 | ||
| 5488 | Arguments: |
|
| 5489 | note_id: UUID of note to modify. |
|
| 5490 | text: The text of the note. |
|
| 5491 | days_active: Days note will be active. -1 on always, 0 off. |
|
| 5492 | hosts: A list of hosts addresses |
|
| 5493 | port: Port to which note applies. |
|
| 5494 | result_id: Result to which note applies. |
|
| 5495 | severity: Severity to which note applies. |
|
| 5496 | task_id: Task to which note applies. |
|
| 5497 | threat: Threat level to which note applies. Will be converted to |
|
| 5498 | severity. |
|
| 5499 | ||
| 5500 | Returns: |
|
| 5501 | The response. See :py:meth:`send_command` for details. |
|
| 5502 | """ |
|
| 5503 | if not note_id: |
|
| 5504 | raise RequiredArgument( |
|
| 5505 | function=self.modify_note.__name__, argument='note_id' |
|
| 5506 | ) |
|
| 5507 | ||
| 5508 | if not text: |
|
| 5509 | raise RequiredArgument( |
|
| 5510 | function=self.modify_note.__name__, argument='text' |
|
| 5511 | ) |
|
| 5512 | ||
| 5513 | cmd = XmlCommand("modify_note") |
|
| 5514 | cmd.set_attribute("note_id", note_id) |
|
| 5515 | cmd.add_element("text", text) |
|
| 5516 | ||
| 5517 | if days_active is not None: |
|
| 5518 | cmd.add_element("active", str(days_active)) |
|
| 5519 | ||
| 5520 | if hosts: |
|
| 5521 | cmd.add_element("hosts", to_comma_list(hosts)) |
|
| 5522 | ||
| 5523 | if port: |
|
| 5524 | cmd.add_element("port", str(port)) |
|
| 5525 | ||
| 5526 | if result_id: |
|
| 5527 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 5528 | ||
| 5529 | if severity: |
|
| 5530 | cmd.add_element("severity", str(severity)) |
|
| 5531 | ||
| 5532 | if task_id: |
|
| 5533 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 5534 | ||
| 5535 | if threat is not None: |
|
| 5536 | ||
| 5537 | if not isinstance(threat, SeverityLevel): |
|
| 5538 | raise InvalidArgumentType( |
|
| 5539 | function=self.modify_note.__name__, |
|
| 5540 | argument='threat', |
|
| 5541 | arg_type=SeverityLevel.__name__, |
|
| 5542 | ) |
|
| 5543 | ||
| 5544 | cmd.add_element("threat", threat.value) |
|
| 5545 | ||
| 5546 | return self._send_xml_command(cmd) |
|
| 5547 | ||
| 5548 | def modify_override( |
|
| 5549 | self, |
|