Repository navigation
Add --net and the project key net for the network policy - #1098
Open
beetlebugorg wants to merge 1 commit into
Open
beetlebugorg wants to merge 1 commit into
beetlebugorg wants to merge 1 commit into
Conversation
A script with the capability socket could reach only loopback, and no flag changed that. `ztk --net POLICY` now sets the network policy of ztcl: loopback (the default), any, or allow=LIST of hosts, address ranges, and ports. `ztk run` reads the key net of ztcl.project. A policy other than loopback needs the consent of the user: on a terminal, ztk asks the question and runs only after the answer y. With no terminal, the user gives the same policy with --net, and without it the run stops with status 2 and names the flag. --net with another policy than the key is an error. A bad policy is an error with its text. SECURITY.md has a section on the network. Fixes #758
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ztk --net POLICYsets the network policy ofsocket:loopback(the default, as before),any, orallow=LISTof hosts, address ranges, and ports (ztcl.sock.parsePolicy). A bad policy is an error that shows its text.ztk runreads the keynetofztcl.project. A policy other thanloopbackneeds the consent of the user:y.--net. Without it, the run stops with status 2 and names the flag, in the form of the no-terminal message ofztcl run.--netwith a policy other than the key's is an error.runcmd.payloadOfof ztcl beta.9 refuses it ("ztcl run does not yet apply the key net").runproject.preparenow returns the payload and the policy.loopback.SECURITY.mdhas a section on the network, anddocs/cli.mdhas the new flag.Fixes #758
Tests
zig build testpasses, with a new test ofnetNeedsConsentand of the question text, which has no control code.tests/help.shpasses.--allow socketandsocket 192.0.2.1 80:--net allow=192.0.2.0/24:80: "connection refused", so the policy let it through.net allow=192.0.2.0/24:80:--netand the same policy: it runs.--net any: an error.net loopback: no question.net bad: an error.net any:yruns andnstops with "not run".Notes for ztcl
The question of
ztcl run(askProject,askFirst) is private to themain.zigof ztcl, so ztk has its own short question with no "always" answer. Two requests to ztcl:ztk runcan offer "always".netinztcl run.