Skip to content

Sprint review: URL templates from a spec may only name arguments; form requests send their fields - #29

Merged
thorwhalen merged 5 commits into
masterfrom
sprint-review-http2py
Oct 13, 2026
Merged

thorwhalen merged 5 commits into
masterfrom
sprint-review-http2py

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Sprint review (2026-10-11 → 13) of #20, #22, #24, #27: adversarial review, design review, coverage first.

Findings fixed here

  • A spec could read the caller's arguments into the URL. A request function fills its url_template with str.format(**arguments), and the template comes from the spec, which HttpClient may fetch from the server. A placeholder like {x.__class__} or {x.f.__globals__[KEY]} reads attributes of the caller's own arguments (for pickled object arguments, module globals) into the URL sent to that server. mk_request_function now refuses any placeholder, or query_arg_names entry, that looks up an attribute or item (., [, or a nested field in a format spec), via check_url_template, so a client built from such a spec fails at construction. Other names, such as OpenAPI's hyphenated {user-id}, still work. This is the threat model of Never unpickle binary responses unless explicitly asked (binary_loads= / binary_dumps= seams) #20 and Routes live in client.routes; a route name cannot replace a client attribute (#23) #24 (a spoofed or compromised server). No dependent in the local package fleet uses dotted or indexed placeholders.
  • Multipart form requests sent nothing unless the method was GET. The form branch of request_func hung off if method != "GET" as an elif.

Reviewed, not defects

Review

An independent adversarial review (Opus) found two should-fix problems, both now fixed and tested. First, query_arg_names bypassed the check. Second, refusing every non-identifier placeholder broke hyphenated {user-id} paths, which worked on master. It confirmed that the form fix never sends both data and files. On master, form fields were never sent through HttpClient at all, since it passes lowercase methods.

Tests

Characterisation tests first (they pass on master). Full suite: 109 passed (was 93). Coverage: decorators 88% → 90%, py2request 67% → 69%, total 66% → 67%. Most of client.py's remaining gap is the login/refresh flow, which the sprint did not touch.

🤖 Generated with Claude Code

thorwhalen and others added 5 commits October 13, 2026 06:43
… URL encoding

Characterisation tests on the unchanged code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A request function fills its url_template with str.format(**arguments), and the
template comes from the spec, which HttpClient may fetch from the server. A
placeholder such as {x.__class__} or {x.f.__globals__[KEY]} would read
attributes of the caller's own arguments (with pickled object arguments, module
globals) into the URL sent to that server. mk_request_function now refuses any
placeholder that is not a plain name, so a client built from such a spec fails
at construction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nly GET

The form branch of request_func hung off 'if method != "GET"' as an elif, so
a POST (or PUT...) with content type multipart/form-data sent no body at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rg_names too

From the adversarial review of this PR:
- hyphenated OpenAPI placeholders ({user-id}) worked on master and were refused,
  taking the whole client down with them. Only '.' and '[' (attribute and item
  lookups) and nested fields in a format spec are refused now;
- query_arg_names, appended as ?name={name} at call time, bypassed the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 7f8b85f into master Oct 13, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the sprint-review-http2py branch October 13, 2026 06:49
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.

1 participant