(path: Path)
| 95 | |
| 96 | |
| 97 | def inspect_auth_db(path: Path) -> tuple[int, set[str]]: |
| 98 | if not path.exists(): |
| 99 | return -1, set() |
| 100 | |
| 101 | try: |
| 102 | connection = sqlite3.connect(path) |
| 103 | try: |
| 104 | tables = { |
| 105 | row[0] |
| 106 | for row in connection.execute("SELECT name FROM sqlite_master WHERE type = 'table'") |
| 107 | } |
| 108 | score = 0 |
| 109 | if "users" in tables: |
| 110 | score += 1 |
| 111 | if "trusted_devices" in tables: |
| 112 | score += 3 |
| 113 | if "device_approval_requests" in tables: |
| 114 | score += 3 |
| 115 | if "users" in tables: |
| 116 | user_count = connection.execute("SELECT COUNT(*) FROM users").fetchone()[0] |
| 117 | if user_count: |
| 118 | score += 2 |
| 119 | return score, tables |
| 120 | finally: |
| 121 | connection.close() |
| 122 | except sqlite3.Error: |
| 123 | return -1, set() |
| 124 | |
| 125 | |
| 126 | def resolve_auth_db_path() -> Path: |
no outgoing calls
no test coverage detected