Repository navigation
fix(pptx-maker): refuse a deck id, name or path segment that ends in a newline - #34465
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The patch anchors the path guard at Notes
[DESIGN-REVIEWED] fb4578f Description read[DESCRIPTION-READ] e5e859321b87b430221c32c4f9eea29c6a943391f39b1c383e8953050aea0727 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Each item fixes, or is required by, the What this change shipsInventory (5 items) — 5 justifiedIntent: stop a pptx-maker deck id, library name or path segment with a trailing newline from reaching a directory or file. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] fb4578f Description read[DESCRIPTION-READ] b0807d0f2cb078937426b75ee1378953cde7be6e84635a1dcd86ff656b5bdde2 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
a7fb451 to
fb4578f
Compare
|
span=c0c03021e8fd
|
|
span=633d73090175
|
|
span=0d7e9d018744
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. On fb4578f the review checked three things. First, SEGMENT_RE in paths.py is the one per-segment guard behind resolve_deck_dir, split_segments, resolve_library_file and the library.py caller, and every caller uses .match, so the \Z anchor covers all of them. Second, reverting SEGMENT_RE to $ makes exactly the 5 tests named on the Proof line fail, and reverting either decks.py pattern makes the structural contract test fail. Third, the new tests write only under temp dirs and have no clock, sleep or port.
Done well: registering pptx_maker.backend in the regex-anchor contract fixes the whole class for this package, so a later $-anchored pattern there fails CI on its own.
Optional: add pptx_maker modules to test_walk_sees_the_known_validators, so the decks.py anchors cannot lose their only pin without a test noticing.
Optional: the decks.py edit changes no runtime behavior, because the .json suffix check runs before both regexes. One sentence in the body could say it is there for the contract walk. A Reader: line per resolver under Backwards compatibility would also help.
Optional: when open PR #15394 rebases on top of this, its new _PAGE_RE should use \Z in place of $.
Problem / Motivation
Goal: a pptx-maker deck id, name or path segment that ends in a newline is refused, like every other value its path guard refuses.
pptx_maker/backend/paths.pysaysSEGMENT_RE"is the primary path guard". It checks a deck id (resolve_deck_dir), a library file name (resolve_library_file) and every part of a relative path (split_segments), all of which arrive from the client. It is$-anchored and used with.match, and Python's$also matches just before a trailing"\n", so each check accepts a valid value plus one newline: on mainresolve_deck_dir("deck-1\n")answers the directorydeck-1\n, andresolve_library_file(lib, "slide\n", ".html")answers the fileslide\n.html, when either exists.decks.py's_EPOCH_REand_SLUG_EPOCH_RE, which read the deck files it lists, have the same shape.test/test_regex_anchor_contract.pyholds a package's request-path validators to\Z, package by package (#12161 began it; #34336 registered Mochi). pptx-maker is not registered there yet.Why it matters
The path guard's own comment promises that nothing but the allow-listed characters survives it, and a newline in a path segment is a name the deck and library readers then open.
Not a goal
What changed (motivation → approach → change)
Approach: the repo's existing fix for this class. Anchor at
\Z, which matches only at the true end of the string, and register the package so the contract keeps it that way.src/kiro_crew/apps/builtins/pptx_maker/backend/paths.py:SEGMENT_REends at\Z, with the reason in its comment.src/kiro_crew/apps/builtins/pptx_maker/backend/decks.py:_EPOCH_REand_SLUG_EPOCH_REend at\Z.test/test_regex_anchor_contract.py:pptx_maker.backendjoins_REQUEST_PATH_PACKAGES(registered at the same level as papyrus'sbackend), andSEGMENT_REjoins_VALIDATORSwith a valid input.test/test_pptx_maker_paths.py:test_rejects_a_trailing_newlinechecksSEGMENT_REandsplit_segments.test_a_trailing_newline_never_reaches_a_deck_directorycreates the newline-named directory and checks the resolver refuses it; it skips where the file system refuses such a name (Windows), as the symlink test in the same file does.test_a_trailing_newline_never_reaches_a_library_filecreates no file, because a library target need not exist.App repo: KiroCrewCaptain/kirocrew-app-pptx-maker#7
Backwards compatibility
Compatible for every valid value: the three patterns accept exactly what they did, minus a value with one trailing newline.
Tests
brief.md\n; the resolvers answer the newline-named directory and file), and so do the contract's accept-and-reject case forSEGMENT_REand its structural walk over the package.test/test_pptx_maker_*.py, the package's owntests/andtest/test_regex_anchor_contract.py: 617 passed, 1 skipped, three runs in a row at-n0.flake8 backend testsis clean andpytestgives 654 passed, 2 skipped, three runs in a row.flake8,isort, the black gate, the comment-history gate, CI's semgrep rules and source gates, and the flake-pattern and wait-discipline ratchets pass locally.python -m pytest test/test_pptx_maker_paths.py test/test_regex_anchor_contract.py -n0Manual verification
N/A: the tests call the path helpers the routes call, on real temporary directories.
Sibling sweep
Swept: every module-level compiled pattern under
src/kiro_crew/apps/builtins/pptx_makerwith an unescaped$and nore.MULTILINE;git grep -nF '$")' -- src/kiro_crew/apps/builtins/pptx_makerlists none after this change.Sibling:
src/kiro_crew/apps/builtins/pptx_maker/backend/paths.py-- changed hereSibling:
src/kiro_crew/apps/builtins/pptx_maker/backend/decks.py-- changed herePattern harvest
Rule candidate: none new.
test/test_regex_anchor_contract.pyalready states the rule; this registers one more package under it.Screenshots / video
Why no screenshot: no markup change; a refused value is answered the way other unsafe names are.
Related Issues
None open for pptx-maker. Same class as #34199, #34238 and #34336; the contract began in #12161.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement