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

Function execute

worker/src/components/security/naabu.ts:305–437  ·  view source on GitHub ↗
({ inputs, params }, context)

Source from the content-addressed store, hash-verified

303 description: 'Fast TCP port scanner (Naabu).',
304 },
305 async execute({ inputs, params }, context) {
306 const parsedParams = parameterSchema.parse(params);
307 const trimmedPorts = parsedParams.ports?.trim();
308 const trimmedExclude = parsedParams.excludePorts?.trim();
309 const trimmedInterface = parsedParams.interface?.trim();
310
311 const effectiveOptions = {
312 ports: trimmedPorts && trimmedPorts.length > 0 ? trimmedPorts : undefined,
313 topPorts: parsedParams.topPorts,
314 excludePorts: trimmedExclude && trimmedExclude.length > 0 ? trimmedExclude : undefined,
315 rate: parsedParams.rate,
316 retries: parsedParams.retries ?? 1,
317 enablePing: parsedParams.enablePing ?? false,
318 interface: trimmedInterface && trimmedInterface.length > 0 ? trimmedInterface : undefined,
319 };
320
321 context.logger.info(
322 `[Naabu] Scanning ${inputs.targets.length} target(s) with options: ports=${effectiveOptions.ports ?? 'default'}, topPorts=${effectiveOptions.topPorts ?? 'default'}, rate=${effectiveOptions.rate ?? 'auto'}, retries=${effectiveOptions.retries}`,
323 );
324
325 context.emitProgress({
326 message: 'Launching Naabu port scan…',
327 level: 'info',
328 data: { targets: inputs.targets.slice(0, 5) },
329 });
330
331 const tenantId = (context as any).tenantId ?? 'default-tenant';
332 const volume = new IsolatedContainerVolume(tenantId, context.runId);
333 const baseRunner = definition.runner;
334
335 if (baseRunner.kind !== 'docker') {
336 throw new ContainerError('Naabu runner is expected to be docker-based.', {
337 details: { expectedKind: 'docker', actualKind: baseRunner.kind },
338 });
339 }
340
341 let rawOutput: string;
342 try {
343 // Write targets to input file
344 const inputFiles: Record<string, string> = {
345 [TARGETS_FILE_NAME]: inputs.targets.join('\n'),
346 };
347
348 const volumeName = await volume.initialize(inputFiles);
349 context.logger.info(`[Naabu] Created isolated volume: ${volumeName}`);
350
351 // Build naabu CLI arguments in TypeScript
352 const naabuArgs = buildNaabuArgs({
353 targetFile: `${CONTAINER_INPUT_DIR}/${TARGETS_FILE_NAME}`,
354 ...effectiveOptions,
355 });
356
357 const runnerConfig: DockerRunnerConfig = {
358 kind: 'docker',
359 image: baseRunner.image,
360 network: baseRunner.network,
361 timeoutSeconds: baseRunner.timeoutSeconds ?? dockerTimeoutSeconds,
362 env: { ...(baseRunner.env ?? {}) },

Callers

nothing calls this directly

Calls 10

initializeMethod · 0.95
getVolumeConfigMethod · 0.95
cleanupMethod · 0.95
runComponentWithRunnerFunction · 0.90
generateFindingHashFunction · 0.90
buildNaabuArgsFunction · 0.85
parseNaabuOutputFunction · 0.85
parseMethod · 0.80
infoMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected