Check if credentials exist for a target (without returning password). Args: target_host: Target host/IP to check Returns: Dict with exists: bool, auth_type: str, username: str (if exists)
(self, target_host: str)
| 2665 | for row in cursor.fetchall(): |
| 2666 | result = dict(row) |
| 2667 | # Indicate if password is set without revealing it |
| 2668 | result['has_password'] = True # If row exists, password was provided |
| 2669 | results.append(result) |
| 2670 | |
| 2671 | return results |
| 2672 | |
| 2673 | except Exception as e: |
| 2674 | logger.error(f"Failed to list ZAP credentials: {e}") |
| 2675 | return [] |
| 2676 | |
| 2677 | def check_zap_credentials_exist(self, target_host: str) -> Dict[str, Any]: |
| 2678 | """ |
| 2679 | Check if credentials exist for a target (without returning password). |
| 2680 | |
| 2681 | Args: |
| 2682 | target_host: Target host/IP to check |
| 2683 | |
| 2684 | Returns: |
| 2685 | Dict with exists: bool, auth_type: str, username: str (if exists) |
| 2686 | """ |
| 2687 | try: |
| 2688 | target_host = self._normalize_target_host(target_host) |
| 2689 | |
| 2690 | with self.get_connection() as conn: |
| 2691 | cursor = conn.cursor() |
| 2692 | cursor.execute(""" |
| 2693 | SELECT auth_type, username, login_url, notes |
| 2694 | FROM zap_target_credentials WHERE target_host = ? |
| 2695 | """, (target_host,)) |
| 2696 | |
| 2697 | row = cursor.fetchone() |
| 2698 | if row: |
| 2699 | return { |
| 2700 | 'exists': True, |
| 2701 | 'auth_type': row['auth_type'], |
| 2702 | 'username': row['username'], |
| 2703 | 'login_url': row['login_url'], |
| 2704 | 'notes': row['notes'] |
no test coverage detected