(
result: import('../ai/claude-executor.js').ClaudePromptResult,
authentication: NonNullable<DistributedConfig['authentication']>,
)
| 204 | } |
| 205 | |
| 206 | function classifyResult( |
| 207 | result: import('../ai/claude-executor.js').ClaudePromptResult, |
| 208 | authentication: NonNullable<DistributedConfig['authentication']>, |
| 209 | ): Result<void, PentestError> { |
| 210 | if (!result.success) { |
| 211 | const detail = result.error ?? 'Validator agent terminated unexpectedly.'; |
| 212 | return err( |
| 213 | new PentestError( |
| 214 | `Authentication validator failed to run: ${detail}`, |
| 215 | 'validation', |
| 216 | result.retryable ?? true, |
| 217 | { originalError: detail, errorType: result.errorType, cost: result.cost }, |
| 218 | ErrorCode.AGENT_EXECUTION_FAILED, |
| 219 | ), |
| 220 | ); |
| 221 | } |
| 222 | |
| 223 | if (!result.structuredOutput || typeof result.structuredOutput !== 'object') { |
| 224 | return err( |
| 225 | new PentestError( |
| 226 | 'Authentication validator did not return a structured verdict.', |
| 227 | 'validation', |
| 228 | true, |
| 229 | { cost: result.cost }, |
| 230 | ErrorCode.AGENT_EXECUTION_FAILED, |
| 231 | ), |
| 232 | ); |
| 233 | } |
| 234 | |
| 235 | const verdict = result.structuredOutput as Partial<AuthValidationVerdict>; |
| 236 | |
| 237 | if (verdict.login_success === true) { |
| 238 | return ok(undefined); |
| 239 | } |
| 240 | |
| 241 | const failurePoint: AuthFailurePoint = isAuthFailurePoint(verdict.failure_point) |
| 242 | ? verdict.failure_point |
| 243 | : 'out_of_band'; |
| 244 | const failureDetail = |
| 245 | verdict.failure_detail?.trim() || 'Login failed without a specific diagnostic from the validator agent.'; |
| 246 | |
| 247 | return err( |
| 248 | new PentestError( |
| 249 | `Authentication failed at "${failurePoint}": ${failureDetail}`, |
| 250 | 'config', |
| 251 | false, |
| 252 | { |
| 253 | failurePoint, |
| 254 | failureDetail, |
| 255 | loginUrl: authentication.login_url, |
| 256 | loginType: authentication.login_type, |
| 257 | cost: result.cost, |
| 258 | }, |
| 259 | ErrorCode.AUTH_LOGIN_FAILED, |
| 260 | ), |
| 261 | ); |
| 262 | } |
no test coverage detected