|
@@ 4205-4264 (lines=60) @@
|
| 4202 |
|
|
| 4203 |
|
return self._send_xml_command(cmd) |
| 4204 |
|
|
| 4205 |
|
def modify_note(self, note_id, text, *, seconds_active=None, hosts=None, |
| 4206 |
|
port=None, result_id=None, severity=None, task_id=None, |
| 4207 |
|
threat=None): |
| 4208 |
|
"""Modifies an existing note. |
| 4209 |
|
|
| 4210 |
|
Arguments: |
| 4211 |
|
note_id (str): UUID of note to modify. |
| 4212 |
|
text (str): The text of the note. |
| 4213 |
|
seconds_active (int, optional): Seconds note will be active. |
| 4214 |
|
-1 on always, 0 off. |
| 4215 |
|
hosts (list, optional): A list of hosts addresses |
| 4216 |
|
port (int, optional): Port to which note applies. |
| 4217 |
|
result_id (str, optional): Result to which note applies. |
| 4218 |
|
severity (descimal, optional): Severity to which note applies. |
| 4219 |
|
task_id (str, optional): Task to which note applies. |
| 4220 |
|
threat (str, optional): Threat level to which note applies. One of |
| 4221 |
|
High, Medium, Low, Alarm, Log or Debug. Will be converted to |
| 4222 |
|
severity. |
| 4223 |
|
|
| 4224 |
|
Returns: |
| 4225 |
|
The response. See :py:meth:`send_command` for details. |
| 4226 |
|
""" |
| 4227 |
|
if not note_id: |
| 4228 |
|
raise RequiredArgument('modify_note requires a note_id attribute') |
| 4229 |
|
|
| 4230 |
|
if not text: |
| 4231 |
|
raise RequiredArgument('modify_note requires a text element') |
| 4232 |
|
|
| 4233 |
|
cmd = XmlCommand('modify_note') |
| 4234 |
|
cmd.set_attribute('note_id', note_id) |
| 4235 |
|
cmd.add_element('text', text) |
| 4236 |
|
|
| 4237 |
|
if not seconds_active is None: |
| 4238 |
|
cmd.add_element('active', str(seconds_active)) |
| 4239 |
|
|
| 4240 |
|
if hosts: |
| 4241 |
|
cmd.add_element('hosts', ','.join(hosts)) |
| 4242 |
|
|
| 4243 |
|
if port: |
| 4244 |
|
cmd.add_element('port', str(port)) |
| 4245 |
|
|
| 4246 |
|
if result_id: |
| 4247 |
|
cmd.add_element('result', attrs={'id': result_id}) |
| 4248 |
|
|
| 4249 |
|
if severity: |
| 4250 |
|
cmd.add_element('severity', str(severity)) |
| 4251 |
|
|
| 4252 |
|
if task_id: |
| 4253 |
|
cmd.add_element('task', attrs={'id': task_id}) |
| 4254 |
|
|
| 4255 |
|
if threat is not None: |
| 4256 |
|
cmd.add_element('threat', threat) |
| 4257 |
|
|
| 4258 |
|
if threat not in THREAD_TYPES: |
| 4259 |
|
raise InvalidArgument( |
| 4260 |
|
'modify_note threat argument {0} is invalid. threat must ' |
| 4261 |
|
'be one of {1}'.format(threat, ', '.join(THREAD_TYPES)) |
| 4262 |
|
) |
| 4263 |
|
|
| 4264 |
|
return self._send_xml_command(cmd) |
| 4265 |
|
|
| 4266 |
|
def modify_override(self, override_id, text, *, seconds_active=None, |
| 4267 |
|
hosts=None, port=None, result_id=None, severity=None, |
|
@@ 820-879 (lines=60) @@
|
| 817 |
|
|
| 818 |
|
return self._send_xml_command(cmd) |
| 819 |
|
|
| 820 |
|
def create_note(self, text, nvt_oid, *, seconds_active=None, hosts=None, |
| 821 |
|
result_id=None, severity=None, task_id=None, threat=None, |
| 822 |
|
port=None): |
| 823 |
|
"""Create a new note |
| 824 |
|
|
| 825 |
|
Arguments: |
| 826 |
|
text (str): Text of the new note |
| 827 |
|
nvt_id (str): OID of the nvt to which note applies |
| 828 |
|
seconds_active (int, optional): Seconds note will be active. -1 on |
| 829 |
|
always, 0 off |
| 830 |
|
hosts (list, optional): A list of hosts addresses |
| 831 |
|
port (int, optional): Port to which the note applies |
| 832 |
|
result_id (str, optional): UUID of a result to which note applies |
| 833 |
|
severity (decimal, optional): Severity to which note applies |
| 834 |
|
task_id (str, optional): UUID of task to which note applies |
| 835 |
|
threat (str, optional): Threat level to which note applies. One of |
| 836 |
|
High, Medium, Low, Alarm, Log or Debug. Will be converted to |
| 837 |
|
severity. |
| 838 |
|
|
| 839 |
|
Returns: |
| 840 |
|
The response. See :py:meth:`send_command` for details. |
| 841 |
|
""" |
| 842 |
|
if not text: |
| 843 |
|
raise RequiredArgument('create_note requires a text argument') |
| 844 |
|
|
| 845 |
|
if not nvt_oid: |
| 846 |
|
raise RequiredArgument('create_note requires a nvt_oid argument') |
| 847 |
|
|
| 848 |
|
cmd = XmlCommand('create_note') |
| 849 |
|
cmd.add_element('text', text) |
| 850 |
|
cmd.add_element('nvt', attrs={"oid": nvt_oid}) |
| 851 |
|
|
| 852 |
|
if not seconds_active is None: |
| 853 |
|
cmd.add_element('active', str(seconds_active)) |
| 854 |
|
|
| 855 |
|
if hosts: |
| 856 |
|
cmd.add_element('hosts', ','.join(hosts)) |
| 857 |
|
|
| 858 |
|
if port: |
| 859 |
|
cmd.add_element('port', str(port)) |
| 860 |
|
|
| 861 |
|
if result_id: |
| 862 |
|
cmd.add_element('result', attrs={'id': result_id}) |
| 863 |
|
|
| 864 |
|
if severity: |
| 865 |
|
cmd.add_element('severity', str(severity)) |
| 866 |
|
|
| 867 |
|
if task_id: |
| 868 |
|
cmd.add_element('task', attrs={'id': task_id}) |
| 869 |
|
|
| 870 |
|
if threat is not None: |
| 871 |
|
if threat not in THREAD_TYPES: |
| 872 |
|
raise InvalidArgument( |
| 873 |
|
'create_note threat argument {0} is invalid. threat must ' |
| 874 |
|
'be one of {1}'.format(threat, ', '.join(THREAD_TYPES)) |
| 875 |
|
) |
| 876 |
|
|
| 877 |
|
cmd.add_element('threat', threat) |
| 878 |
|
|
| 879 |
|
return self._send_xml_command(cmd) |
| 880 |
|
|
| 881 |
|
def clone_note(self, note_id): |
| 882 |
|
"""Clone an existing note |