|
@@ 644-712 (lines=69) @@
|
| 641 |
|
cmd.add_element('copy', note_id) |
| 642 |
|
return self._send_xml_command(cmd) |
| 643 |
|
|
| 644 |
|
def create_override(self, text, nvt_oid, seconds_active=None, hosts=None, |
| 645 |
|
port=None, result_id=None, severity=None, comment=None, |
| 646 |
|
new_severity=None, task_id=None, threat=None, |
| 647 |
|
new_threat=None): |
| 648 |
|
"""Create a new override |
| 649 |
|
|
| 650 |
|
Arguments: |
| 651 |
|
text (str): Text of the new override |
| 652 |
|
nvt_id (str): OID of the nvt to which override applies |
| 653 |
|
seconds_active (int, optional): Seconds override will be active. |
| 654 |
|
-1 on always, 0 off |
| 655 |
|
comment (str, optional): Comment for the override |
| 656 |
|
hosts (list, optional): A list of host addresses |
| 657 |
|
port (str, optional): Port to which the override applies |
| 658 |
|
result_id (str, optional): UUID of a result to which override |
| 659 |
|
applies |
| 660 |
|
severity (decimal, optional): Severity to which override applies |
| 661 |
|
new_severity (decimal, optional): New severity for result |
| 662 |
|
task_id (str, optional): UUID of task to which override applies |
| 663 |
|
threat (str, optional): Threat level to which override applies. Will |
| 664 |
|
be converted to severity |
| 665 |
|
new_threat (str, optional): New threat level for result, will be |
| 666 |
|
converted to a new_severity |
| 667 |
|
|
| 668 |
|
Returns: |
| 669 |
|
The response. See :py:meth:`send_command` for details. |
| 670 |
|
""" |
| 671 |
|
if not text: |
| 672 |
|
raise RequiredArgument('create_override requires a text argument') |
| 673 |
|
|
| 674 |
|
if not nvt_oid: |
| 675 |
|
raise RequiredArgument('create_override requires a nvt_oid ' |
| 676 |
|
'argument') |
| 677 |
|
|
| 678 |
|
cmd = XmlCommand('create_override') |
| 679 |
|
cmd.add_element('text', text) |
| 680 |
|
cmd.add_element('nvt', attrs={'oid': nvt_oid}) |
| 681 |
|
|
| 682 |
|
if not seconds_active is None: |
| 683 |
|
cmd.add_element('active', str(seconds_active)) |
| 684 |
|
|
| 685 |
|
if comment: |
| 686 |
|
cmd.add_element('comment', comment) |
| 687 |
|
|
| 688 |
|
if hosts: |
| 689 |
|
cmd.add_element('hosts', ', '.join(hosts)) |
| 690 |
|
|
| 691 |
|
if port: |
| 692 |
|
cmd.add_element('port', port) |
| 693 |
|
|
| 694 |
|
if result_id: |
| 695 |
|
cmd.add_element('result', attrs={'id': result_id}) |
| 696 |
|
|
| 697 |
|
if severity: |
| 698 |
|
cmd.add_element('severity', severity) |
| 699 |
|
|
| 700 |
|
if new_severity: |
| 701 |
|
cmd.add_element('new_severity', new_severity) |
| 702 |
|
|
| 703 |
|
if task_id: |
| 704 |
|
cmd.add_element('task', attrs={'id': task_id}) |
| 705 |
|
|
| 706 |
|
if threat: |
| 707 |
|
cmd.add_element('threat', threat) |
| 708 |
|
|
| 709 |
|
if new_threat: |
| 710 |
|
cmd.add_element('new_threat', new_threat) |
| 711 |
|
|
| 712 |
|
return self._send_xml_command(cmd) |
| 713 |
|
|
| 714 |
|
def clone_override(self, override_id): |
| 715 |
|
"""Clone an existing override |
|
@@ 3442-3499 (lines=58) @@
|
| 3439 |
|
|
| 3440 |
|
return self._send_xml_command(cmd) |
| 3441 |
|
|
| 3442 |
|
def modify_override(self, override_id, text, seconds_active=None, |
| 3443 |
|
hosts=None, port=None, result_id=None, severity=None, |
| 3444 |
|
new_severity=None, task_id=None, threat=None, |
| 3445 |
|
new_threat=None): |
| 3446 |
|
"""Modifies an existing override. |
| 3447 |
|
|
| 3448 |
|
Arguments: |
| 3449 |
|
override_id (str): UUID of override to modify. |
| 3450 |
|
text (str): The text of the override. |
| 3451 |
|
seconds_active (int, optional): Seconds override will be active. |
| 3452 |
|
-1 on always, 0 off. |
| 3453 |
|
hosts (list, optional): A list of host addresses |
| 3454 |
|
port (str, optional): Port to which override applies. |
| 3455 |
|
result_id (str, optional): Result to which override applies. |
| 3456 |
|
severity (str, optional): Severity to which override applies. |
| 3457 |
|
new_severity (str, optional): New severity score for result. |
| 3458 |
|
task_id (str, optional): Task to which override applies. |
| 3459 |
|
threat (str, optional): Threat level to which override applies. |
| 3460 |
|
new_threat (str, optional): New threat level for results. |
| 3461 |
|
""" |
| 3462 |
|
if not override_id: |
| 3463 |
|
raise RequiredArgument('modify_override requires a override_id ' |
| 3464 |
|
'argument') |
| 3465 |
|
if not text: |
| 3466 |
|
raise RequiredArgument('modify_override requires a text argument') |
| 3467 |
|
|
| 3468 |
|
cmd = XmlCommand('modify_override') |
| 3469 |
|
cmd.set_attribute('override_id', override_id) |
| 3470 |
|
cmd.add_element('text', text) |
| 3471 |
|
|
| 3472 |
|
if not seconds_active is None: |
| 3473 |
|
cmd.add_element('active', str(seconds_active)) |
| 3474 |
|
|
| 3475 |
|
if hosts: |
| 3476 |
|
cmd.add_element('hosts', ', '.join(hosts)) |
| 3477 |
|
|
| 3478 |
|
if port: |
| 3479 |
|
cmd.add_element('port', port) |
| 3480 |
|
|
| 3481 |
|
if result_id: |
| 3482 |
|
cmd.add_element('result', attrs={'id': result_id}) |
| 3483 |
|
|
| 3484 |
|
if severity: |
| 3485 |
|
cmd.add_element('severity', severity) |
| 3486 |
|
|
| 3487 |
|
if new_severity: |
| 3488 |
|
cmd.add_element('new_severity', new_severity) |
| 3489 |
|
|
| 3490 |
|
if task_id: |
| 3491 |
|
cmd.add_element('task', attrs={'id': task_id}) |
| 3492 |
|
|
| 3493 |
|
if threat: |
| 3494 |
|
cmd.add_element('threat', threat) |
| 3495 |
|
|
| 3496 |
|
if new_threat: |
| 3497 |
|
cmd.add_element('new_threat', new_threat) |
| 3498 |
|
|
| 3499 |
|
return self._send_xml_command(cmd) |
| 3500 |
|
|
| 3501 |
|
def modify_permission(self, permission_id, comment=None, name=None, |
| 3502 |
|
resource_id=None, resource_type=None, |