Skip to content

feat: HTTP GET and HEAD data entries in the core and the CLI (#405, PR 2a) - #534

Open
dean0x wants to merge 54 commits into
mainfrom
feat/405-pr2a-http-get-head
Open

dean0x wants to merge 54 commits into
mainfrom
feat/405-pr2a-http-get-head

Conversation

@dean0x

@dean0x dean0x commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

A template can declare a URL data entry. Before this PR, each compile refused a URL entry that had no replay value (mds::network_denied). With this PR, mds build sends HTTP GET and HEAD requests for these entries when the host opens the network.

This is PR 2a of the split of #405.

Changes

Core (mds-core)

  • Placement encoders for path, query and header values (crates/mds-core/src/data/encode.rs).
  • A strict URL parser (CheckedUrl, Origin).
  • Request identity: SHA-256 over the canonical request text (RequestId). The core has its own SHA-256 and HMAC-SHA-256 code, so the core and the WASM build need no hash crate.
  • An allow list (NetworkPolicy, AllowItem). A config can only narrow it (NetworkPolicy::narrow).
  • Address ranges that a host name can never open (NetworkPolicy::check_address).
  • Redirect hops: the core checks each hop as a new request, with a maximum of 5 hops for each entry. The sender follows no redirect.
  • Header rules: the core refuses a literal value for a credential header (authorization, proxy-authorization, cookie, x-api-key). These headers accept only the secret form, and a redirect to a different origin removes them. The core also refuses the headers that the sender writes (Host, Content-Length, Transfer-Encoding, Connection, Keep-Alive, Proxy-Connection, TE, Trailer, Upgrade).
  • The {secret, prefix} header form. Only the entry module can use it. This rule also applies to replayed entries.
  • A step engine and a public step API: compile_step_native_fs, compile_step_virtual_fs and compile_step_str, with FetchContext, FetchState and Step. Each step is a fresh compile. It derives each request again and checks every rule again before it binds the responses of the state.
  • A status envelope: with envelope: true, a request map binds {status, headers, body} for a final status from 200 to 599.
  • A remote_inputs result field (CompileResult.remote_inputs). It lists the bound URL entries in template form. The canonical JSON writes remoteInputs only when the list is not empty.
  • Two lint rules: insecure-data-origin (a request map with an http:// URL) and literal-credential-header (a header with literal text when its name contains token, secret, api-key, apikey or password). Both rules warn by default. They have no automatic fix.
  • A new error code mds::network and new network limits (spec §4.1, "Network limits").

New crate mds-fetch

  • Pinned dependencies: ureq =3.5.0, rustls =0.23.46 with ring, and webpki-root-certs =1.0.11. rcgen =0.14.10 is for tests only.
  • The sender follows no redirect.
  • It checks every address of a lookup before it connects, and it connects only to an address that the policy passed.
  • It takes no proxy from the environment. crates/mds-fetch/tests/proxy.rs proves this: a child process sets all six proxy variables, and the proxy listener gets no connection.
  • It keeps certificate verification on. It takes extra roots only from the host (--tls-root).
  • It counts the body bytes against a cap, and each request has a deadline.

CLI (mds-cli)

  • mds build --allow-net=<origins> opens the network for the listed origins only. Each item names one exact origin: host, host:port, https://host[:port] or http://host:port. Without the flag, the network stays off.
  • --allow-net-imports lets the URL entries of imported modules and @extends bases send.
  • --secret NAME=env:VAR@ORIGIN sets a header value of the entry module from the environment variable VAR. The CLI sends it to ORIGIN only.
  • --tls-root <file> adds a PEM file of extra trust roots.
  • --allow-net-imports, --secret and --tls-root need --allow-net.
  • The mds.json network section (allow, allow_imports) can only narrow the flags.
  • mds watch, check, lint and fmt send nothing, and they refuse --allow-net (tooling_never_sends_and_refuses_the_network_flags in crates/mds-cli/tests/cli_net.rs).

Release

  • release.yml publishes mds-fetch between mds-core and mds-cli. After each publish, it waits for the crates.io index.
  • The version gate (scripts/verify-versions.mjs) and the bump script (scripts/bump-version.mjs) cover the new crate.

Dependency policy

  • deny.toml accepts CDLA-Permissive-2.0 for webpki-root-certs only and BSD-3-Clause for subtle only. about.toml adds the two licenses to its accepted list.
  • deny.toml skips the second versions getrandom@0.2.17 and windows-sys@0.52.0, and the windows-targets@0.52.6 tree. ring uses these versions.
  • The maintainer confirmed this scope. cargo-deny reports no warning.
  • crates/mds-core/tests/supply_chain.rs proves that mds-core and mds-wasm hold no HTTP, TLS, URL or async crate.

Breaking Changes

None against v0.7.0. The data entries of #405 are not in a release yet. CHANGELOG.md (### Changed) lists three request map rules that this PR changes.

Testing

Test Coverage

  • 171 new Rust tests. 141 of them are in new files:
    • Core unit tests for digest, encode, envelope, policy, request, step and url (in crates/mds-core/src/data/).
    • crates/mds-core/tests/data_step.rs, net_sinks.rs and supply_chain.rs.
    • crates/mds-fetch/tests/plain.rs, proxy.rs and tls.rs. The TLS tests make their CA, certificate and key at test time, so the repository holds no key.
    • crates/mds-cli/tests/cli_net.rs.
  • Script specs in scripts/__test__: cargo-deny-policy, release-auth-probe and verify-versions.

Testing Gaps

  • Until the NOTICE refresh, the Version gate check fails on the NOTICE comparison.
  • No binding sends a request in this PR (see Known Limits).

WASM size

  • CI at 05fb90e: 968,871 B raw (402,711 B gzip). Base 6e1a80f: 944,967 B. Delta: +23,904 B. Limit: 975,000 B (headroom: 6,129 B).
  • The WASM build never starts a step compile. The resolver gets to the step engine through a fn pointer (BindFn, crates/mds-core/src/data/step.rs:463). Only a step compile sets it (StepCtx::new, line 312). Thus the linker removes the engine from the WASM build (local gain: 55,103 B).
  • PR 2b raises the limit by the rule of ci: raise the WASM size limit to 975,000 bytes #530, at its own CI number.

Release steps (maintainer)

  • The first release with mds-fetch publishes a new crate name. Before that tag, give the crates.io token the scope to publish a new crate. Alternatively, publish mds-fetch one time by hand (RELEASING.md, prerequisite 3).

Still to come in this PR

  • The NOTICE refresh of both copies (NOTICE and crates/mds-python/NOTICE), with the pinned cargo-about. Until then, the Version gate check fails on the NOTICE comparison.
  • Two CLAUDE.md lines: the Windows local clippy twin and the publish dry-run note.

Known Limits

  • The napi, Python, WASM and JS bindings keep mds::network_denied for a URL entry with no replay value until PR 2b.
  • mds watch keeps the network off.
  • An @extends base counts as a module other than the entry module. Its URL entry needs the import opt-in (--allow-net-imports), and it cannot use the {secret, prefix} header form.
  • The design (Known limits table) gives the other limits. Examples: the browser residuals of PR 2b, and the reflection check that does not see a transformed value.

Related Issues

Refs #405

The last PR of the split closes the issue.

Reviewer Focus Areas

  1. crates/mds-core/src/data/policy.rs:398 - check_address: the address ranges that a host name cannot open.
  2. crates/mds-core/src/data/step.rs:664 - follow: the core checks each redirect hop as a new request.
  3. crates/mds-core/src/data/decl.rs:114 - CREDENTIAL_HEADERS, and SENDER_HEADERS at line 132.
  4. crates/mds-fetch/src/send.rs:164 - agent: no proxy and no redirect.

Add the request, response, time and address limits of network data
entries. A host driver can read the limits that it applies.

Add MdsError::Network with the code mds::network and a named
constructor. The message names the module, the entry, the URL as
declared and the origin. It never holds the expanded URL. The CLI
exits 2 for this code. The spec registry has its row.

Refs #405
Add one parser for every URL that a data request can go to. It accepts
https and http URLs of visible ASCII with a lower-case host name, an
IPv4 address of four decimal parts or an IPv6 address in brackets. It
refuses user information, backslashes, fragments, bad percent forms,
numeric host names, zones and bad ports. A redirect location is an
absolute URL or an absolute path on the base origin. Each refusal has
a fixed reason that holds no input.

The step engine is the first caller. This change has no behavior
change.

Refs #405
Add SHA-256 (FIPS 180-4) and HMAC-SHA-256 (RFC 2104) as own code, so
the core and the WASM build need no hash crate. The FIPS 180-4 examples
and the RFC 4231 cases 1, 2, 3, 4, 6 and 7 prove the code. The block
loop is bounded by the input length and does not allocate.

The request identity is the first caller. This change has no behavior
change.

Refs #405
Add one expansion path from a URL or header template and its reference
values to request text, for every value source. The place of a
reference comes from the literal template text, before or after the
first literal `?`, never from a value. Each value is inserted once and
never scanned again.

A path segment value is percent-encoded outside the RFC 3986
unreserved set, and empty text, `.` and `..` are refused. A query value
has the same byte rule. A header value can hold only visible ASCII and
spaces, and other text is refused. A URL can not grow past the URL
length limit.

A value becomes text only as a string, `true` or `false`, or an exact
integer up to 2^53. Other values fail with mds::type_error, through
the new MdsError::DataTypeError that names the module, the entry and
the field.

The reference scanner now also gives the literal text between the
references. The step engine is the first caller. This change has no
behavior change.

Refs #405
A URL entry now keeps its request template: the URL as declared, the
method, the format, the envelope flag, the headers and the references.

New declaration rules, each mds::data, also for an entry that replay
satisfies:
- A request map can name an http:// URL. The string form keeps the
  https rule.
- The new request field `envelope` is a boolean. `accept` is json by
  default.
- A GET or HEAD request cannot have a body. HEAD requires
  `envelope: true`.
- Authorization, Proxy-Authorization, Cookie and X-Api-Key take the
  secret form only. A secret prefix is header text.
- The strict URL parser reads the literal URL, so a short IPv4 form or
  a bad port fails at declaration.

Refs #405
The new public NetworkPolicy holds the host allow list, the import
opt-in and the host secrets. A host builds it once, and the core
checks each request against it.

- AllowItem::parse reads host, host:port, https://host[:port] or
  http://host:port through the strict URL parser. A match needs the
  same scheme, the exact host and the same port.
- narrow is the one narrowing rule: each item and the import grant
  must be in the wider policy.
- check_address refuses the local, private, shared, reserved and
  multicast ranges. Only an allow item of that exact IP address with
  its port opens such an address.
- The hop check refuses https to http, a target that is not in the
  allow list and a chain past five hops. A hop to another origin
  drops the secret and credential headers.
- A secret value has a hidden Debug form and one send accessor.

Scheme, Host and Origin of the URL parser are now public.

Refs #405
The new public Request type holds the method, the checked URL, the
format and the headers of one request. A secret header holds its
secret name and prefix only, never the value.

The request ID is the SHA-256 digest of a canonical text: the method,
the final URL, the format, each header in lower-case name order and
the body (empty in this release). A secret header enters as its name,
its prefix and the HMAC-SHA-256 of its value under a per-run key that
the host gives with RunKey::from_bytes. A request with a secret header
must bind to a host secret of the request origin.

RequestId has a strict form of 64 lower-case hex digits. CheckedUrl
of the URL parser is now public with read accessors.

Refs #405
A data entry can declare at most 32 request headers, counted at
declaration before any header is kept. One request header value holds
at most 8 KiB, checked before each append of the expanded text. Each
limit fails with mds::resource_limit and has an at-cap and an
over-cap test.

Refs #405
The data graph keeps the level of each entry. The bind walks the
entries level by level, in declaration order inside a level, so an
entry always binds after each entry that it references. File entries
are all on the first level, so their read order does not change.

Refs #405
A step compile refuses host input that it did not ask for: a fetch
state with a response that the compile did not request. The core now
returns mds::invalid_options for it, with fixed text and no source
span. The bindings keep the code for their own option checks. On the
CLI the code exits with 2.

Refs #405
A step compile now derives the request of each URL entry in level
order and binds the responses that the host gives. An entry with no
response adds its request to the needed list once and stays pending,
as does each entry that references a pending entry. Each round checks
the method, the expanded URL, the allow list, the import opt-in and
the secret headers again. A redirect goes through the location, hop
and header rules as a new request, for at most five hops. A response
body goes through the data file converter and the byte cap of the
compile, and a value or a location that holds a host secret value
fails. A compile derives at most 64 distinct requests, and a response
that the compile did not request fails with mds::invalid_options.

The engine has no public caller yet, and a compile without a step
context keeps the frontier refusal.

Refs #405
A request map with `envelope: true` binds `{status, headers, body}` for
any final status from 200 to 599. Header names become lower case with
`-` changed to `_`. A name that is then not an identifier is dropped, and
so are the cookie headers. Repeated headers join with `, `, and two names
with one key fail. A HEAD answer has `body: null`. Without the envelope,
a status that is not 2xx still fails.

The per-compile memo keys each value by the request ID and the envelope
flag, so one response binds a body entry and an envelope entry of the
same request in their own shapes.

Refs #405
`Debug` of `Request` now shows the ID, the method, the URL as declared,
the origin and the header names. `Debug` of `CheckedUrl` shows the origin
only, and `Debug` of a text header value shows no text. So a debug print
of a request never shows the expanded path or query or a header value.

`Request::template` gives the URL as declared, for host messages.

Refs #405
`compile_step_native_fs`, `compile_step_virtual_fs` and
`compile_step_str` run one step compile. Each call is a fresh compile
that derives every request again and runs every check again, with the
`FetchContext` (policy and run key) and the `FetchState` of the host.
It returns `Step::Done` with the result or `Step::Need` with the
requests.

The state holds responses only, keyed by request ID: a second response
for one ID and more than 64 responses fail. A host gives an answer as
`Response::http` or `Response::failed` with a fixed `TransportFailure`
kind.

`CompileResult.remote_inputs` lists each bound URL entry in template
form. The canonical JSON writes `remoteInputs` only when the list is
not empty, so every other result keeps its shape.

Refs #405
A refused request of a step compile now has the fixed help of the check
that refused it. Entries with no replay value keep the exact message and
help. `MdsError::network_refused` builds the refusal for a host, for
example a sender that refuses an address.

A data rule error of a response body now names the entry only. The key
path of a response is body text, so it is no longer in the message.

The step module lists each sink of request text and its one builder.
New tests check that a response value in a failed next URL is in no
message, `Debug` view, record, warning or result field.

Refs #405
An `@extends` base is a module other than the entry module. Its URL
entry needs the import opt-in and cannot use a secret header, also with
the opt-in. The spec states the rule, and a new test pins the secret
part, with the same text as the entry module as the control.

Refs #405
`insecure-data-origin` reports a request map that names an `http://`
URL. `literal-credential-header` reports a header with literal text
when its lower-case name contains `token`, `secret`, `api-key`,
`apikey` or `password`. Both rules warn by default, are never fixed,
read the declarations only and send no request. A message names the
entry and the header, never the header value.

The rule list now has 13 names in the Rust registry, the TypeScript
mirror, the CLI goldens, the spec and the READMEs.

Refs #405
Add crates/mds-fetch as a workspace member at the workspace version,
with a path and version dependency on mds-core. Pin ureq 3.5.0 (no
default features, rustls connector with no provider), rustls 0.23.46
(ring, std, tls12) and webpki-root-certs 1.0.11 with exact versions.
Pin rcgen 0.14.10 (ring and pem only) as a dev-dependency, so the TLS
tests make their certificates at test time.

Pin four transitive crates to versions older than 30 days:
rustls-webpki 0.103.16, rustls-pki-types 1.15.1, bytes 1.12.1 and
zeroize 1.9.1. No locked version of an existing package changed.

A crate clippy.toml refuses the ureq call that turns off the
certificate check. The release manifest lists the new crate, so the
version gate and the bump script include it.

Refs #405
Add two license exceptions, each for one crate only:
CDLA-Permissive-2.0 for webpki-root-certs (the Mozilla root list) and
BSD-3-Clause for subtle (a dependency of rustls). about.toml accepts
the same two licenses, in the order of the exceptions.

Add duplicate skips for getrandom 0.2.17 and windows-sys 0.52.0, which
ring uses. Add one tree skip for windows-targets 0.52.6: that tree
holds only windows-targets and its eight windows_* target crates.
There is no advisory ignore.

The policy spec pins the new exceptions, skips and tree skip, and
rejects a different tree, a depth field and an empty tree list.
RELEASING.md names the new skips.

Both NOTICE copies still need a refresh with cargo-about 0.9.1, so
that they hold the CDLA-Permissive-2.0 and BSD-3-Clause texts.

Refs #405
Make NetworkPolicy::bind_secret public, so a sender can bind each
secret header again for the request origin before it writes the
header. The core binds each secret header with the same function.

The request deadline covers the name lookup too, and one refused
address fails a request: the docs of REQUEST_TIMEOUT and of
TransportFailure::AddressRefused now say so.

Refs #405
Add Fetcher, the sender of the requests that a step compile needs.
Each request gets its own ureq agent with a fixed configuration:
- no proxy, no redirect and no idle connection;
- a resolver that does one lookup per request and checks each
  address with NetworkPolicy::check_address before it connects;
- the rustls TLS provider with ring, the Mozilla roots and the roots
  that the host gives, with the certificate check always on;
- the core header cap, a body read of at most the cap plus one byte,
  and a deadline that can only narrow the core request deadline.

Each secret header binds again for the request origin before the
sender writes it. Every failure is a fixed TransportFailure, so no
error text of a lower layer is in the response.

run_key makes a new run key from the system random source, and
parse_pem_roots reads the roots of a PEM file. A clippy rule of the
crate refuses the call that turns off the certificate check.

Refs #405
Each test runs its listener on 127.0.0.1:0 in the test process, and
no test reaches the internet. Each rule has a control that shows the
test can fail:
- plain.rs: a lookup answer in a refused range opens no connection;
  one lookup per request; no redirect; the address cap; the deadline;
  the body cap at the cap, one byte over, and the stop of the read;
  the header cap; the fixed request headers; HEAD; a full step; and a
  new run key for each run.
- tls.rs: an unknown root and a certificate for another address fail;
  a host root passes; a secret header sends its prefix and value and
  sends nothing when it does not bind; host roots are checked. The
  tests make the CA, the certificate and the key at test time, so the
  repository holds no key.
- proxy.rs: the test runs again as a child with each proxy variable
  set to a second listener. The sender does not connect to it, and a
  default ureq agent in the same child does.

Refs #405
Add a gate that follows the normal dependencies of mds-core and
mds-wasm for every target. It fails when the tree holds an HTTP, TLS,
URL, async runtime or root list crate, or mds-fetch. A second check
fails when any workspace crate depends on a logger crate.

The gate reads Cargo.lock for the edges and cargo metadata with
--no-deps --offline for the dependency kinds of the workspace crates,
so it needs no network access. It fails closed on an edge that it can
not follow. Controls: a planted lock where the core reaches ureq and
rustls, a planted logger, and the real tree of mds-fetch, which holds
ureq, rustls and ring.

Refs #405
The publish-crates job now publishes mds-core, waits for the index,
publishes mds-fetch, waits for the index again, and then publishes
mds-cli. The mds-fetch step uses the same re-run guard as the other
two publish steps, so a rerun passes when the version is already on
crates.io. Both index polls run the same bounded block, with the
crate name in the step env.

Spec S34 pins the order, the re-run guard, the poll bound and the
identical poll blocks, each with a planted control. Spec S24 now
expects three publish steps that bind the registry value.

RELEASING.md names mds-fetch in the version list, the token rights,
the job steps and the recovery table. The first release with
mds-fetch publishes a new crate name, so the token needs the scope
for a new crate before that tag.

Refs #405
`mds build` gets the flags `--allow-net`, `--allow-net-imports`,
`--secret NAME=env:VAR@ORIGIN` and `--tls-root`. Without `--allow-net`
the network stays off, and `mds.json` can not open it.

The `network` section of `mds.json` can only narrow the flags. An
unknown key or a bad allow item fails config loading. A wider list, or
`allow_imports: true` without `--allow-net-imports`, fails with
`mds::invalid_options` and names the field.

The driver runs step compiles over mds-fetch. Each round sends at most
8 requests at a time, one deadline binds the network work of a compile,
and one run sends at most 512 requests. `mds watch`, `check`, `lint`
and `fmt` have no network flags and send nothing.

The tests use listeners on 127.0.0.1 in the test process. Each check
of no connection has a control that sees a connection first.

Refs #405
mds-cli now has a path and version dependency on mds-fetch. The
version gate checks that this version is the workspace version, and
the bump script sets it, as for each dependency on mds-core. A
manifest that names mds-fetch in another form fails the gate.

Refs #405
The 30 s deadline of the network work of a compile now starts at the
first send of the compile, not at the first step compile. This agrees
with the documented limit: the time of the first local compile does not
use the network time.

Refs #405
The spec now gives the network grant and its allow list, the import
opt-in, host secrets, the address and redirect rules, the value-to-text
and encoder tables, the request identity, the errors of a request, the
start and resume of step compiles, the network limits and the order in
which they bind, the new mds build flags and the network section of
mds.json. The bindings still send no request in this release.

SECURITY.md, the CHANGELOG and the README replace the statement that
this release sends no request with these facts.

Refs #405
The check of the credential header list put one copy of the letter case
compare in the WASM build for each name of the list. Move the compare
into one function that is not inlined. The list and the result do not
change. The WASM build is 1,542 bytes smaller.

Refs #405
The WASM build has no step compile, but it kept the full engine of URL
data entries: the resolver called the engine directly when a step
context was present. Now the step context holds a pointer to the
engine, and only the constructor of the step context sets it. A build
that never starts a step compile has no path to the engine, so the
linker drops it. Native step compiles run the same code as before,
through one indirect call for each URL entry. The WASM build is
55,103 bytes smaller.

Refs #405
A request map could set the Host header and the headers that frame
the message, and the sender then wrote these values. Now a step compile
refuses these header names in any letter case and in any value form.
It fails with mds::data before a request exists. Thus a request reaches
only the origin of its URL.

The step engine builds the request headers in a separate function. The
spec, the changelog and SECURITY.md state the rule. The spec also says
that only an allow item can open an address of a refused range. The
WASM build does not change, because only the step engine calls the
check.

Refs #405
When the text after env: in a --secret flag is not an environment
variable name, the message no longer shows that text. The text can be a
value that the user typed in place of the variable name. The message
still names the flag index and NAME.

Refs #405
A URL entry with a secret header is allowed in the entry module only.
Before this change, only the request step applied the rule. A replayed
entry makes no request, so a replayed entry in an imported module or in
an @extends base passed. The data bind now applies the same check to
every URL entry, replayed or not, in a plain compile and in a step
compile. The request step and the data bind share one check function
and one message.

Tests: a replayed entry with a secret header fails in an imported module
and in an @extends base. Control: the same replayed entry in the entry
module renders the replayed value.

Refs #405
The panic gate follows each call by name. Three names in the network
driver led it to functions that write: `start`, `compile_source` and
`Response::failed`. Rename the first two, and write the third with its
`mds::` path.

A failed join of a send thread now gives the internal error. The panic
hook ends the process first on a thread that catches nothing, so the
driver needs no `resume_unwind`.

The gate now lists `compile_pinned_to_content` as a compile call. It is
the compile of one file of a directory build, with a network round in
it. Two controls of the gate now use the new catch closure text.

Refs #405
Add a test where the listener waits 100 ms of a 1 s narrowed deadline
and then answers 200. The test asserts the 200 body. The silent
listener test stays as the case past the deadline. A control with a
wait past the deadline fails, so the test reaches the deadline path.

Refs #405
@dean0x
dean0x marked this pull request as ready for review November 25, 2026 15:08
On Windows the CLI writes the mds.json path as ".\mds.json". Two
assertions in cli_net.rs held the "./mds.json" spelling, so they
failed only in the Windows CI job. Build the expected prefix with
MAIN_SEPARATOR_STR, as the other mds-cli tests do.

Refs #405
Some assertions put a planted test value, or text that can hold it,
in their failure message. Use fixed messages for these checks. Where
a later assertion prints an error message, check first that the
message does not hold the value. In cli_net.rs, check stdout and
stderr for the value before the other assertions print stderr.

Refs #405
Add a section about URL data entries: the step engine, the network policy, the request identity, the envelope, the mds-fetch sender and the CLI driver. Add rules for the engine pointer, secret values in test messages and CLI path text.

Refs #405
The envelope puts the response body one level deeper. A body with a
value at the value depth cap of 64 then gave an internal error. Now
the envelope refuses such a body with a data error of the field
`body`, and the compile ends with the normal exit code. A body with
no envelope binds as before.

Add a unit test for the cap and a step test that pairs the envelope
case with the same body with no envelope.

Task: resolve-b3
State in the `SystemLookup` docs that a lookup past its timeout keeps
its thread until the system lookup returns. The request cap of one CLI
run bounds the count of these threads. A host that runs for a long
time can give its own lookup with `Fetcher::with_lookup`.

State in the `Fetcher::new` docs that the sender does not examine the
allow list again. It uses its policy only for the address check and
the secret headers, so a host must give it the same `NetworkPolicy`
as the step context.

Task: resolve-b3
The raw response bodies of one compile now share one total of 200 MiB,
the compile memory budget. Every status counts, a redirect answer and
an error answer too. The fetch state counts each body as the response
enters it, so every host gets the bound. A body past the total fails
with a resource limit error (exit 3).

The 10 MiB body cap of one response now applies to a redirect answer
too, before the core follows it.

FetchState::body_bytes_left gives the bytes that a compile can still
take. The mds build driver adds each group of parallel sends to the
state before the next group starts, and gives each send an equal share
of the bytes left as its body cap. Thus a group in flight can not pass
the total. A body past a share below 10 MiB fails with the error of the
total (MdsError::response_bodies_exceeded).

Tests cover the total at the bound and one byte over, the body cap of
the core at the cap and one byte over (also for a redirect answer), the
data total of response bodies, and the shares of the driver.

Task: resolve-b1 (review findings 2 and 8)
A table test runs each redirect status (301, 302, 303, 307 and 308),
with and without the envelope. A location that the allow list does not
name fails the hop check. Controls: a listed location gives the next
request, and 300 and 304, which are not redirects, bind with the
envelope and fail without it. The spec states the 300 and 304 rule and
names the test.

Task: resolve-b1 (review finding 7)
Two rows join the response table of the step tests: the value of a host
secret in an array of an object, and in an object of a top-level array.
Both fail the response check, with the fixed message first. Control: the
same array shapes with another value bind.

Task: resolve-b1 (review finding 9)
A build that never starts a step compile, such as the WASM build, must
keep no step engine code. Resolver code reaches the engine only through
the StepCtx.bind pointer. A source scan now pins that shape:

- bind_url_entry calls the engine through ctx.bind only, and
  bind_with_engine is named only where it is defined and set.
- A bounded walk of src/ reads every directory and every file it needs.
  Outside the engine files, no code names an engine function, and only
  lib.rs starts a step context.
- Planted controls (a direct call at the pointer site, a call in a
  planted child module, a hop check in resolver code) each give exactly
  their own finding. Comments and literals give none.

The compiler now refuses the narrow names too: scan_secrets and
request_label are private to the step module, and StepCtx::new is
visible in the data module only.

Task: resolve-b1 (review finding 6)
The address table now refuses ::/96, ::ffff:0:0:0/96, 64:ff9b:1::/48,
2001::/32 and fec0::/10. The ::/96 range holds the unspecified and the
loopback address, so their two single rows go. Each range that embeds an
IPv4 address is refused whole.

The address test moves [::2], [fec0::] and the last fec0::/10 address
from passed to refused. It adds both edges of each new range to the
refused rows and the next address outside each range to the passed rows.
Spec section 4.12 lists the same ranges.

Task: resolve-b2 (finding 1)
The core sets the request method; headers that change it are refused.
A request map cannot set X-HTTP-Method-Override, X-HTTP-Method or
X-Method-Override, in any letter case. They join the list of headers
that a request cannot set, so a step compile fails with the same
mds::data error before any request exists.

Tests: a unit row for each name in mixed case, and the three names in
the step compile test of these headers. Controls: a longer name passes
in both tests. Spec section 4.12 and the CHANGELOG state the rule.

Task: resolve-b2 (method headers)
Remove a stale known-limits line in spec section 4.12. It said that
this release fetches no URL, but mds build --allow-net sends GET and
HEAD requests.

The --secret row of the mds build options and SECURITY.md now state
that a directory build compiles each .mds file of the tree that is not
a partial as its own entry module with the same network flags, so each
such file can use the secret header form.

Task: resolve-b2 (stale line, directory builds)
Some tests that plant a value printed text that can hold it in an
assertion message: the error text, the lint output, the request
heads and the lint diagnostics. Check that the value is absent first
in each such test. Give each assertion a fixed message, and compare
the span text instead of printing it.

The lint CLI test now reads the output directly, because the shared
JSON helpers print the output when they fail. It also checks the
decoded JSON, in case the JSON text escapes the value.

The same order now applies to the control run of the secret chain
and to the response-value test in cli_net.rs.

Refs #405
The build driver starts one deadline at the first send of a compile,
and each later round gets only the time that is left. No test showed
this: a change that starts a new deadline for each round passed.

The deadline length is now a field of the network run, set to the
compile deadline, with a test-only setter. A new unit test sends a
two-level chain to a local listener that answers each request after
150 ms. With a 250 ms deadline the first request passes and the
second fails with the timeout. With a 2 s deadline the chain renders.
With a new deadline for each round, the short run renders, and the
test fails.

The doc of the compile deadline now states what the driver does: one
deadline from the first send, a check before each send, and at most
the time left for each send.

Refs #405
The test that mds watch refuses --allow-net waited for the child with
no bound. If watch took the flag, it would start, never stop, and the
test would hang with no failed assertion.

Spawn the child under the kill-on-drop guard and poll it for at most
10 s. If it is still alive, kill it and fail with a fixed message.
The exit code and stderr checks stay. With the flag removed from the
command, watch starts, and the test fails after about 10 s with that
message.

Refs #405
The notice config now accepts CDLA-Permissive-2.0 for webpki-root-certs only and BSD-3-Clause for subtle only, as the dependency policy does. The policy spec checks both crate tables, with three controls.
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.

2 participants