@@ 5286-5359 (lines=74) @@ | ||
5283 | ||
5284 | return self._send_xml_command(cmd) |
|
5285 | ||
5286 | def modify_note( |
|
5287 | self, |
|
5288 | note_id: str, |
|
5289 | text: str, |
|
5290 | *, |
|
5291 | days_active: Optional[int] = None, |
|
5292 | hosts: Optional[List[str]] = None, |
|
5293 | port: Optional[int] = None, |
|
5294 | result_id: Optional[str] = None, |
|
5295 | severity: Optional[Severity] = None, |
|
5296 | task_id: Optional[str] = None, |
|
5297 | threat: Optional[SeverityLevel] = None, |
|
5298 | ) -> Any: |
|
5299 | """Modifies an existing note. |
|
5300 | ||
5301 | Arguments: |
|
5302 | note_id: UUID of note to modify. |
|
5303 | text: The text of the note. |
|
5304 | days_active: Days note will be active. -1 on always, 0 off. |
|
5305 | hosts: A list of hosts addresses |
|
5306 | port: Port to which note applies. |
|
5307 | result_id: Result to which note applies. |
|
5308 | severity: Severity to which note applies. |
|
5309 | task_id: Task to which note applies. |
|
5310 | threat: Threat level to which note applies. Will be converted to |
|
5311 | severity. |
|
5312 | ||
5313 | Returns: |
|
5314 | The response. See :py:meth:`send_command` for details. |
|
5315 | """ |
|
5316 | if not note_id: |
|
5317 | raise RequiredArgument( |
|
5318 | function=self.modify_note.__name__, argument='note_id' |
|
5319 | ) |
|
5320 | ||
5321 | if not text: |
|
5322 | raise RequiredArgument( |
|
5323 | function=self.modify_note.__name__, argument='text' |
|
5324 | ) |
|
5325 | ||
5326 | cmd = XmlCommand("modify_note") |
|
5327 | cmd.set_attribute("note_id", note_id) |
|
5328 | cmd.add_element("text", text) |
|
5329 | ||
5330 | if days_active is not None: |
|
5331 | cmd.add_element("active", str(days_active)) |
|
5332 | ||
5333 | if hosts: |
|
5334 | cmd.add_element("hosts", to_comma_list(hosts)) |
|
5335 | ||
5336 | if port: |
|
5337 | cmd.add_element("port", str(port)) |
|
5338 | ||
5339 | if result_id: |
|
5340 | cmd.add_element("result", attrs={"id": result_id}) |
|
5341 | ||
5342 | if severity: |
|
5343 | cmd.add_element("severity", str(severity)) |
|
5344 | ||
5345 | if task_id: |
|
5346 | cmd.add_element("task", attrs={"id": task_id}) |
|
5347 | ||
5348 | if threat is not None: |
|
5349 | ||
5350 | if not isinstance(threat, SeverityLevel): |
|
5351 | raise InvalidArgumentType( |
|
5352 | function=self.modify_note.__name__, |
|
5353 | argument='threat', |
|
5354 | arg_type=SeverityLevel.__name__, |
|
5355 | ) |
|
5356 | ||
5357 | cmd.add_element("threat", threat.value) |
|
5358 | ||
5359 | return self._send_xml_command(cmd) |
|
5360 | ||
5361 | def modify_override( |
|
5362 | self, |
|
@@ 3037-3110 (lines=74) @@ | ||
3034 | ||
3035 | return self._send_xml_command(cmd) |
|
3036 | ||
3037 | def create_note( |
|
3038 | self, |
|
3039 | text: str, |
|
3040 | nvt_oid: str, |
|
3041 | *, |
|
3042 | days_active: Optional[int] = None, |
|
3043 | hosts: Optional[List[str]] = None, |
|
3044 | port: Optional[int] = None, |
|
3045 | result_id: Optional[str] = None, |
|
3046 | severity: Optional[Severity] = None, |
|
3047 | task_id: Optional[str] = None, |
|
3048 | threat: Optional[SeverityLevel] = None, |
|
3049 | ) -> Any: |
|
3050 | """Create a new note |
|
3051 | ||
3052 | Arguments: |
|
3053 | text: Text of the new note |
|
3054 | nvt_id: OID of the nvt to which note applies |
|
3055 | days_active: Days note will be active. -1 on |
|
3056 | always, 0 off |
|
3057 | hosts: A list of hosts addresses |
|
3058 | port: Port to which the note applies |
|
3059 | result_id: UUID of a result to which note applies |
|
3060 | severity: Severity to which note applies |
|
3061 | task_id: UUID of task to which note applies |
|
3062 | threat: Severity level to which note applies. Will be converted to |
|
3063 | severity. |
|
3064 | ||
3065 | Returns: |
|
3066 | The response. See :py:meth:`send_command` for details. |
|
3067 | """ |
|
3068 | if not text: |
|
3069 | raise RequiredArgument( |
|
3070 | function=self.create_note.__name__, argument='text' |
|
3071 | ) |
|
3072 | ||
3073 | if not nvt_oid: |
|
3074 | raise RequiredArgument( |
|
3075 | function=self.create_note.__name__, argument='nvt_oid' |
|
3076 | ) |
|
3077 | ||
3078 | cmd = XmlCommand("create_note") |
|
3079 | cmd.add_element("text", text) |
|
3080 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
3081 | ||
3082 | if days_active is not None: |
|
3083 | cmd.add_element("active", str(days_active)) |
|
3084 | ||
3085 | if hosts: |
|
3086 | cmd.add_element("hosts", to_comma_list(hosts)) |
|
3087 | ||
3088 | if port: |
|
3089 | cmd.add_element("port", str(port)) |
|
3090 | ||
3091 | if result_id: |
|
3092 | cmd.add_element("result", attrs={"id": result_id}) |
|
3093 | ||
3094 | if severity: |
|
3095 | cmd.add_element("severity", str(severity)) |
|
3096 | ||
3097 | if task_id: |
|
3098 | cmd.add_element("task", attrs={"id": task_id}) |
|
3099 | ||
3100 | if threat is not None: |
|
3101 | if not isinstance(threat, SeverityLevel): |
|
3102 | raise InvalidArgumentType( |
|
3103 | function="create_note", |
|
3104 | argument="threat", |
|
3105 | arg_type=SeverityLevel.__name__, |
|
3106 | ) |
|
3107 | ||
3108 | cmd.add_element("threat", threat.value) |
|
3109 | ||
3110 | return self._send_xml_command(cmd) |
|
3111 | ||
3112 | def clone_note(self, note_id: str) -> Any: |
|
3113 | """Clone an existing note |