| 205 | * Follows the Dynamic Args Pattern from component-development.mdx |
| 206 | */ |
| 207 | const buildNaabuArgs = (options: BuildNaabuArgsOptions): string[] => { |
| 208 | const args: string[] = []; |
| 209 | |
| 210 | // Target list file |
| 211 | args.push('-list', options.targetFile); |
| 212 | |
| 213 | // JSON output for structured parsing |
| 214 | args.push('-json'); |
| 215 | |
| 216 | // Silent mode for clean output |
| 217 | args.push('-silent'); |
| 218 | |
| 219 | // Stream mode to prevent output buffering (critical for PTY) |
| 220 | args.push('-stream'); |
| 221 | |
| 222 | // Port configuration |
| 223 | if (options.ports) { |
| 224 | args.push('-p', options.ports); |
| 225 | } |
| 226 | if (typeof options.topPorts === 'number' && options.topPorts >= 1) { |
| 227 | args.push('-top-ports', String(options.topPorts)); |
| 228 | } |
| 229 | if (options.excludePorts) { |
| 230 | args.push('-exclude-ports', options.excludePorts); |
| 231 | } |
| 232 | |
| 233 | // Rate and retries |
| 234 | if (typeof options.rate === 'number' && options.rate >= 1) { |
| 235 | args.push('-rate', String(options.rate)); |
| 236 | } |
| 237 | if (typeof options.retries === 'number') { |
| 238 | args.push('-retries', String(options.retries)); |
| 239 | } |
| 240 | |
| 241 | // Ping probes |
| 242 | if (options.enablePing) { |
| 243 | args.push('-ping'); |
| 244 | } |
| 245 | |
| 246 | // Network interface |
| 247 | if (options.interface) { |
| 248 | args.push('-interface', options.interface); |
| 249 | } |
| 250 | |
| 251 | return args; |
| 252 | }; |
| 253 | |
| 254 | const definition = defineComponent({ |
| 255 | id: 'shipsec.naabu.scan', |