Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

determine when a Env is being used for a Key #11

Closed
PatrickJS opened this issue Sep 17, 2018 · 0 comments
Closed

determine when a Env is being used for a Key #11

PatrickJS opened this issue Sep 17, 2018 · 0 comments

Comments

@PatrickJS
Copy link

PatrickJS commented Sep 17, 2018

building on the idea of (envkey/envkey-app#15) when you overwrite process.env you can also include getter/setters to keep track of if an Env is being used. Most of the time these would be set to a variable or the user opting into this would be aware of the getter/setters being tracked. Envkey can send up this data during an app's healthcheck. You can also track if the env was overwritten then send up data saying if the value was different from what was in Envkey. And you can even block get/set.

const envkeys = {
  // only secret keys that are set to be removed rather than static keys like
  NODE_ENV: {
    get: function () {
      // batch track get events or even block
      return '';
    },
    set: function (value) {
      // batch track set events or even block
      return value
    }
  }
}
Object.defineProperties(
  Object.getPrototypeOf(process.env),
  envkeys
)
return envkeys // the object returned from 'envkey/fetch' for when a user prefers the envkey object over process.env

Bonus Experiment
With get/set you can even limit key get requests during runtime onced a certain amount of time/useable before removing the values completely. This could prevent any future users from trying to access the envs if someone compromised a box or somehow managed to send up javascript requests to send down the process.env values. At the same time envkey would need to be versioned to determine the current state of all the envs at any given time and to see in the logs when a key was added/removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants