| @@ 4435-4541 (lines=107) @@ | ||
| 4432 | ||
| 4433 | return self._send_xml_command(cmd) |
|
| 4434 | ||
| 4435 | def modify_alert( |
|
| 4436 | self, |
|
| 4437 | alert_id: str, |
|
| 4438 | *, |
|
| 4439 | name: Optional[str] = None, |
|
| 4440 | comment: Optional[str] = None, |
|
| 4441 | filter_id: Optional[str] = None, |
|
| 4442 | event: Optional[AlertEvent] = None, |
|
| 4443 | event_data: Optional[dict] = None, |
|
| 4444 | condition: Optional[AlertCondition] = None, |
|
| 4445 | condition_data: Optional[dict] = None, |
|
| 4446 | method: Optional[AlertMethod] = None, |
|
| 4447 | method_data: Optional[dict] = None, |
|
| 4448 | ) -> Any: |
|
| 4449 | """Modifies an existing alert. |
|
| 4450 | ||
| 4451 | Arguments: |
|
| 4452 | alert_id: UUID of the alert to be modified. |
|
| 4453 | name: Name of the Alert. |
|
| 4454 | condition: The condition that must be satisfied for the alert to |
|
| 4455 | occur. If the event is either 'Updated SecInfo |
|
| 4456 | arrived' or 'New SecInfo arrived', condition must be 'Always'. |
|
| 4457 | Otherwise, condition can also be on of 'Severity at least', |
|
| 4458 | 'Filter count changed' or 'Filter count at least'. |
|
| 4459 | condition_data: Data that defines the condition |
|
| 4460 | event: The event that must happen for the alert to occur, one of |
|
| 4461 | 'Task run status changed', 'Updated SecInfo arrived' or |
|
| 4462 | 'New SecInfo arrived' |
|
| 4463 | event_data: Data that defines the event |
|
| 4464 | method: The method by which the user is alerted, one of 'SCP', |
|
| 4465 | 'Send', 'SMB', 'SNMP', 'Syslog' or 'Email'; |
|
| 4466 | if the event is neither 'Updated SecInfo arrived' nor |
|
| 4467 | 'New SecInfo arrived', method can also be one of 'Start Task', |
|
| 4468 | 'HTTP Get', 'Sourcefire Connector' or 'verinice Connector'. |
|
| 4469 | method_data: Data that defines the method |
|
| 4470 | filter_id: Filter to apply when executing alert |
|
| 4471 | comment: Comment for the alert |
|
| 4472 | ||
| 4473 | Returns: |
|
| 4474 | The response. See :py:meth:`send_command` for details. |
|
| 4475 | """ |
|
| 4476 | ||
| 4477 | if not alert_id: |
|
| 4478 | raise RequiredArgument( |
|
| 4479 | function=self.modify_alert.__name__, argument='alert_id' |
|
| 4480 | ) |
|
| 4481 | ||
| 4482 | cmd = XmlCommand("modify_alert") |
|
| 4483 | cmd.set_attribute("alert_id", str(alert_id)) |
|
| 4484 | ||
| 4485 | if name: |
|
| 4486 | cmd.add_element("name", name) |
|
| 4487 | ||
| 4488 | if comment: |
|
| 4489 | cmd.add_element("comment", comment) |
|
| 4490 | ||
| 4491 | if filter_id: |
|
| 4492 | cmd.add_element("filter", attrs={"id": filter_id}) |
|
| 4493 | ||
| 4494 | if condition: |
|
| 4495 | if not isinstance(condition, AlertCondition): |
|
| 4496 | raise InvalidArgumentType( |
|
| 4497 | function=self.modify_alert.__name__, |
|
| 4498 | argument='condition', |
|
| 4499 | arg_type=AlertCondition.__name__, |
|
| 4500 | ) |
|
| 4501 | ||
| 4502 | conditions = cmd.add_element("condition", condition.value) |
|
| 4503 | ||
| 4504 | if condition_data is not None: |
|
| 4505 | for key, value in condition_data.items(): |
|
| 4506 | _data = conditions.add_element("data", value) |
|
| 4507 | _data.add_element("name", key) |
|
| 4508 | ||
| 4509 | if method: |
|
| 4510 | if not isinstance(method, AlertMethod): |
|
| 4511 | raise InvalidArgumentType( |
|
| 4512 | function=self.modify_alert.__name__, |
|
| 4513 | argument='method', |
|
| 4514 | arg_type=AlertMethod.__name__, |
|
| 4515 | ) |
|
| 4516 | ||
| 4517 | methods = cmd.add_element("method", method.value) |
|
| 4518 | ||
| 4519 | if method_data is not None: |
|
| 4520 | for key, value in method_data.items(): |
|
| 4521 | _data = methods.add_element("data", value) |
|
| 4522 | _data.add_element("name", key) |
|
| 4523 | ||
| 4524 | if event: |
|
| 4525 | if not isinstance(event, AlertEvent): |
|
| 4526 | raise InvalidArgumentType( |
|
| 4527 | function=self.modify_alert.__name__, |
|
| 4528 | argument='event', |
|
| 4529 | arg_type=AlertEvent.__name__, |
|
| 4530 | ) |
|
| 4531 | ||
| 4532 | _check_event(event, condition, method) |
|
| 4533 | ||
| 4534 | events = cmd.add_element("event", event.value) |
|
| 4535 | ||
| 4536 | if event_data is not None: |
|
| 4537 | for key, value in event_data.items(): |
|
| 4538 | _data = events.add_element("data", value) |
|
| 4539 | _data.add_element("name", key) |
|
| 4540 | ||
| 4541 | return self._send_xml_command(cmd) |
|
| 4542 | ||
| 4543 | def modify_asset(self, asset_id: str, comment: Optional[str] = "") -> Any: |
|
| 4544 | """Modifies an existing asset. |
|
| @@ 887-993 (lines=107) @@ | ||
| 884 | ||
| 885 | return self._send_xml_command(cmd) |
|
| 886 | ||
| 887 | def modify_alert( |
|
| 888 | self, |
|
| 889 | alert_id: str, |
|
| 890 | *, |
|
| 891 | name: Optional[str] = None, |
|
| 892 | comment: Optional[str] = None, |
|
| 893 | filter_id: Optional[str] = None, |
|
| 894 | event: Optional[AlertEvent] = None, |
|
| 895 | event_data: Optional[dict] = None, |
|
| 896 | condition: Optional[AlertCondition] = None, |
|
| 897 | condition_data: Optional[dict] = None, |
|
| 898 | method: Optional[AlertMethod] = None, |
|
| 899 | method_data: Optional[dict] = None, |
|
| 900 | ) -> Any: |
|
| 901 | """Modifies an existing alert. |
|
| 902 | ||
| 903 | Arguments: |
|
| 904 | alert_id: UUID of the alert to be modified. |
|
| 905 | name: Name of the Alert. |
|
| 906 | condition: The condition that must be satisfied for the alert to |
|
| 907 | occur. If the event is either 'Updated SecInfo |
|
| 908 | arrived' or 'New SecInfo arrived', condition must be 'Always'. |
|
| 909 | Otherwise, condition can also be on of 'Severity at least', |
|
| 910 | 'Filter count changed' or 'Filter count at least'. |
|
| 911 | condition_data: Data that defines the condition |
|
| 912 | event: The event that must happen for the alert to occur, one of |
|
| 913 | 'Task run status changed', 'Updated SecInfo arrived' or |
|
| 914 | 'New SecInfo arrived' |
|
| 915 | event_data: Data that defines the event |
|
| 916 | method: The method by which the user is alerted, one of 'SCP', |
|
| 917 | 'Send', 'SMB', 'SNMP', 'Syslog' or 'Email'; |
|
| 918 | if the event is neither 'Updated SecInfo arrived' nor |
|
| 919 | 'New SecInfo arrived', method can also be one of 'Start Task', |
|
| 920 | 'HTTP Get', 'Sourcefire Connector' or 'verinice Connector'. |
|
| 921 | method_data: Data that defines the method |
|
| 922 | filter_id: Filter to apply when executing alert |
|
| 923 | comment: Comment for the alert |
|
| 924 | ||
| 925 | Returns: |
|
| 926 | The response. See :py:meth:`send_command` for details. |
|
| 927 | """ |
|
| 928 | ||
| 929 | if not alert_id: |
|
| 930 | raise RequiredArgument( |
|
| 931 | function=self.modify_alert.__name__, argument='alert_id' |
|
| 932 | ) |
|
| 933 | ||
| 934 | cmd = XmlCommand("modify_alert") |
|
| 935 | cmd.set_attribute("alert_id", str(alert_id)) |
|
| 936 | ||
| 937 | if name: |
|
| 938 | cmd.add_element("name", name) |
|
| 939 | ||
| 940 | if comment: |
|
| 941 | cmd.add_element("comment", comment) |
|
| 942 | ||
| 943 | if filter_id: |
|
| 944 | cmd.add_element("filter", attrs={"id": filter_id}) |
|
| 945 | ||
| 946 | if condition: |
|
| 947 | if not isinstance(condition, AlertCondition): |
|
| 948 | raise InvalidArgumentType( |
|
| 949 | function=self.modify_alert.__name__, |
|
| 950 | argument='condition', |
|
| 951 | arg_type=AlertCondition.__name__, |
|
| 952 | ) |
|
| 953 | ||
| 954 | conditions = cmd.add_element("condition", condition.value) |
|
| 955 | ||
| 956 | if condition_data is not None: |
|
| 957 | for key, value in condition_data.items(): |
|
| 958 | _data = conditions.add_element("data", value) |
|
| 959 | _data.add_element("name", key) |
|
| 960 | ||
| 961 | if method: |
|
| 962 | if not isinstance(method, AlertMethod): |
|
| 963 | raise InvalidArgumentType( |
|
| 964 | function=self.modify_alert.__name__, |
|
| 965 | argument='method', |
|
| 966 | arg_type=AlertMethod.__name__, |
|
| 967 | ) |
|
| 968 | ||
| 969 | methods = cmd.add_element("method", method.value) |
|
| 970 | ||
| 971 | if method_data is not None: |
|
| 972 | for key, value in method_data.items(): |
|
| 973 | _data = methods.add_element("data", value) |
|
| 974 | _data.add_element("name", key) |
|
| 975 | ||
| 976 | if event: |
|
| 977 | if not isinstance(event, AlertEvent): |
|
| 978 | raise InvalidArgumentType( |
|
| 979 | function=self.modify_alert.__name__, |
|
| 980 | argument='event', |
|
| 981 | arg_type=AlertEvent.__name__, |
|
| 982 | ) |
|
| 983 | ||
| 984 | _check_event(event, condition, method) |
|
| 985 | ||
| 986 | events = cmd.add_element("event", event.value) |
|
| 987 | ||
| 988 | if event_data is not None: |
|
| 989 | for key, value in event_data.items(): |
|
| 990 | _data = events.add_element("data", value) |
|
| 991 | _data.add_element("name", key) |
|
| 992 | ||
| 993 | return self._send_xml_command(cmd) |
|
| 994 | ||
| 995 | def modify_audit( |
|
| 996 | self, |
|
| @@ 1008-1114 (lines=107) @@ | ||
| 1005 | ||
| 1006 | return self._send_xml_command(cmd) |
|
| 1007 | ||
| 1008 | def modify_alert( |
|
| 1009 | self, |
|
| 1010 | alert_id: str, |
|
| 1011 | *, |
|
| 1012 | name: Optional[str] = None, |
|
| 1013 | comment: Optional[str] = None, |
|
| 1014 | filter_id: Optional[str] = None, |
|
| 1015 | event: Optional[AlertEvent] = None, |
|
| 1016 | event_data: Optional[dict] = None, |
|
| 1017 | condition: Optional[AlertCondition] = None, |
|
| 1018 | condition_data: Optional[dict] = None, |
|
| 1019 | method: Optional[AlertMethod] = None, |
|
| 1020 | method_data: Optional[dict] = None, |
|
| 1021 | ) -> Any: |
|
| 1022 | """Modifies an existing alert. |
|
| 1023 | ||
| 1024 | Arguments: |
|
| 1025 | alert_id: UUID of the alert to be modified. |
|
| 1026 | name: Name of the Alert. |
|
| 1027 | condition: The condition that must be satisfied for the alert to |
|
| 1028 | occur. If the event is either 'Updated SecInfo |
|
| 1029 | arrived' or 'New SecInfo arrived', condition must be 'Always'. |
|
| 1030 | Otherwise, condition can also be on of 'Severity at least', |
|
| 1031 | 'Filter count changed' or 'Filter count at least'. |
|
| 1032 | condition_data: Data that defines the condition |
|
| 1033 | event: The event that must happen for the alert to occur, one of |
|
| 1034 | 'Task run status changed', 'Updated SecInfo arrived' or |
|
| 1035 | 'New SecInfo arrived' |
|
| 1036 | event_data: Data that defines the event |
|
| 1037 | method: The method by which the user is alerted, one of 'SCP', |
|
| 1038 | 'Send', 'SMB', 'SNMP', 'Syslog' or 'Email'; |
|
| 1039 | if the event is neither 'Updated SecInfo arrived' nor |
|
| 1040 | 'New SecInfo arrived', method can also be one of 'Start Task', |
|
| 1041 | 'HTTP Get', 'Sourcefire Connector' or 'verinice Connector'. |
|
| 1042 | method_data: Data that defines the method |
|
| 1043 | filter_id: Filter to apply when executing alert |
|
| 1044 | comment: Comment for the alert |
|
| 1045 | ||
| 1046 | Returns: |
|
| 1047 | The response. See :py:meth:`send_command` for details. |
|
| 1048 | """ |
|
| 1049 | ||
| 1050 | if not alert_id: |
|
| 1051 | raise RequiredArgument( |
|
| 1052 | function=self.modify_alert.__name__, argument='alert_id' |
|
| 1053 | ) |
|
| 1054 | ||
| 1055 | cmd = XmlCommand("modify_alert") |
|
| 1056 | cmd.set_attribute("alert_id", str(alert_id)) |
|
| 1057 | ||
| 1058 | if name: |
|
| 1059 | cmd.add_element("name", name) |
|
| 1060 | ||
| 1061 | if comment: |
|
| 1062 | cmd.add_element("comment", comment) |
|
| 1063 | ||
| 1064 | if filter_id: |
|
| 1065 | cmd.add_element("filter", attrs={"id": filter_id}) |
|
| 1066 | ||
| 1067 | if condition: |
|
| 1068 | if not isinstance(condition, AlertCondition): |
|
| 1069 | raise InvalidArgumentType( |
|
| 1070 | function=self.modify_alert.__name__, |
|
| 1071 | argument='condition', |
|
| 1072 | arg_type=AlertCondition.__name__, |
|
| 1073 | ) |
|
| 1074 | ||
| 1075 | conditions = cmd.add_element("condition", condition.value) |
|
| 1076 | ||
| 1077 | if condition_data is not None: |
|
| 1078 | for key, value in condition_data.items(): |
|
| 1079 | _data = conditions.add_element("data", value) |
|
| 1080 | _data.add_element("name", key) |
|
| 1081 | ||
| 1082 | if method: |
|
| 1083 | if not isinstance(method, AlertMethod): |
|
| 1084 | raise InvalidArgumentType( |
|
| 1085 | function=self.modify_alert.__name__, |
|
| 1086 | argument='method', |
|
| 1087 | arg_type=AlertMethod.__name__, |
|
| 1088 | ) |
|
| 1089 | ||
| 1090 | methods = cmd.add_element("method", method.value) |
|
| 1091 | ||
| 1092 | if method_data is not None: |
|
| 1093 | for key, value in method_data.items(): |
|
| 1094 | _data = methods.add_element("data", value) |
|
| 1095 | _data.add_element("name", key) |
|
| 1096 | ||
| 1097 | if event: |
|
| 1098 | if not isinstance(event, AlertEvent): |
|
| 1099 | raise InvalidArgumentType( |
|
| 1100 | function=self.modify_alert.__name__, |
|
| 1101 | argument='event', |
|
| 1102 | arg_type=AlertEvent.__name__, |
|
| 1103 | ) |
|
| 1104 | ||
| 1105 | _check_event(event, condition, method) |
|
| 1106 | ||
| 1107 | events = cmd.add_element("event", event.value) |
|
| 1108 | ||
| 1109 | if event_data is not None: |
|
| 1110 | for key, value in event_data.items(): |
|
| 1111 | _data = events.add_element("data", value) |
|
| 1112 | _data.add_element("name", key) |
|
| 1113 | ||
| 1114 | return self._send_xml_command(cmd) |
|
| 1115 | ||
| 1116 | def modify_audit( |
|
| 1117 | self, |
|