(command: string, args: string[], options: ExecutionOptions)
| 331 | } |
| 332 | |
| 333 | export function getSandboxNsjailOptions(command: string, args: string[], options: ExecutionOptions): NsJailOptions { |
| 334 | // If we already had a custom cwd, use that. |
| 335 | if (options.customCwd) { |
| 336 | let relativeCommand = command; |
| 337 | if (command.startsWith(options.customCwd)) { |
| 338 | relativeCommand = path.relative(options.customCwd, command); |
| 339 | if (path.dirname(relativeCommand) === '.') { |
| 340 | relativeCommand = `./${relativeCommand}`; |
| 341 | } |
| 342 | } |
| 343 | return getNsJailOptions('sandbox', relativeCommand, args, options); |
| 344 | } |
| 345 | |
| 346 | // Else, assume the executable should be run as `./exec` and run it from its directory. |
| 347 | options = {...options, customCwd: path.dirname(command)}; |
| 348 | return getNsJailOptions('sandbox', `./${path.basename(command)}`, args, options); |
| 349 | } |
| 350 | |
| 351 | export function getSandboxCEWrapperOptions(command: string, args: string[], options: ExecutionOptions): NsJailOptions { |
| 352 | return getCeWrapperOptions('sandbox', command, args, options); |
no test coverage detected