MCPcopy Create free account
hub / github.com/ShipSecAI/studio / execute

Function execute

worker/src/components/security/trufflehog.ts:368–531  ·  view source on GitHub ↗
({ inputs, params }, context)

Source from the content-addressed store, hash-verified

366 ],
367 },
368 async execute({ inputs, params }, context) {
369 const parsedParams = parameterSchema.parse(params);
370 const runnerPayload = {
371 ...inputs,
372 ...parsedParams,
373 };
374
375 context.logger.info(
376 `[TruffleHog] Scanning ${runnerPayload.scanType} target: ${runnerPayload.scanTarget}`,
377 );
378
379 const optionsSummary = {
380 scanType: runnerPayload.scanType,
381 onlyVerified: runnerPayload.onlyVerified ?? true,
382 jsonOutput: runnerPayload.jsonOutput ?? true,
383 branch: runnerPayload.branch ?? null,
384 sinceCommit: runnerPayload.sinceCommit ?? null,
385 hasFilesystemContent: !!runnerPayload.filesystemContent,
386 };
387
388 context.emitProgress({
389 message: 'Launching TruffleHog scan…',
390 level: 'info',
391 data: { target: runnerPayload.scanTarget, options: optionsSummary },
392 });
393
394 // Handle filesystem scanning with isolated volumes
395 let volume: IsolatedContainerVolume | undefined;
396 let effectiveInput = runnerPayload;
397
398 const baseRunner = definition.runner;
399 if (baseRunner.kind !== 'docker') {
400 throw new ContainerError('TruffleHog runner must be docker', {
401 details: { reason: 'runner_type_mismatch', expected: 'docker', actual: baseRunner.kind },
402 });
403 }
404
405 try {
406 // If filesystemContent is provided, use isolated volume
407 if (
408 runnerPayload.filesystemContent &&
409 Object.keys(runnerPayload.filesystemContent).length > 0
410 ) {
411 if (runnerPayload.scanType !== 'filesystem') {
412 throw new ValidationError('filesystemContent can only be used with scanType=filesystem', {
413 fieldErrors: { scanType: ['Must be "filesystem" when using filesystemContent'] },
414 });
415 }
416
417 const tenantId = (context as any).tenantId ?? 'default-tenant';
418 volume = new IsolatedContainerVolume(tenantId, context.runId);
419
420 // Initialize volume with files
421 const volumeName = await volume.initialize(runnerPayload.filesystemContent);
422 context.logger.info(`[TruffleHog] Created isolated volume: ${volumeName}`);
423
424 // Override scanTarget to point to mounted volume
425 effectiveInput = {

Callers

nothing calls this directly

Calls 10

runComponentWithRunnerFunction · 0.90
generateFindingHashFunction · 0.90
buildTruffleHogCommandFunction · 0.85
parseRawOutputFunction · 0.85
parseMethod · 0.80
infoMethod · 0.80
errorMethod · 0.80
initializeMethod · 0.45
getVolumeConfigMethod · 0.45
cleanupMethod · 0.45

Tested by

no test coverage detected