|
15 | 15 | AgentInstallerInstructionLanguageType, |
16 | 16 | AgentInstallerInstructions, |
17 | 17 | Agents, |
| 18 | + AliveTest, |
18 | 19 | Credentials, |
19 | 20 | CredentialStoreCredentialType, |
20 | 21 | CredentialStores, |
|
29 | 30 | ReportPorts, |
30 | 31 | ReportTlsCertificates, |
31 | 32 | ReportVulnerabilities, |
| 33 | + Targets, |
32 | 34 | Tasks, |
33 | 35 | WebApplicationTargets, |
34 | 36 | ) |
@@ -1382,3 +1384,187 @@ def get_web_application_targets( |
1382 | 1384 | tasks=tasks, |
1383 | 1385 | ) |
1384 | 1386 | ) |
| 1387 | + |
| 1388 | + def create_target( |
| 1389 | + self, |
| 1390 | + name: str, |
| 1391 | + *, |
| 1392 | + asset_hosts_filter: str | None = None, |
| 1393 | + hosts: list[str] | None = None, |
| 1394 | + comment: str | None = None, |
| 1395 | + exclude_hosts: list[str] | None = None, |
| 1396 | + ssh_credential_id: EntityID | None = None, |
| 1397 | + ssh_credential_port: int | str | None = None, |
| 1398 | + smb_credential_id: EntityID | None = None, |
| 1399 | + esxi_credential_id: EntityID | None = None, |
| 1400 | + snmp_credential_id: EntityID | None = None, |
| 1401 | + alive_test: str | AliveTest | None = None, |
| 1402 | + allow_simultaneous_ips: bool | None = None, |
| 1403 | + reverse_lookup_only: bool | None = None, |
| 1404 | + reverse_lookup_unify: bool | None = None, |
| 1405 | + port_range: str | None = None, |
| 1406 | + port_list_id: EntityID | None = None, |
| 1407 | + ) -> T: |
| 1408 | + """Create a new target |
| 1409 | +
|
| 1410 | + Args: |
| 1411 | + name: Name of the target |
| 1412 | + asset_hosts_filter: Filter to select target host from assets hosts |
| 1413 | + hosts: List of hosts addresses to scan |
| 1414 | + exclude_hosts: List of hosts addresses to exclude from scan |
| 1415 | + comment: Comment for the target |
| 1416 | + ssh_credential_id: UUID of a ssh credential to use on target |
| 1417 | + ssh_credential_port: The port to use for ssh credential |
| 1418 | + smb_credential_id: UUID of a smb credential to use on target |
| 1419 | + snmp_credential_id: UUID of a snmp credential to use on target |
| 1420 | + esxi_credential_id: UUID of a esxi credential to use on target |
| 1421 | + alive_test: Which alive test to use |
| 1422 | + allow_simultaneous_ips: Whether to scan multiple IPs of the |
| 1423 | + same host simultaneously |
| 1424 | + reverse_lookup_only: Whether to scan only hosts that have names |
| 1425 | + reverse_lookup_unify: Whether to scan only one IP when multiple IPs |
| 1426 | + have the same name. |
| 1427 | + port_range: Port range for the target |
| 1428 | + port_list_id: UUID of the port list to use on target |
| 1429 | + """ |
| 1430 | + return self._send_request_and_transform_response( |
| 1431 | + Targets.create_target( |
| 1432 | + name, |
| 1433 | + asset_hosts_filter=asset_hosts_filter, |
| 1434 | + hosts=hosts, |
| 1435 | + comment=comment, |
| 1436 | + exclude_hosts=exclude_hosts, |
| 1437 | + ssh_credential_id=ssh_credential_id, |
| 1438 | + ssh_credential_port=ssh_credential_port, |
| 1439 | + smb_credential_id=smb_credential_id, |
| 1440 | + esxi_credential_id=esxi_credential_id, |
| 1441 | + snmp_credential_id=snmp_credential_id, |
| 1442 | + alive_test=alive_test, |
| 1443 | + allow_simultaneous_ips=allow_simultaneous_ips, |
| 1444 | + reverse_lookup_only=reverse_lookup_only, |
| 1445 | + reverse_lookup_unify=reverse_lookup_unify, |
| 1446 | + port_range=port_range, |
| 1447 | + port_list_id=port_list_id, |
| 1448 | + ) |
| 1449 | + ) |
| 1450 | + |
| 1451 | + def modify_target( |
| 1452 | + self, |
| 1453 | + target_id: EntityID, |
| 1454 | + *, |
| 1455 | + name: str | None = None, |
| 1456 | + comment: str | None = None, |
| 1457 | + hosts: list[str] | None = None, |
| 1458 | + exclude_hosts: list[str] | None = None, |
| 1459 | + ssh_credential_id: EntityID | None = None, |
| 1460 | + ssh_credential_port: str | int | None = None, |
| 1461 | + smb_credential_id: EntityID | None = None, |
| 1462 | + esxi_credential_id: EntityID | None = None, |
| 1463 | + snmp_credential_id: EntityID | None = None, |
| 1464 | + alive_test: AliveTest | str | None = None, |
| 1465 | + allow_simultaneous_ips: bool | None = None, |
| 1466 | + reverse_lookup_only: bool | None = None, |
| 1467 | + reverse_lookup_unify: bool | None = None, |
| 1468 | + port_list_id: EntityID | None = None, |
| 1469 | + ) -> T: |
| 1470 | + """Modify an existing target. |
| 1471 | +
|
| 1472 | + Args: |
| 1473 | + target_id: UUID of target to modify. |
| 1474 | + comment: Comment on target. |
| 1475 | + name: Name of target. |
| 1476 | + hosts: List of target hosts. |
| 1477 | + exclude_hosts: A list of hosts to exclude. |
| 1478 | + ssh_credential_id: UUID of SSH credential to use on target. |
| 1479 | + ssh_credential_port: The port to use for ssh credential |
| 1480 | + smb_credential_id: UUID of SMB credential to use on target. |
| 1481 | + esxi_credential_id: UUID of ESXi credential to use on target. |
| 1482 | + snmp_credential_id: UUID of SNMP credential to use on target. |
| 1483 | + port_list_id: UUID of port list describing ports to scan. |
| 1484 | + alive_test: Which alive tests to use. |
| 1485 | + allow_simultaneous_ips: Whether to scan multiple IPs of the |
| 1486 | + same host simultaneously |
| 1487 | + reverse_lookup_only: Whether to scan only hosts that have names. |
| 1488 | + reverse_lookup_unify: Whether to scan only one IP when multiple IPs |
| 1489 | + have the same name. |
| 1490 | + """ |
| 1491 | + return self._send_request_and_transform_response( |
| 1492 | + Targets.modify_target( |
| 1493 | + target_id, |
| 1494 | + name=name, |
| 1495 | + comment=comment, |
| 1496 | + hosts=hosts, |
| 1497 | + exclude_hosts=exclude_hosts, |
| 1498 | + ssh_credential_id=ssh_credential_id, |
| 1499 | + ssh_credential_port=ssh_credential_port, |
| 1500 | + smb_credential_id=smb_credential_id, |
| 1501 | + esxi_credential_id=esxi_credential_id, |
| 1502 | + snmp_credential_id=snmp_credential_id, |
| 1503 | + alive_test=alive_test, |
| 1504 | + allow_simultaneous_ips=allow_simultaneous_ips, |
| 1505 | + reverse_lookup_only=reverse_lookup_only, |
| 1506 | + reverse_lookup_unify=reverse_lookup_unify, |
| 1507 | + port_list_id=port_list_id, |
| 1508 | + ) |
| 1509 | + ) |
| 1510 | + |
| 1511 | + def clone_target(self, target_id: EntityID) -> T: |
| 1512 | + """Clone an existing target. |
| 1513 | +
|
| 1514 | + Args: |
| 1515 | + target_id: UUID of an existing target to clone. |
| 1516 | + """ |
| 1517 | + return self._send_request_and_transform_response( |
| 1518 | + Targets.clone_target(target_id) |
| 1519 | + ) |
| 1520 | + |
| 1521 | + def delete_target( |
| 1522 | + self, target_id: EntityID, *, ultimate: bool | None = False |
| 1523 | + ) -> T: |
| 1524 | + """Delete an existing target. |
| 1525 | +
|
| 1526 | + Args: |
| 1527 | + target_id: UUID of an existing target to delete. |
| 1528 | + ultimate: Whether to remove entirely or to the trashcan. |
| 1529 | + """ |
| 1530 | + return self._send_request_and_transform_response( |
| 1531 | + Targets.delete_target(target_id, ultimate=ultimate) |
| 1532 | + ) |
| 1533 | + |
| 1534 | + def get_target( |
| 1535 | + self, target_id: EntityID, *, tasks: bool | None = None |
| 1536 | + ) -> T: |
| 1537 | + """Request a single target. |
| 1538 | +
|
| 1539 | + Args: |
| 1540 | + target_id: UUID of the target to request. |
| 1541 | + tasks: Whether to include list of tasks that use the target |
| 1542 | + """ |
| 1543 | + return self._send_request_and_transform_response( |
| 1544 | + Targets.get_target(target_id, tasks=tasks) |
| 1545 | + ) |
| 1546 | + |
| 1547 | + def get_targets( |
| 1548 | + self, |
| 1549 | + *, |
| 1550 | + filter_string: str | None = None, |
| 1551 | + filter_id: EntityID | None = None, |
| 1552 | + trash: bool | None = None, |
| 1553 | + tasks: bool | None = None, |
| 1554 | + ) -> T: |
| 1555 | + """Request a list of targets. |
| 1556 | +
|
| 1557 | + Args: |
| 1558 | + filter_string: Filter term to use for the query. |
| 1559 | + filter_id: UUID of an existing filter to use for the query. |
| 1560 | + trash: Whether to include targets in the trashcan. |
| 1561 | + tasks: Whether to include list of tasks that use the target. |
| 1562 | + """ |
| 1563 | + return self._send_request_and_transform_response( |
| 1564 | + Targets.get_targets( |
| 1565 | + filter_string=filter_string, |
| 1566 | + filter_id=filter_id, |
| 1567 | + trash=trash, |
| 1568 | + tasks=tasks, |
| 1569 | + ) |
| 1570 | + ) |
0 commit comments