MCPcopy
hub / github.com/KeygraphHQ/shannon / classifyResult

Function classifyResult

apps/worker/src/services/validate-authentication.ts:206–262  ·  view source on GitHub ↗
(
  result: import('../ai/claude-executor.js').ClaudePromptResult,
  authentication: NonNullable<DistributedConfig['authentication']>,
)

Source from the content-addressed store, hash-verified

204}
205
206function 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}

Callers 1

validateAuthenticationFunction · 0.85

Calls 3

errFunction · 0.85
okFunction · 0.85
isAuthFailurePointFunction · 0.85

Tested by

no test coverage detected