6 ms·
Might something like this work as a robust solution: https://0bin.net/paste/TTOdW9+B#olQ+FmoCmluokC8UdWllx8GXQtos48RCUMX+7HmRFzL https://0bin.net/paste/TTOdW9+
by tlonny 4y ago
Might something like this work as a robust solution:
https://0bin.net/paste/TTOdW9+B#olQ+FmoCmluokC8UdWllx8GXQtos48RCUMX+7HmRFzL https://0bin.net/paste/TTOdW9+B#olQ+FmoCmluokC8UdWllx8GXQtos...
TL;DR
At program initialization, clear the `environ` object, and stash the environment variables in some random location in memory. You can then restore the `environ` object when needed via a contextmanager - meaning that code must explicitly be granted permission to access env vs. being able to snoop regardless.
Curious to hear your thoughts!
EDIT: I wonder if this approach could be extended to allow the use of certain "restricted" libraries (I'm thinking stuff to do with network calls/file system) only within specific scopes - as this would defend against publishing the env vars to a public endpoint...