Skip to content

Commit

Permalink
sink: --allow-net="" allows any host
Browse files Browse the repository at this point in the history
**Summary**
This change ensures that the --allow-net flag works in environments were
changing the command line arguments is not feasible/recommended (e.g.
docker containers).

Fix #312
  • Loading branch information
fracek committed Jan 19, 2024
1 parent 7021f25 commit dc202c7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion script/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,23 @@ impl Script {
}

fn default_permissions(options: &ScriptOptions) -> Result<PermissionsContainer, ScriptError> {
// If users use an empty hostname, allow all hosts.
let allow_net = options.allow_net.clone().map(|hosts| {
if hosts.len() == 1 {
if hosts[0].is_empty() {
vec![]
} else {
hosts
}
} else {
hosts
}
});

match Permissions::from_options(&PermissionsOptions {
allow_env: options.allow_env.clone(),
allow_hrtime: true,
allow_net: options.allow_net.clone(),
allow_net,
prompt: false,
..PermissionsOptions::default()
}) {
Expand Down

0 comments on commit dc202c7

Please sign in to comment.