Repository navigation
fix(print): encode queue and task identifiers in URL paths - #453
Merged
Merged
Conversation
Signed-off-by: João Pedro Brun <joao.pedro.brun@sap.com>
Contributor
Author
Code ReviewReviewed against the 23-criterion Resolved since first review
Still open
Things done well
|
Signed-off-by: João Pedro Brun <joao.pedro.brun@sap.com>
tiagoek
approved these changes
Nov 10, 2026
10 of 17 tasks
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.
Description
Caller-supplied queue names and task IDs were inserted directly into URL paths, allowing reserved characters to change the request URL. Encode
qnameanditem_idin queue creation, profile retrieval and print-task creation withquote(..., safe=""). Reject literal.and..segments through the existingHttpError/PrintOperationErrorhandling while preserving identifier spelling and request-body references.Related Issue
N/A
Type of Change
How to Test
Run from the repository root after checking out this branch.
Run the Print unit suite:
Expected: 46 passed, including 13 regression cases covering all three URL call sites, dot-segment rejection and UUID spelling preservation.
Compare the old URL construction with the updated client. This example prepares requests with
Session.sendmocked; it sends no network requests:Expected:
Before,
..changes the path,param=xbecomes a query, andfragbecomes a URL fragment. Fragments are not sent in the HTTP request target. After, those characters remain encoded inside the queue identifier.Run the repository checks:
Expected: formatting, lint, whitespace and type checks pass. Unchanged YAML and lock-file hooks are skipped.
Checklist
/security-reviewand addressed all ❌ findingsBreaking Changes
No breaking changes for documented Print Service usage. Public client signatures, request bodies, and URLs for valid queue names and task UUIDs are unchanged. These callers need no migration.
This security fix changes how other identifier inputs behave:
/,?,#, and%are encoded as identifier data instead of being interpreted as URL structure..and..identifiers now raise the existingPrintOperationErrorbefore an HTTP request.These behavior changes affect inputs outside the service's documented identifier constraints; identical behavior for every previously accepted input is not claimed.
Additional Notes
Security Review
Reviewed against the 12-criterion
security-reviewcontract. Verdict: ✅ No security issues — nothing blocking and no open warnings; theHttpErrorchoice under S7 is a deliberate non-breaking design (see below), and S4 is a pre-existing, out-of-scope observation._encode_path_segmentusesquote(segment, safe="")so/ ? # %and other delimiters are encoded as identifier data, and literal./..are rejected before any request is built. Path traversal and URL-structure injection viaqname/item_idare both closed at all three call sites (create_queue,get_print_profiles,create_print_task)._encode_path_segmentsignals the./..rejection by raisingHttpError(client.py:35). This is deliberate and correct:HttpErrorandPrintOperationErrorare siblings underPrintError, and every caller's documented contract is “raisesPrintOperationError”. ReusingHttpErrorroutes the rejection through each existingexcept HttpErrorblock, which re-raisesPrintOperationErrorwith the original as__cause__(asserted by the tests). AValueError/new validation type would escape theexcept HttpErrorblocks increate_queueandcreate_print_task(raw, undocumented type — a breaking change to the public exception contract) and would be mislabeled as a parse error by the genericexcept Exceptioninget_print_profiles. TheHttpErrorname reads slightly oddly for a validation reject in isolation, but preserving the exception contract outweighs that local nit._resolve_username(client.py:39-56) base64-decodes the JWT payload without signature verification to readuser_name/client_id. This predates the PR and is out of its scope. It is low-risk in context — the value is only a best-effort display username with aclient_idfallback, not an authorization decision — but flagging it so it is on the record for a future hardening pass (verify viaIASVerifier, or document why the unverified decode is acceptable here).logger.errorcalls log the operation andqname, which are operational identifiers), and noverify=False.