-
Notifications
You must be signed in to change notification settings - Fork 5.6k
feat(cli/args): implement --deny-import flag #29702
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
base: main
Are you sure you want to change the base?
Conversation
.arg( | ||
{ | ||
let mut arg = deny_import_arg().hide(true); | ||
if let Some(requires) = requires { | ||
// allow this for install --global | ||
if requires != "global" { | ||
arg = arg.requires(requires) | ||
} | ||
} | ||
arg | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ANNOTATION: simply a clone of the allow_import_arg behavior from the lines above it:
Lines 4084 to 4095 in 724685c
.arg( | |
{ | |
let mut arg = allow_import_arg().hide(true); | |
if let Some(requires) = requires { | |
// allow this for install --global | |
if requires != "global" { | |
arg = arg.requires(requires) | |
} | |
} | |
arg | |
} | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deny_import_arg behavior is a bit different from allow_import_arg.
Do you mean that I should extract line 4099-4104 as a method?
Or, am I missing something...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No just commenting on the diff. The behavior here wasn't exactly obvious and highlighed well by the diff.
If you were curious, I initially didn't understand the // allow ...
comment until I looked at the undiffed file and realized it was a copy and paste.
Closes: #29502
Preparing deny_import.js like below,
I verified that these changes were working properly by running the following command:
~/denoland/deno/target/debug/deno run --deny-import="example.com:443,deno.land:443" deny_import.js
shows an import access error like the one below.I also verified that
~/denoland/deno/target/debug/deno run --deny-import="example.com:443" deny_import.js
does not show any errors because example.com is not referenced in deny_import.js