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