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

feat(permissions): allow env permission to take values #9825

Merged
merged 27 commits into from
Apr 13, 2021

Conversation

crowlKats
Copy link
Member

closes #3137

@crowlKats crowlKats changed the title feat(permissions): allow env to take values feat(permissions): allow env permission to take values Mar 18, 2021
@bartlomieju bartlomieju added this to the 1.9.0 milestone Mar 18, 2021
# Conflicts:
#	runtime/ops/os.rs
# Conflicts:
#	runtime/ops/worker_host.rs
runtime/ops/os.rs Outdated Show resolved Hide resolved
@kt3k
Copy link
Member

kt3k commented Mar 22, 2021

I tried simple script like the below on my end with and without combinations of perm flags.

await Deno.permissions.request({ name: 'env', variable: 'FOO' })
console.log(Deno.env.get('FOO'));

The basic feature seems working to me. Good feature to have! 👍

crowlKats and others added 3 commits March 23, 2021 02:28
# Conflicts:
#	runtime/ops/worker_host.rs
#	runtime/permissions.rs
cli/flags.rs Show resolved Hide resolved
cli/tests/unit/os_test.ts Outdated Show resolved Hide resolved
@bartlomieju
Copy link
Member

In general this PR looks good to me, but I have one comment that makes me wanna skip it for 1.9: with this change --allow-env allows to provide a list of variables that can be read and set - I'm thinking that maybe we should split this flag into to, one for reading and one for setting (similar to --allow-read and --allow-write).

Before making decision I will wait for other contributors opinions.

@lucacasonato
Copy link
Member

I'm thinking that maybe we should split this flag into to, one for reading and one for setting

I don't think this is needed as setting env vars only has an effect on you, and your processes children, but not siblings or parent processes.

@nayeemrmn
Copy link
Collaborator

I don't think this is needed as setting env vars only has an effect on you, and your processes children, but not siblings or parent processes.

Hmm, doesn't that also mean that variables should be settable without permission and allowlisted thereafter?

@bartlomieju
Copy link
Member

I don't think this is needed as setting env vars only has an effect on you, and your processes children, but not siblings or parent processes.

Hmm, doesn't that also mean that variables should be settable without permission and allowlisted thereafter?

@nayeemrmn I don't understand the question, could you provide an example?

@nayeemrmn
Copy link
Collaborator

nayeemrmn commented Apr 9, 2021

I realised since setting env variables within the process doesn't affect the outside, there's no reason for it to require permission.

Deno.env.get("foo"); // Requires `--allow-env=foo`.
Deno.env.set("foo", "bar"); // Shouldn't require permission.
Deno.env.get("foo"); // Shouldn't require permission.

@bartlomieju
Copy link
Member

I realised since setting env variables within the process doesn't affect the outside, there's no reason for it to require permission.

Deno.env.get("foo"); // Requires `--allow-env=foo`.
Deno.env.set("foo", "bar"); // Shouldn't require permission.
Deno.env.get("foo"); // Shouldn't require permission.

@nayeemrmn so this suggestion alters current behavior, which would be a breaking change. I'm also not sure how would it be implemented, but I'm more than happy to discuss it for 2.0.

@nayeemrmn
Copy link
Collaborator

nayeemrmn commented Apr 9, 2021

If you take away a permission gate because it's not actually a security issue, I'm not sure it's a breaking change. But either way it certainly doesn't need to be part of this PR 👍

(EDIT: I suppose it would be breaking for workers? ¯_(ツ)_/¯)

crowlKats and others added 5 commits April 12, 2021 01:44
# Conflicts:
#	cli/flags.rs
#	runtime/ops/os.rs
#	runtime/ops/permissions.rs
#	runtime/ops/worker_host.rs
#	runtime/permissions.rs
# Conflicts:
#	runtime/ops/os.rs
#	runtime/permissions.rs
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - nice work @crowlKats !

@piscisaureus
Copy link
Member

piscisaureus commented Apr 12, 2021

I think sufficient effort was put into this PR to address Windows quirks.

Of course, it is not a given that windows uses case folding that is 100% compatible with .toUpperCase(). Who knows, this could lead to some obscure bugs down the line, or not.

@bartlomieju

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

Successfully merging this pull request may close these issues.

Limited Permission for --allow-env
7 participants