diff --git a/lib/compilers/golang.ts b/lib/compilers/golang.ts index 903278461..f899d0964 100644 --- a/lib/compilers/golang.ts +++ b/lib/compilers/golang.ts @@ -66,7 +66,8 @@ export class GolangCompiler extends BaseCompiler { 'goroot', this.compilerProps(`group.${group}.goroot`), ); - const goarch = this.compilerProps( + // GOARCH can be something like '386' which is read out as a number. + const goarch = this.compilerProps( 'goarch', this.compilerProps(`group.${group}.goarch`), ); @@ -80,7 +81,7 @@ export class GolangCompiler extends BaseCompiler { this.GOENV.GOROOT = goroot; } if (goarch) { - this.GOENV.GOARCH = goarch; + this.GOENV.GOARCH = goarch.toString(); } if (goos) { this.GOENV.GOOS = goos; diff --git a/lib/exec.ts b/lib/exec.ts index 608994713..b1787413c 100644 --- a/lib/exec.ts +++ b/lib/exec.ts @@ -48,6 +48,18 @@ type NsJailOptions = { const execProps = propsFor('execution'); +function checkExecOptions(options: ExecutionOptions) { + if (options.env) { + for (const key of Object.keys(options.env)) { + const value: any = options.env[key]; + if (value !== undefined && typeof value !== 'string') { + logger.warn(`Found non-string in environment: ${key} of ${typeof value} : '${value}'`); + options.env[key] = value.toString(); + } + } + } +} + function setupOnError(stream: Stream, name: string) { if (stream === undefined) return; stream.on('error', err => { @@ -393,6 +405,7 @@ export async function sandbox( args: string[], options: ExecutionOptions, ): Promise { + checkExecOptions(options); const type = execProps('sandboxType', 'firejail'); const dispatchEntry = sandboxDispatchTable[type]; if (!dispatchEntry) throw new Error(`Bad sandbox type ${type}`); @@ -608,6 +621,7 @@ export async function execute( args: string[], options: ExecutionOptions, ): Promise { + checkExecOptions(options); const type = execProps('executionType', 'none'); const dispatchEntry = executeDispatchTable[type]; if (!dispatchEntry) throw new Error(`Bad sandbox type ${type}`);