AWS Thinkbox Discussion Forums

SetProcessEnvironmentVariable unwanted log message


I have written an event plugin. In this event plugin, in a OnJobFinished callback, I use the SetProcessEnvironmentVariable method to pass environment variables to the subprocess I’m executing using the RunProcess command.

All that works fine, except for one thing : in the job reports, I get log messages such as :

2023-09-16 21:40:51: SGPublishEvent: Setting Process Environment Variable TEST to xxxxxxxxxxxxxxxxxxxxxx

As I’m using this to pass an API user and password to the subprocess, I don’t want the SetProcessEnvironmentVariable to create any log message. Can I prevent this from happening ?


Mmmm. You can’t directly, but these days the Sandbox process should be safe enough to use the os.environ dictionary directly in Python and it’ll propagate downward. You could even unset the state after launching the process. Note though that any user who is running as the same account as the Worker may be able to interrogate the processes environment and gain access to the secret. Still, more secure than writing it straight to the log.


In the past I avoided using os.environ to set variables, I had some problems with that.

But I followed your advice and replaced SetProcessEnvironmentVariable by os.environ and it works fine.


1 Like
Privacy | Site terms | Cookie preferences