mirror of
https://github.com/KeygraphHQ/shannon.git
synced 2026-10-03 14:56:50 +02:00
* feat(worker): record token, cache, and turn usage per agent * feat: replace model tiers with a single SHANNON_AI_MODEL across five providers * feat(cli): rebuild the setup wizard for provider and model selection * docs: document single-model selection and supported providers * feat(worker): use chat completions for OpenAI behind a custom base URL * feat: add SHANNON_AI_OPENAI_FORMAT to pick the wire API for OpenAI gateways * refactor(cli): drop endpoint path hints from the gateway format picker * feat(worker): enable pi in-session provider retry with retry-after backoff * refactor(worker): hand provider error classification to pi and drop the Anthropic ladders * refactor: remove the subscription retry preset and pipeline config section * fix(worker): validate Bedrock credentials with the same live probe as other providers * feat(worker): render the report from structured findings instead of agent-written markdown * fix(worker): dispose the credential probe session on every path * fix(worker): refuse to replace the assembled report with an empty one * refactor(worker): catch post-processing throws across the whole finalization block * revert(worker): drop the report zero-findings guard * docs(worker): correct the retry split and Bedrock credential claims * docs: regenerate llms-full.txt from current sources * feat(cli): build and run the npx flow from a clone * refactor(cli): flatten the setup summary output * feat(cli): reject runs with more than one provider configured * fix(worker): say a rejected bash call never ran * chore(cli): drop grok-4.3 and gpt-5.6-luna from the setup suggestions * feat(worker): capture structured finding locations for SARIF output * fix(worker): enumerate queue confidence so the report inherits it verbatim * feat(worker): give the reporting phase a mode-specific output schema * feat(worker): emit a SARIF 2.1.0 log for exploitative runs * fix(worker): correct SARIF locations and defer fingerprinting to the upload action * fix(worker): drop the confidence suffix from the analysis-mode summary list * feat(worker): give exploit findings a dedicated code location field * feat(worker): carry structured code locations from the vuln queue to the report * fix(worker): join code locations from the vuln queue instead of re-asking agents * fix(worker): spell out the finding_id to category mapping in the tool schema * feat: drop Google/Gemini as a supported AI provider * fix(worker): stop asking the report agent for code locations * docs: correct the provider list and drop the removed rate-limit settings * docs: add provider cyber safeguards and suggested models per provider * docs: document the SARIF output and the report rating thresholds
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
// Copyright (C) 2025 Keygraph, Inc.
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License version 3
|
|
// as published by the Free Software Foundation.
|
|
|
|
/**
|
|
* Config Loader Service
|
|
*
|
|
* Wraps parseConfig + distributeConfig with Result type for explicit error handling.
|
|
* Pure service with no Temporal dependencies.
|
|
*/
|
|
|
|
import { distributeConfig, parseConfig, parseConfigYAML } from '../config-parser.js';
|
|
import type { DistributedConfig } from '../types/config.js';
|
|
import { ErrorCode } from '../types/errors.js';
|
|
import { err, ok, type Result } from '../types/result.js';
|
|
import { PentestError } from './error-handling.js';
|
|
|
|
/**
|
|
* Service for loading and distributing configuration files.
|
|
*
|
|
* Provides a Result-based API for explicit error handling,
|
|
* allowing callers to decide how to handle failures.
|
|
*/
|
|
export class ConfigLoaderService {
|
|
/**
|
|
* Load and distribute a configuration file.
|
|
*
|
|
* @param configPath - Path to the YAML configuration file
|
|
* @returns Result containing DistributedConfig on success, PentestError on failure
|
|
*/
|
|
async load(configPath: string): Promise<Result<DistributedConfig, PentestError>> {
|
|
try {
|
|
const config = await parseConfig(configPath);
|
|
const distributed = distributeConfig(config);
|
|
return ok(distributed);
|
|
} catch (error) {
|
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
|
|
// parseConfig throws PentestErrors that already name the failure; anything
|
|
// else reaching here is a parse-time fault.
|
|
const errorCode = error instanceof PentestError && error.code ? error.code : ErrorCode.CONFIG_PARSE_ERROR;
|
|
|
|
return err(
|
|
new PentestError(
|
|
`Failed to load config ${configPath}: ${errorMessage}`,
|
|
'config',
|
|
false,
|
|
{ configPath, originalError: errorMessage },
|
|
errorCode,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Load config if path is provided, otherwise return null config.
|
|
* If configData is provided (pre-parsed), returns it directly without file I/O.
|
|
*
|
|
* @param configPath - Optional path to the YAML configuration file
|
|
* @param configData - Optional pre-parsed config (bypasses file loading)
|
|
* @returns Result containing DistributedConfig (or null) on success, PentestError on failure
|
|
*/
|
|
async loadOptional(
|
|
configPath: string | undefined,
|
|
configData?: DistributedConfig,
|
|
configYAML?: string,
|
|
): Promise<Result<DistributedConfig | null, PentestError>> {
|
|
if (configData) {
|
|
return ok(configData);
|
|
}
|
|
if (configYAML) {
|
|
try {
|
|
const config = parseConfigYAML(configYAML);
|
|
return ok(distributeConfig(config));
|
|
} catch (error) {
|
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
return err(
|
|
new PentestError(
|
|
`Failed to parse config YAML: ${errorMessage}`,
|
|
'config',
|
|
false,
|
|
{ originalError: errorMessage },
|
|
ErrorCode.CONFIG_PARSE_ERROR,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
if (!configPath) {
|
|
return ok(null);
|
|
}
|
|
return this.load(configPath);
|
|
}
|
|
}
|