style: fix biome formatting in worker package
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -178,7 +178,8 @@ export async function runClaudePrompt(
|
|||||||
sdkEnv.CLAUDE_CODE_USE_VERTEX = '1';
|
sdkEnv.CLAUDE_CODE_USE_VERTEX = '1';
|
||||||
if (providerConfig.gcpRegion) sdkEnv.CLOUD_ML_REGION = providerConfig.gcpRegion;
|
if (providerConfig.gcpRegion) sdkEnv.CLOUD_ML_REGION = providerConfig.gcpRegion;
|
||||||
if (providerConfig.gcpProjectId) sdkEnv.ANTHROPIC_VERTEX_PROJECT_ID = providerConfig.gcpProjectId;
|
if (providerConfig.gcpProjectId) sdkEnv.ANTHROPIC_VERTEX_PROJECT_ID = providerConfig.gcpProjectId;
|
||||||
if (providerConfig.gcpCredentialsPath) sdkEnv.GOOGLE_APPLICATION_CREDENTIALS = providerConfig.gcpCredentialsPath;
|
if (providerConfig.gcpCredentialsPath)
|
||||||
|
sdkEnv.GOOGLE_APPLICATION_CREDENTIALS = providerConfig.gcpCredentialsPath;
|
||||||
break;
|
break;
|
||||||
case 'litellm_router':
|
case 'litellm_router':
|
||||||
if (providerConfig.baseUrl) sdkEnv.ANTHROPIC_BASE_URL = providerConfig.baseUrl;
|
if (providerConfig.baseUrl) sdkEnv.ANTHROPIC_BASE_URL = providerConfig.baseUrl;
|
||||||
|
|||||||
@@ -11,11 +11,7 @@
|
|||||||
import type { PipelineState } from '../temporal/shared.js';
|
import type { PipelineState } from '../temporal/shared.js';
|
||||||
|
|
||||||
export interface CheckpointProvider {
|
export interface CheckpointProvider {
|
||||||
onAgentComplete(
|
onAgentComplete(agentName: string, phase: string, state: PipelineState): Promise<void>;
|
||||||
agentName: string,
|
|
||||||
phase: string,
|
|
||||||
state: PipelineState,
|
|
||||||
): Promise<void>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Default no-op implementation — no external checkpointing. */
|
/** Default no-op implementation — no external checkpointing. */
|
||||||
|
|||||||
@@ -11,11 +11,7 @@ import type { ActivityInput } from '../temporal/activities.js';
|
|||||||
import type { VulnType } from '../types/agents.js';
|
import type { VulnType } from '../types/agents.js';
|
||||||
|
|
||||||
export interface FindingsProvider {
|
export interface FindingsProvider {
|
||||||
mergeFindingsIntoQueue(
|
mergeFindingsIntoQueue(repoPath: string, vulnType: VulnType, input: ActivityInput): Promise<{ mergedCount: number }>;
|
||||||
repoPath: string,
|
|
||||||
vulnType: VulnType,
|
|
||||||
input: ActivityInput,
|
|
||||||
): Promise<{ mergedCount: number }>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Default no-op implementation — no external findings to merge. */
|
/** Default no-op implementation — no external findings to merge. */
|
||||||
|
|||||||
@@ -95,7 +95,19 @@ export class AgentExecutionService {
|
|||||||
auditSession: AuditSession,
|
auditSession: AuditSession,
|
||||||
logger: ActivityLogger,
|
logger: ActivityLogger,
|
||||||
): Promise<Result<AgentEndResult, PentestError>> {
|
): Promise<Result<AgentEndResult, PentestError>> {
|
||||||
const { webUrl, repoPath, deliverablesPath, configPath, configData, configYAML, pipelineTestingMode = false, attemptNumber, apiKey, promptDir, providerConfig } = input;
|
const {
|
||||||
|
webUrl,
|
||||||
|
repoPath,
|
||||||
|
deliverablesPath,
|
||||||
|
configPath,
|
||||||
|
configData,
|
||||||
|
configYAML,
|
||||||
|
pipelineTestingMode = false,
|
||||||
|
attemptNumber,
|
||||||
|
apiKey,
|
||||||
|
promptDir,
|
||||||
|
providerConfig,
|
||||||
|
} = input;
|
||||||
|
|
||||||
// 1. Load config (pre-parsed configData → raw YAML → file path)
|
// 1. Load config (pre-parsed configData → raw YAML → file path)
|
||||||
const configResult = await this.configLoader.loadOptional(configPath, configData, configYAML);
|
const configResult = await this.configLoader.loadOptional(configPath, configData, configYAML);
|
||||||
@@ -108,7 +120,14 @@ export class AgentExecutionService {
|
|||||||
const promptTemplate = AGENTS[agentName].promptTemplate;
|
const promptTemplate = AGENTS[agentName].promptTemplate;
|
||||||
let prompt: string;
|
let prompt: string;
|
||||||
try {
|
try {
|
||||||
prompt = await loadPrompt(promptTemplate, { webUrl, repoPath }, distributedConfig, pipelineTestingMode, logger, promptDir);
|
prompt = await loadPrompt(
|
||||||
|
promptTemplate,
|
||||||
|
{ webUrl, repoPath },
|
||||||
|
distributedConfig,
|
||||||
|
pipelineTestingMode,
|
||||||
|
logger,
|
||||||
|
promptDir,
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
return err(
|
return err(
|
||||||
|
|||||||
@@ -81,7 +81,13 @@ export class ConfigLoaderService {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
return err(
|
return err(
|
||||||
new PentestError(`Failed to parse config YAML: ${errorMessage}`, 'config', false, { originalError: errorMessage }, ErrorCode.CONFIG_PARSE_ERROR),
|
new PentestError(
|
||||||
|
`Failed to parse config YAML: ${errorMessage}`,
|
||||||
|
'config',
|
||||||
|
false,
|
||||||
|
{ originalError: errorMessage },
|
||||||
|
ErrorCode.CONFIG_PARSE_ERROR,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,11 @@ function isLoopbackAddress(address: string): boolean {
|
|||||||
|
|
||||||
// === Repository Validation ===
|
// === Repository Validation ===
|
||||||
|
|
||||||
async function validateRepo(repoPath: string, logger: ActivityLogger, skipGitCheck?: boolean): Promise<Result<void, PentestError>> {
|
async function validateRepo(
|
||||||
|
repoPath: string,
|
||||||
|
logger: ActivityLogger,
|
||||||
|
skipGitCheck?: boolean,
|
||||||
|
): Promise<Result<void, PentestError>> {
|
||||||
logger.info('Checking repository path...', { repoPath });
|
logger.info('Checking repository path...', { repoPath });
|
||||||
|
|
||||||
// 1. Check repo directory exists
|
// 1. Check repo directory exists
|
||||||
@@ -184,11 +188,17 @@ function classifySdkError(sdkError: SDKAssistantMessageError, authType: string):
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Validate credentials via a minimal Claude Agent SDK query. */
|
/** Validate credentials via a minimal Claude Agent SDK query. */
|
||||||
async function validateCredentials(logger: ActivityLogger, apiKey?: string, providerConfig?: import('../types/config.js').ProviderConfig): Promise<Result<void, PentestError>> {
|
async function validateCredentials(
|
||||||
|
logger: ActivityLogger,
|
||||||
|
apiKey?: string,
|
||||||
|
providerConfig?: import('../types/config.js').ProviderConfig,
|
||||||
|
): Promise<Result<void, PentestError>> {
|
||||||
// 0. If providerConfig is present, credentials are managed by the caller.
|
// 0. If providerConfig is present, credentials are managed by the caller.
|
||||||
// The executor will map providerConfig directly to sdkEnv — no process.env needed.
|
// The executor will map providerConfig directly to sdkEnv — no process.env needed.
|
||||||
if (providerConfig) {
|
if (providerConfig) {
|
||||||
logger.info(`Provider config present (type: ${providerConfig.providerType || 'anthropic_api'}) — skipping env-based credential validation`);
|
logger.info(
|
||||||
|
`Provider config present (type: ${providerConfig.providerType || 'anthropic_api'}) — skipping env-based credential validation`,
|
||||||
|
);
|
||||||
return ok(undefined);
|
return ok(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { AuditSession } from '../audit/index.js';
|
|||||||
import type { ResumeAttempt } from '../audit/metrics-tracker.js';
|
import type { ResumeAttempt } from '../audit/metrics-tracker.js';
|
||||||
import type { SessionMetadata } from '../audit/utils.js';
|
import type { SessionMetadata } from '../audit/utils.js';
|
||||||
import type { WorkflowSummary } from '../audit/workflow-logger.js';
|
import type { WorkflowSummary } from '../audit/workflow-logger.js';
|
||||||
import type { ContainerConfig, ProviderConfig } from '../types/config.js';
|
import { DEFAULT_DELIVERABLES_SUBDIR, deliverablesDir } from '../paths.js';
|
||||||
import { getContainer, getOrCreateContainer, removeContainer } from '../services/container.js';
|
import { getContainer, getOrCreateContainer, removeContainer } from '../services/container.js';
|
||||||
import { classifyErrorForTemporal, PentestError } from '../services/error-handling.js';
|
import { classifyErrorForTemporal, PentestError } from '../services/error-handling.js';
|
||||||
import { ExploitationCheckerService } from '../services/exploitation-checker.js';
|
import { ExploitationCheckerService } from '../services/exploitation-checker.js';
|
||||||
@@ -33,9 +33,9 @@ import { assembleFinalReport, injectModelIntoReport } from '../services/reportin
|
|||||||
import { AGENTS } from '../session-manager.js';
|
import { AGENTS } from '../session-manager.js';
|
||||||
import type { AgentName } from '../types/agents.js';
|
import type { AgentName } from '../types/agents.js';
|
||||||
import { ALL_AGENTS } from '../types/agents.js';
|
import { ALL_AGENTS } from '../types/agents.js';
|
||||||
|
import type { ContainerConfig, ProviderConfig } from '../types/config.js';
|
||||||
import { ErrorCode } from '../types/errors.js';
|
import { ErrorCode } from '../types/errors.js';
|
||||||
import { isErr } from '../types/result.js';
|
import { isErr } from '../types/result.js';
|
||||||
import { DEFAULT_DELIVERABLES_SUBDIR, deliverablesDir } from '../paths.js';
|
|
||||||
import { fileExists, readJson } from '../utils/file-io.js';
|
import { fileExists, readJson } from '../utils/file-io.js';
|
||||||
import { createActivityLogger } from './activity-logger.js';
|
import { createActivityLogger } from './activity-logger.js';
|
||||||
import type { AgentMetrics, PipelineState, ResumeState } from './shared.js';
|
import type { AgentMetrics, PipelineState, ResumeState } from './shared.js';
|
||||||
@@ -306,7 +306,15 @@ export async function runPreflightValidation(input: ActivityInput): Promise<void
|
|||||||
const logger = createActivityLogger();
|
const logger = createActivityLogger();
|
||||||
logger.info('Running preflight validation...', { attempt: attemptNumber });
|
logger.info('Running preflight validation...', { attempt: attemptNumber });
|
||||||
|
|
||||||
const result = await runPreflightChecks(input.webUrl, input.repoPath, input.configPath, logger, input.skipGitCheck, input.apiKey, input.providerConfig);
|
const result = await runPreflightChecks(
|
||||||
|
input.webUrl,
|
||||||
|
input.repoPath,
|
||||||
|
input.configPath,
|
||||||
|
logger,
|
||||||
|
input.skipGitCheck,
|
||||||
|
input.apiKey,
|
||||||
|
input.providerConfig,
|
||||||
|
);
|
||||||
|
|
||||||
if (isErr(result)) {
|
if (isErr(result)) {
|
||||||
const classified = classifyErrorForTemporal(result.error);
|
const classified = classifyErrorForTemporal(result.error);
|
||||||
|
|||||||
@@ -219,14 +219,24 @@ export async function pentestPipeline(input: PipelineInput): Promise<PipelineSta
|
|||||||
|
|
||||||
if (input.resumeFromWorkspace) {
|
if (input.resumeFromWorkspace) {
|
||||||
// 1. Load resume state (validates workspace, cross-checks deliverables)
|
// 1. Load resume state (validates workspace, cross-checks deliverables)
|
||||||
resumeState = await a.loadResumeState(input.resumeFromWorkspace, input.webUrl, input.repoPath, input.deliverablesSubdir);
|
resumeState = await a.loadResumeState(
|
||||||
|
input.resumeFromWorkspace,
|
||||||
|
input.webUrl,
|
||||||
|
input.repoPath,
|
||||||
|
input.deliverablesSubdir,
|
||||||
|
);
|
||||||
|
|
||||||
// 2. Restore git workspace and clean up incomplete deliverables
|
// 2. Restore git workspace and clean up incomplete deliverables
|
||||||
const incompleteAgents = ALL_AGENTS.filter(
|
const incompleteAgents = ALL_AGENTS.filter(
|
||||||
(agentName) => !resumeState?.completedAgents.includes(agentName),
|
(agentName) => !resumeState?.completedAgents.includes(agentName),
|
||||||
) as AgentName[];
|
) as AgentName[];
|
||||||
|
|
||||||
await a.restoreGitCheckpoint(input.repoPath, resumeState.checkpointHash, incompleteAgents, input.deliverablesSubdir);
|
await a.restoreGitCheckpoint(
|
||||||
|
input.repoPath,
|
||||||
|
resumeState.checkpointHash,
|
||||||
|
incompleteAgents,
|
||||||
|
input.deliverablesSubdir,
|
||||||
|
);
|
||||||
|
|
||||||
// 3. Short-circuit if all agents already completed
|
// 3. Short-circuit if all agents already completed
|
||||||
if (resumeState.completedAgents.length === ALL_AGENTS.length) {
|
if (resumeState.completedAgents.length === ALL_AGENTS.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user