| @@ 870-929 (lines=60) @@ | ||
| 867 | ||
| 868 | return self._send_xml_command(cmd) |
|
| 869 | ||
| 870 | def create_note( |
|
| 871 | self, |
|
| 872 | text, |
|
| 873 | nvt_oid, |
|
| 874 | *, |
|
| 875 | seconds_active=None, |
|
| 876 | hosts=None, |
|
| 877 | result_id=None, |
|
| 878 | severity=None, |
|
| 879 | task_id=None, |
|
| 880 | threat=None, |
|
| 881 | port=None |
|
| 882 | ): |
|
| 883 | """Create a new note |
|
| 884 | ||
| 885 | Arguments: |
|
| 886 | text (str): Text of the new note |
|
| 887 | nvt_id (str): OID of the nvt to which note applies |
|
| 888 | seconds_active (int, optional): Seconds note will be active. -1 on |
|
| 889 | always, 0 off |
|
| 890 | hosts (list, optional): A list of hosts addresses |
|
| 891 | port (int, optional): Port to which the note applies |
|
| 892 | result_id (str, optional): UUID of a result to which note applies |
|
| 893 | severity (decimal, optional): Severity to which note applies |
|
| 894 | task_id (str, optional): UUID of task to which note applies |
|
| 895 | threat (str, optional): Threat level to which note applies. One of |
|
| 896 | High, Medium, Low, Alarm, Log or Debug. Will be converted to |
|
| 897 | severity. |
|
| 898 | ||
| 899 | Returns: |
|
| 900 | The response. See :py:meth:`send_command` for details. |
|
| 901 | """ |
|
| 902 | if not text: |
|
| 903 | raise RequiredArgument("create_note requires a text argument") |
|
| 904 | ||
| 905 | if not nvt_oid: |
|
| 906 | raise RequiredArgument("create_note requires a nvt_oid argument") |
|
| 907 | ||
| 908 | cmd = XmlCommand("create_note") |
|
| 909 | cmd.add_element("text", text) |
|
| 910 | cmd.add_element("nvt", attrs={"oid": nvt_oid}) |
|
| 911 | ||
| 912 | if not seconds_active is None: |
|
| 913 | cmd.add_element("active", str(seconds_active)) |
|
| 914 | ||
| 915 | if hosts: |
|
| 916 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
| 917 | ||
| 918 | if port: |
|
| 919 | cmd.add_element("port", str(port)) |
|
| 920 | ||
| 921 | if result_id: |
|
| 922 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 923 | ||
| 924 | if severity: |
|
| 925 | cmd.add_element("severity", str(severity)) |
|
| 926 | ||
| 927 | if task_id: |
|
| 928 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 929 | ||
| 930 | if threat is not None: |
|
| 931 | if threat not in THREAD_TYPES: |
|
| 932 | raise InvalidArgument( |
|
| @@ 4615-4674 (lines=60) @@ | ||
| 4612 | ||
| 4613 | return self._send_xml_command(cmd) |
|
| 4614 | ||
| 4615 | def modify_note( |
|
| 4616 | self, |
|
| 4617 | note_id, |
|
| 4618 | text, |
|
| 4619 | *, |
|
| 4620 | seconds_active=None, |
|
| 4621 | hosts=None, |
|
| 4622 | port=None, |
|
| 4623 | result_id=None, |
|
| 4624 | severity=None, |
|
| 4625 | task_id=None, |
|
| 4626 | threat=None |
|
| 4627 | ): |
|
| 4628 | """Modifies an existing note. |
|
| 4629 | ||
| 4630 | Arguments: |
|
| 4631 | note_id (str): UUID of note to modify. |
|
| 4632 | text (str): The text of the note. |
|
| 4633 | seconds_active (int, optional): Seconds note will be active. |
|
| 4634 | -1 on always, 0 off. |
|
| 4635 | hosts (list, optional): A list of hosts addresses |
|
| 4636 | port (int, optional): Port to which note applies. |
|
| 4637 | result_id (str, optional): Result to which note applies. |
|
| 4638 | severity (descimal, optional): Severity to which note applies. |
|
| 4639 | task_id (str, optional): Task to which note applies. |
|
| 4640 | threat (str, optional): Threat level to which note applies. One of |
|
| 4641 | High, Medium, Low, Alarm, Log or Debug. Will be converted to |
|
| 4642 | severity. |
|
| 4643 | ||
| 4644 | Returns: |
|
| 4645 | The response. See :py:meth:`send_command` for details. |
|
| 4646 | """ |
|
| 4647 | if not note_id: |
|
| 4648 | raise RequiredArgument("modify_note requires a note_id attribute") |
|
| 4649 | ||
| 4650 | if not text: |
|
| 4651 | raise RequiredArgument("modify_note requires a text element") |
|
| 4652 | ||
| 4653 | cmd = XmlCommand("modify_note") |
|
| 4654 | cmd.set_attribute("note_id", note_id) |
|
| 4655 | cmd.add_element("text", text) |
|
| 4656 | ||
| 4657 | if not seconds_active is None: |
|
| 4658 | cmd.add_element("active", str(seconds_active)) |
|
| 4659 | ||
| 4660 | if hosts: |
|
| 4661 | cmd.add_element("hosts", _to_comma_list(hosts)) |
|
| 4662 | ||
| 4663 | if port: |
|
| 4664 | cmd.add_element("port", str(port)) |
|
| 4665 | ||
| 4666 | if result_id: |
|
| 4667 | cmd.add_element("result", attrs={"id": result_id}) |
|
| 4668 | ||
| 4669 | if severity: |
|
| 4670 | cmd.add_element("severity", str(severity)) |
|
| 4671 | ||
| 4672 | if task_id: |
|
| 4673 | cmd.add_element("task", attrs={"id": task_id}) |
|
| 4674 | ||
| 4675 | if threat is not None: |
|
| 4676 | cmd.add_element("threat", threat) |
|
| 4677 | ||