({ inputs, params }, context)
| 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 ?? {}) }, |
nothing calls this directly
no test coverage detected