@@ 4040-4096 (lines=57) @@ | ||
4037 | ||
4038 | return self._send_xml_command(cmd) |
|
4039 | ||
4040 | def modify_scanner(self, scanner_id, host, port, scanner_type, *, |
|
4041 | comment=None, name=None, ca_pub=None, |
|
4042 | credential_id=None): |
|
4043 | """Modifies an existing scanner. |
|
4044 | ||
4045 | Arguments: |
|
4046 | scanner_id (str): UUID of scanner to modify. |
|
4047 | host (str): Host of the scanner. |
|
4048 | port (str): Port of the scanner. |
|
4049 | scanner_type (str): Type of the scanner. |
|
4050 | '1' for OSP, '2' for OpenVAS (classic) Scanner. |
|
4051 | comment (str, optional): Comment on scanner. |
|
4052 | name (str, optional): Name of scanner. |
|
4053 | ca_pub (str, optional): Certificate of CA to verify scanner's |
|
4054 | certificate. |
|
4055 | credential_id (str, optional): UUID of the client certificate |
|
4056 | credential for the Scanner. |
|
4057 | ||
4058 | Returns: |
|
4059 | The response. See :py:meth:`send_command` for details. |
|
4060 | """ |
|
4061 | if not scanner_id: |
|
4062 | raise RequiredArgument( |
|
4063 | 'modify_scanner requires a scanner_id argument') |
|
4064 | if not host: |
|
4065 | raise RequiredArgument('modify_scanner requires a host argument') |
|
4066 | if not port: |
|
4067 | raise RequiredArgument('modify_scanner requires a port argument') |
|
4068 | if not scanner_type: |
|
4069 | raise RequiredArgument('modify_scanner requires a scanner_type ' |
|
4070 | 'argument') |
|
4071 | ||
4072 | cmd = XmlCommand('modify_scanner') |
|
4073 | cmd.set_attribute('scanner_id', scanner_id) |
|
4074 | cmd.add_element('host', host) |
|
4075 | cmd.add_element('port', port) |
|
4076 | ||
4077 | if scanner_type not in SCANNER_TYPES: |
|
4078 | raise InvalidArgument('modify_scanner requires a scanner_type ' |
|
4079 | 'argument which must be either "1" for OSP ' |
|
4080 | 'or "2" OpenVAS (Classic).') |
|
4081 | ||
4082 | cmd.add_element('type', scanner_type) |
|
4083 | ||
4084 | if comment: |
|
4085 | cmd.add_element('comment', comment) |
|
4086 | ||
4087 | if name: |
|
4088 | cmd.add_element('name', name) |
|
4089 | ||
4090 | if ca_pub: |
|
4091 | cmd.add_element('ca_pub', ca_pub) |
|
4092 | ||
4093 | if credential_id: |
|
4094 | cmd.add_element('credential', attrs={'id': str(credential_id)}) |
|
4095 | ||
4096 | return self._send_xml_command(cmd) |
|
4097 | ||
4098 | def modify_schedule(self, schedule_id, *, comment=None, name=None, |
|
4099 | first_time_minute=None, first_time_hour=None, |
|
@@ 1185-1238 (lines=54) @@ | ||
1182 | cmd.add_element('copy', role_id) |
|
1183 | return self._send_xml_command(cmd) |
|
1184 | ||
1185 | def create_scanner(self, name, host, port, scanner_type, ca_pub, |
|
1186 | credential_id, *, comment=None): |
|
1187 | """Create a new scanner |
|
1188 | ||
1189 | Arguments: |
|
1190 | name (str): Name of the scanner |
|
1191 | host (str): The host of the scanner |
|
1192 | port (str): The port of the scanner |
|
1193 | scanner_type (str): Type of the scanner. |
|
1194 | '1' for OSP, '2' for OpenVAS (classic) Scanner. |
|
1195 | ca_pub (str): Certificate of CA to verify scanner certificate |
|
1196 | credential_id (str): UUID of client certificate credential for the |
|
1197 | scanner |
|
1198 | comment (str, optional): Comment for the scanner |
|
1199 | ||
1200 | Returns: |
|
1201 | The response. See :py:meth:`send_command` for details. |
|
1202 | """ |
|
1203 | if not name: |
|
1204 | raise RequiredArgument('create_scanner requires a name argument') |
|
1205 | ||
1206 | if not host: |
|
1207 | raise RequiredArgument('create_scanner requires a host argument') |
|
1208 | ||
1209 | if not port: |
|
1210 | raise RequiredArgument('create_scanner requires a port argument') |
|
1211 | ||
1212 | if not scanner_type: |
|
1213 | raise RequiredArgument('create_scanner requires a scanner_type ' |
|
1214 | 'argument') |
|
1215 | if not ca_pub: |
|
1216 | raise RequiredArgument('create_scanner requires a ca_pub argument') |
|
1217 | ||
1218 | if not credential_id: |
|
1219 | raise RequiredArgument('create_scanner requires a credential_id ' |
|
1220 | 'argument') |
|
1221 | ||
1222 | if scanner_type not in SCANNER_TYPES: |
|
1223 | raise InvalidArgument('create_scanner requires a scanner_type ' |
|
1224 | 'argument which must be either "1" for OSP ' |
|
1225 | 'or "2" OpenVAS (Classic).') |
|
1226 | ||
1227 | cmd = XmlCommand('create_scanner') |
|
1228 | cmd.add_element('name', name) |
|
1229 | cmd.add_element('host', host) |
|
1230 | cmd.add_element('port', port) |
|
1231 | cmd.add_element('type', scanner_type) |
|
1232 | cmd.add_element('ca_pub', ca_pub) |
|
1233 | cmd.add_element('credential', attrs={'id': str(credential_id)}) |
|
1234 | ||
1235 | if comment: |
|
1236 | cmd.add_element('comment', comment) |
|
1237 | ||
1238 | return self._send_xml_command(cmd) |
|
1239 | ||
1240 | def clone_scanner(self, scanner_id): |
|
1241 | """Clone an existing scanner |