@@ 647-715 (lines=69) @@ | ||
644 | cmd.add_element('copy', note_id) |
|
645 | return self._send_xml_command(cmd) |
|
646 | ||
647 | def create_override(self, text, nvt_oid, seconds_active=None, hosts=None, |
|
648 | port=None, result_id=None, severity=None, comment=None, |
|
649 | new_severity=None, task_id=None, threat=None, |
|
650 | new_threat=None): |
|
651 | """Create a new override |
|
652 | ||
653 | Arguments: |
|
654 | text (str): Text of the new override |
|
655 | nvt_id (str): OID of the nvt to which override applies |
|
656 | seconds_active (int, optional): Seconds override will be active. |
|
657 | -1 on always, 0 off |
|
658 | comment (str, optional): Comment for the override |
|
659 | hosts (list, optional): A list of host addresses |
|
660 | port (str, optional): Port ot which the override applies |
|
661 | result_id (str, optional): UUID of a result to which override |
|
662 | applies |
|
663 | severity (decimal, optional): Severity to which override applies |
|
664 | new_severity (decimal, optional): New severity for result |
|
665 | task_id (str, optional): UUID of task to which override applies |
|
666 | threat (str, optional): Threat level to which override applies. Will |
|
667 | be converted to severity |
|
668 | new_threat (str, optional): New threat level for result, will be |
|
669 | converted to a new_severity |
|
670 | ||
671 | Returns: |
|
672 | The response. See :py:meth:`send_command` for details. |
|
673 | """ |
|
674 | if not text: |
|
675 | raise RequiredArgument('create_override requires a text argument') |
|
676 | ||
677 | if not nvt_oid: |
|
678 | raise RequiredArgument('create_override requires a nvt_oid ' |
|
679 | 'argument') |
|
680 | ||
681 | cmd = XmlCommand('create_override') |
|
682 | cmd.add_element('text', text) |
|
683 | cmd.add_element('nvt', attrs={'oid': nvt_oid}) |
|
684 | ||
685 | if not seconds_active is None: |
|
686 | cmd.add_element('active', str(seconds_active)) |
|
687 | ||
688 | if comment: |
|
689 | cmd.add_element('comment', comment) |
|
690 | ||
691 | if hosts: |
|
692 | cmd.add_element('hosts', ', '.join(hosts)) |
|
693 | ||
694 | if port: |
|
695 | cmd.add_element('port', port) |
|
696 | ||
697 | if result_id: |
|
698 | cmd.add_element('result', attrs={'id': result_id}) |
|
699 | ||
700 | if severity: |
|
701 | cmd.add_element('severity', severity) |
|
702 | ||
703 | if new_severity: |
|
704 | cmd.add_element('new_severity', new_severity) |
|
705 | ||
706 | if task_id: |
|
707 | cmd.add_element('task', attrs={'id': task_id}) |
|
708 | ||
709 | if threat: |
|
710 | cmd.add_element('threat', threat) |
|
711 | ||
712 | if new_threat: |
|
713 | cmd.add_element('new_threat', new_threat) |
|
714 | ||
715 | return self._send_xml_command(cmd) |
|
716 | ||
717 | def clone_override(self, override_id): |
|
718 | """Clone an existing override |
|
@@ 2710-2767 (lines=58) @@ | ||
2707 | ||
2708 | return self._send_xml_command(cmd) |
|
2709 | ||
2710 | def modify_override(self, override_id, text, seconds_active=None, |
|
2711 | hosts=None, port=None, result_id=None, severity=None, |
|
2712 | new_severity=None, task_id=None, threat=None, |
|
2713 | new_threat=None): |
|
2714 | """Modifies an existing override. |
|
2715 | ||
2716 | Arguments: |
|
2717 | override_id (str): UUID of override to modify. |
|
2718 | text (str): The text of the override. |
|
2719 | seconds_active (int, optional): Seconds override will be active. |
|
2720 | -1 on always, 0 off. |
|
2721 | hosts (list, optional): A list of host addresses |
|
2722 | port (str, optional): Port to which override applies. |
|
2723 | result_id (str, optional): Result to which override applies. |
|
2724 | severity (str, optional): Severity to which override applies. |
|
2725 | new_severity (str, optional): New severity score for result. |
|
2726 | task_id (str, optional): Task to which override applies. |
|
2727 | threat (str, optional): Threat level to which override applies. |
|
2728 | new_threat (str, optional): New threat level for results. |
|
2729 | """ |
|
2730 | if not override_id: |
|
2731 | raise RequiredArgument('modify_override requires a override_id ' |
|
2732 | 'argument') |
|
2733 | if not text: |
|
2734 | raise RequiredArgument('modify_override requires a text argument') |
|
2735 | ||
2736 | cmd = XmlCommand('modify_override') |
|
2737 | cmd.set_attribute('override_id', override_id) |
|
2738 | cmd.add_element('text', text) |
|
2739 | ||
2740 | if not seconds_active is None: |
|
2741 | cmd.add_element('active', str(seconds_active)) |
|
2742 | ||
2743 | if hosts: |
|
2744 | cmd.add_element('hosts', ', '.join(hosts)) |
|
2745 | ||
2746 | if port: |
|
2747 | cmd.add_element('port', port) |
|
2748 | ||
2749 | if result_id: |
|
2750 | cmd.add_element('result', attrs={'id': result_id}) |
|
2751 | ||
2752 | if severity: |
|
2753 | cmd.add_element('severity', severity) |
|
2754 | ||
2755 | if new_severity: |
|
2756 | cmd.add_element('new_severity', new_severity) |
|
2757 | ||
2758 | if task_id: |
|
2759 | cmd.add_element('task', attrs={'id': task_id}) |
|
2760 | ||
2761 | if threat: |
|
2762 | cmd.add_element('threat', threat) |
|
2763 | ||
2764 | if new_threat: |
|
2765 | cmd.add_element('new_threat', new_threat) |
|
2766 | ||
2767 | return self._send_xml_command(cmd) |
|
2768 | ||
2769 | def modify_permission(self, permission_id, comment=None, name=None, |
|
2770 | resource_id=None, resource_type=None, |