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

Function execute

worker/src/components/security/nuclei.ts:326–586  ·  view source on GitHub ↗
({ inputs, params }, context)

Source from the content-addressed store, hash-verified

324 ],
325 },
326 async execute({ inputs, params }, context) {
327 const parsedInputs = inputSchema.parse(inputs);
328 const parsedParams = parameterSchema.parse(params);
329
330 context.logger.info(`[Nuclei] Starting scan for ${parsedInputs.targets.length} target(s)`);
331
332 const tenantId = (context as any).tenantId ?? 'default-tenant';
333 let volume: IsolatedContainerVolume | null = null;
334
335 try {
336 const hasCustomArchive = !!parsedInputs.customTemplateArchive;
337 const hasCustomYaml = !!parsedInputs.customTemplateYaml;
338 const hasBuiltInFilters = !!(
339 (parsedInputs.templateIds && parsedInputs.templateIds.length > 0) ||
340 (parsedInputs.templatePaths && parsedInputs.templatePaths.length > 0)
341 );
342 const hasSeverityFilter = !!(
343 parsedParams.severityFilter && parsedParams.severityFilter.length > 0
344 );
345
346 if (!hasCustomArchive && !hasCustomYaml && !hasBuiltInFilters && !hasSeverityFilter) {
347 throw new ValidationError(
348 'At least one template source is required: customTemplateArchive, customTemplateYaml, templateIds, templatePaths, or severityFilter',
349 );
350 }
351
352 // ===== TypeScript: Build nuclei command args =====
353 const args: string[] = [
354 '-duc', // Disable update check (templates pre-installed in image)
355 '-jsonl', // JSONL output format (nuclei v3.6.0+)
356 '-stream', // Stream mode: prevents buffering, required for PTY compatibility
357 '-verbose', // Show findings in terminal (overrides silent mode)
358 '-l',
359 '/inputs/targets.txt', // Targets file
360 ];
361
362 // Conditionally disable httpx probing
363 if (parsedParams.disableHttpx) {
364 args.push('-nh');
365 }
366
367 // Scan configuration
368 args.push('-rl', parsedParams.rateLimit.toString());
369 args.push('-c', parsedParams.concurrency.toString());
370 args.push('-timeout', parsedParams.timeout.toString());
371 args.push('-retries', parsedParams.retries.toString());
372
373 if (parsedParams.updateTemplates) {
374 args.push('-update-templates');
375 }
376
377 if (parsedParams.followRedirects) {
378 args.push('-follow-redirects');
379 }
380
381 // Severity filter
382 if (parsedParams.severityFilter && parsedParams.severityFilter.length > 0) {
383 args.push('-s', parsedParams.severityFilter.join(','));

Callers

nothing calls this directly

Calls 14

runComponentWithRunnerFunction · 0.90
generateFindingHashFunction · 0.90
extractAndValidateZipFunction · 0.85
validateNucleiTemplateFunction · 0.85
parseNucleiOutputFunction · 0.85
extractStatsFunction · 0.85
parseMethod · 0.80
infoMethod · 0.80
fromMethod · 0.80
getVolumeNameMethod · 0.80
pushMethod · 0.65
initializeMethod · 0.45

Tested by

no test coverage detected