| @@ 5969-6042 (lines=74) @@ | ||
| 5966 | ||
| 5967 | return self._send_xml_command(cmd) |
|
| 5968 | ||
| 5969 | def modify_note( |
|
| 5970 | self, |
|
| 5971 | note_id: str, |
|
| 5972 | text: str, |
|
| 5973 | *, |
|
| 5974 | days_active: Optional[int] = None, |
|
| 5975 | hosts: Optional[List[str]] = None, |
|
| 5976 | port: Optional[int] = None, |
|
| 5977 | result_id: Optional[str] = None, |
|
| 5978 | severity: Optional[Severity] = None, |
|
| 5979 | task_id: Optional[str] = None, |
|
| 5980 | threat: Optional[SeverityLevel] = None, |
|
| 5981 | ) -> Any: |
|
| 5982 | """Modifies an existing note. |
|
| 5983 | ||
| 5984 | Arguments: |
|
| 5985 | note_id: UUID of note to modify. |
|
| 5986 | text: The text of the note. |
|
| 5987 | days_active: Days note will be active. -1 on always, 0 off. |
|
| 5988 | hosts: A list of hosts addresses |
|
| 5989 | port: Port to which note applies. |
|
| 5990 | result_id: Result to which note applies. |
|
| 5991 | severity: Severity to which note applies. |
|
| 5992 | task_id: Task to which note applies. |
|
| 5993 | threat: Threat level to which note applies. Will be converted to |
|
| 5994 | severity. |
|
| 5995 | ||
| 5996 | Returns: |
|
| 5997 | The response. See :py:meth:`send_command` for details. |
|
| 5998 | """ |
|
| 5999 | if not note_id: |
|
| 6000 | raise RequiredArgument( |
|
| 6001 | function=self.modify_note.__name__, argument='note_id' |
|
| 6002 | ) |
|
| 6003 | ||
| 6004 | if not text: |
|
| 6005 | raise RequiredArgument( |
|
| 6006 | function=self.modify_note.__name__, argument='text' |
|
| 6007 | ) |
|
| 6008 | ||
| 6009 | cmd = XmlCommand("modify_note") |
|
| 6010 | cmd.set_attribute("note_id", note_id) |
|
| 6011 | cmd.add_element("text", text) |
|
| 6012 | ||
| 6013 | if days_active is not None: |
|
| 6014 | cmd.add_element("active", str(days_active)) |
|
| 6015 | ||
| 6016 | if hosts: |
|
| 6017 | cmd.add_element("hosts", to_comma_list(hosts)) |
|
| 6018 | ||
| 6019 | if port: |
|
| 6020 | cmd.add_element("port", str(port)) |
|
| 6021 | ||
| 6022 | if result_id: |
|
| 6023 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 6024 | ||
| 6025 | if severity: |
|
| 6026 | cmd.add_element("severity", str(severity)) |
|
| 6027 | ||
| 6028 | if task_id: |
|
| 6029 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 6030 | ||
| 6031 | if threat is not None: |
|
| 6032 | ||
| 6033 | if not isinstance(threat, SeverityLevel): |
|
| 6034 | raise InvalidArgumentType( |
|
| 6035 | function=self.modify_note.__name__, |
|
| 6036 | argument='threat', |
|
| 6037 | arg_type=SeverityLevel.__name__, |
|
| 6038 | ) |
|
| 6039 | ||
| 6040 | cmd.add_element("threat", threat.value) |
|
| 6041 | ||
| 6042 | return self._send_xml_command(cmd) |
|
| 6043 | ||
| 6044 | def modify_override( |
|
| 6045 | self, |
|
| @@ 3251-3324 (lines=74) @@ | ||
| 3248 | ||
| 3249 | return self._send_xml_command(cmd) |
|
| 3250 | ||
| 3251 | def create_note( |
|
| 3252 | self, |
|
| 3253 | text: str, |
|
| 3254 | nvt_oid: str, |
|
| 3255 | *, |
|
| 3256 | days_active: Optional[int] = None, |
|
| 3257 | hosts: Optional[List[str]] = None, |
|
| 3258 | port: Optional[int] = None, |
|
| 3259 | result_id: Optional[str] = None, |
|
| 3260 | severity: Optional[Severity] = None, |
|
| 3261 | task_id: Optional[str] = None, |
|
| 3262 | threat: Optional[SeverityLevel] = None, |
|
| 3263 | ) -> Any: |
|
| 3264 | """Create a new note |
|
| 3265 | ||
| 3266 | Arguments: |
|
| 3267 | text: Text of the new note |
|
| 3268 | nvt_id: OID of the nvt to which note applies |
|
| 3269 | days_active: Days note will be active. -1 on |
|
| 3270 | always, 0 off |
|
| 3271 | hosts: A list of hosts addresses |
|
| 3272 | port: Port to which the note applies |
|
| 3273 | result_id: UUID of a result to which note applies |
|
| 3274 | severity: Severity to which note applies |
|
| 3275 | task_id: UUID of task to which note applies |
|
| 3276 | threat: Severity level to which note applies. Will be converted to |
|
| 3277 | severity. |
|
| 3278 | ||
| 3279 | Returns: |
|
| 3280 | The response. See :py:meth:`send_command` for details. |
|
| 3281 | """ |
|
| 3282 | if not text: |
|
| 3283 | raise RequiredArgument( |
|
| 3284 | function=self.create_note.__name__, argument='text' |
|
| 3285 | ) |
|
| 3286 | ||
| 3287 | if not nvt_oid: |
|
| 3288 | raise RequiredArgument( |
|
| 3289 | function=self.create_note.__name__, argument='nvt_oid' |
|
| 3290 | ) |
|
| 3291 | ||
| 3292 | cmd = XmlCommand("create_note") |
|
| 3293 | cmd.add_element("text", text) |
|
| 3294 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
| 3295 | ||
| 3296 | if days_active is not None: |
|
| 3297 | cmd.add_element("active", str(days_active)) |
|
| 3298 | ||
| 3299 | if hosts: |
|
| 3300 | cmd.add_element("hosts", to_comma_list(hosts)) |
|
| 3301 | ||
| 3302 | if port: |
|
| 3303 | cmd.add_element("port", str(port)) |
|
| 3304 | ||
| 3305 | if result_id: |
|
| 3306 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 3307 | ||
| 3308 | if severity: |
|
| 3309 | cmd.add_element("severity", str(severity)) |
|
| 3310 | ||
| 3311 | if task_id: |
|
| 3312 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 3313 | ||
| 3314 | if threat is not None: |
|
| 3315 | if not isinstance(threat, SeverityLevel): |
|
| 3316 | raise InvalidArgumentType( |
|
| 3317 | function="create_note", |
|
| 3318 | argument="threat", |
|
| 3319 | arg_type=SeverityLevel.__name__, |
|
| 3320 | ) |
|
| 3321 | ||
| 3322 | cmd.add_element("threat", threat.value) |
|
| 3323 | ||
| 3324 | return self._send_xml_command(cmd) |
|
| 3325 | ||
| 3326 | def clone_note(self, note_id: str) -> Any: |
|
| 3327 | """Clone an existing note |
|