Delete ZAP credentials for a target. Args: target_host: Target host/IP to delete credentials for Returns: True if deleted (or didn't exist)
(self, target_host: str)
| 2606 | |
| 2607 | # Try without port |
| 2608 | host_no_port = host.split(':')[0] |
| 2609 | if host_no_port != host: |
| 2610 | return self.get_zap_credentials(host_no_port) |
| 2611 | |
| 2612 | return None |
| 2613 | |
| 2614 | except Exception as e: |
| 2615 | logger.error(f"Failed to get ZAP credentials for URL {url}: {e}") |
| 2616 | return None |
| 2617 | |
| 2618 | def delete_zap_credentials(self, target_host: str) -> bool: |
| 2619 | """ |
| 2620 | Delete ZAP credentials for a target. |
| 2621 | |
| 2622 | Args: |
| 2623 | target_host: Target host/IP to delete credentials for |
| 2624 | |
| 2625 | Returns: |
| 2626 | True if deleted (or didn't exist) |
| 2627 | """ |
| 2628 | try: |
| 2629 | target_host = self._normalize_target_host(target_host) |
| 2630 | |
| 2631 | with self.get_connection() as conn: |
| 2632 | cursor = conn.cursor() |
| 2633 | cursor.execute(""" |
| 2634 | DELETE FROM zap_target_credentials WHERE target_host = ? |
| 2635 | """, (target_host,)) |
| 2636 | conn.commit() |
| 2637 |
no test coverage detected