Repository navigation
Sprint review: URL templates from a spec may only name arguments; form requests send their fields - #29
Merged
Conversation
… 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>
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.
Sprint review (2026-10-11 → 13) of #20, #22, #24, #27: adversarial review, design review, coverage first.
Findings fixed here
url_templatewithstr.format(**arguments), and the template comes from the spec, whichHttpClientmay 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_functionnow refuses any placeholder, orquery_arg_namesentry, that looks up an attribute or item (.,[, or a nested field in a format spec), viacheck_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.request_funchung offif method != "GET"as anelif.Reviewed, not defects
binary_loads=says so;check_loadswarns on a barepickle.loads;default_binary_output_transnow raises rather than unpickling.setup.cfgvalues are collapsed to one line with%escaped.client.routesholds every route.operationId, then method plus path, sanitised into identifiers. Duplicates warn (now tested).Review
An independent adversarial review (Opus) found two should-fix problems, both now fixed and tested. First,
query_arg_namesbypassed 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 bothdataandfiles. On master, form fields were never sent throughHttpClientat all, since it passes lowercase methods.Tests
Characterisation tests first (they pass on master). Full suite: 109 passed (was 93). Coverage:
decorators88% → 90%,py2request67% → 69%, total 66% → 67%. Most ofclient.py's remaining gap is the login/refresh flow, which the sprint did not touch.🤖 Generated with Claude Code