Set and unset aws environment variables
in order to provide the CodeOcean context for some scripts and hide AWS credentials from the users.
This commit is contained in:

committed by
Sebastian Serth

parent
ecce3c294f
commit
903ad415c6
@ -84,6 +84,7 @@ func (w *AWSFunctionWorkload) ExecuteInteractively(id string, _ io.ReadWriter, s
|
||||
if !ok {
|
||||
return nil, nil, ErrorUnknownExecution
|
||||
}
|
||||
w.prepareEnvironmentVariables(request)
|
||||
command, ctx, cancel := prepareExecution(request)
|
||||
exitInternal := make(chan ExitInfo)
|
||||
exit := make(chan ExitInfo, 1)
|
||||
@ -208,3 +209,12 @@ func (w *AWSFunctionWorkload) handleRunnerTimeout(ctx context.Context,
|
||||
exit <- ExitInfo{255, ErrorRunnerInactivityTimeout}
|
||||
}
|
||||
}
|
||||
|
||||
// prepareEnvironmentVariables sets the CODEOCEAN variable and unsets some AWS variables.
|
||||
func (w *AWSFunctionWorkload) prepareEnvironmentVariables(request *dto.ExecutionRequest) {
|
||||
if request.Environment == nil {
|
||||
request.Environment = make(map[string]string)
|
||||
}
|
||||
request.Environment["CODEOCEAN"] = "true"
|
||||
request.Command = "unset \"${!AWS@}\" && " + request.Command
|
||||
}
|
||||
|
Reference in New Issue
Block a user