Skip to content

fix(pptx-maker): refuse a deck id, name or path segment that ends in a newline - #34465

Merged
javenciu merged 1 commit into
mainfrom
fix/pptx-maker-anchor-validators
Nov 10, 2026
Merged

javenciu merged 1 commit into
mainfrom
fix/pptx-maker-anchor-validators

Conversation

@javenciu

@javenciu javenciu commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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.py says SEGMENT_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 main resolve_deck_dir("deck-1\n") answers the directory deck-1\n, and resolve_library_file(lib, "slide\n", ".html") answers the file slide\n.html, when either exists. decks.py's _EPOCH_RE and _SLUG_EPOCH_RE, which read the deck files it lists, have the same shape.

test/test_regex_anchor_contract.py holds 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

  • No other package's patterns.
  • No change to what a valid id, name or segment is.

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_RE ends at \Z, with the reason in its comment.
  • src/kiro_crew/apps/builtins/pptx_maker/backend/decks.py: _EPOCH_RE and _SLUG_EPOCH_RE end at \Z.
  • test/test_regex_anchor_contract.py: pptx_maker.backend joins _REQUEST_PATH_PACKAGES (registered at the same level as papyrus's backend), and SEGMENT_RE joins _VALIDATORS with a valid input.
  • test/test_pptx_maker_paths.py: test_rejects_a_trailing_newline checks SEGMENT_RE and split_segments. test_a_trailing_newline_never_reaches_a_deck_directory creates 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_file creates no file, because a library target need not exist.
  • The app repository gets the same change, since adopted hosts run it rather than this wheel copy:

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

  • Before: on main the three new pptx-maker tests fail (the pattern matches brief.md\n; the resolvers answer the newline-named directory and file), and so do the contract's accept-and-reject case for SEGMENT_RE and its structural walk over the package.
  • After: every test/test_pptx_maker_*.py, the package's own tests/ and test/test_regex_anchor_contract.py: 617 passed, 1 skipped, three runs in a row at -n0.
  • The whole backend suite on a local merge with current main fails only the tests this environment fails on main itself (optional dependencies it lacks).
  • In the app repository, the same three tests fail without the change; with it, flake8 backend tests is clean and pytest gives 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.
  • Reproduce: python -m pytest test/test_pptx_maker_paths.py test/test_regex_anchor_contract.py -n0
  • Proof: PROVEN test/test_pptx_maker_paths.py::TestSegmentGrammar::test_rejects_a_trailing_newline, test/test_pptx_maker_paths.py::TestResolveDeckDir::test_a_trailing_newline_never_reaches_a_deck_directory, test/test_pptx_maker_paths.py::TestResolveLibraryFile::test_a_trailing_newline_never_reaches_a_library_file, test/test_regex_anchor_contract.py::TestTrailingNewlineContract::test_valid_input_plus_newline_is_rejected[pptx-maker-path-segment], test/test_regex_anchor_contract.py::TestTrailingNewlineContract::test_no_request_path_pattern_is_dollar_anchored (head fb4578f)

Manual 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_maker with an unescaped $ and no re.MULTILINE; git grep -nF '$")' -- src/kiro_crew/apps/builtins/pptx_maker lists none after this change.
Sibling: src/kiro_crew/apps/builtins/pptx_maker/backend/paths.py -- changed here
Sibling: src/kiro_crew/apps/builtins/pptx_maker/backend/decks.py -- changed here

Pattern harvest

Rule candidate: none new. test/test_regex_anchor_contract.py already 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

@javenciu
javenciu requested review from a team and KiroCrewCaptain as code owners November 10, 2026 08:43
@javenciu
javenciu enabled auto-merge (squash) November 10, 2026 08:43
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision fb4578fbb5b172b0dc0d63807d2009b312c6a62d touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of fb4578fbb5b172b0dc0d63807d2009b312c6a62d — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The patch anchors the path guard at \Z, the repo's usual fix for this class, registers the package in the existing anchor contract, and names the app-repo twin.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of fb4578fbb5b172b0dc0d63807d2009b312c6a62d — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Each item fixes, or is required by, the $-matches-before-newline defect that the PR's own failing-on-base tests reproduce.

What this change ships

Inventory (5 items) — 5 justified

Intent: 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.

  1. A deck id, library file name or relative-path segment ending in \n is now refused (SEGMENT_RE ends at \Z). — justified
  2. Deck-directory filenames ending in \n no longer parse as deck files (_EPOCH_RE and _SLUG_EPOCH_RE end at \Z); once the package is registered, the contract's structural walk requires this. — justified
  3. pptx_maker.backend joins the packages the regex-anchor contract walks, so a $-anchored pattern added there later fails CI. — justified
  4. SEGMENT_RE joins the contract's accept/reject validators. — justified
  5. Three new tests cover the segment grammar, the deck-directory resolver and the library-file resolver. — justified

[FIRST-PRINCIPLES-REVIEWED] fb4578f

Description read

[DESCRIPTION-READ] b0807d0f2cb078937426b75ee1378953cde7be6e84635a1dcd86ff656b5bdde2

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed fb4578fbb5b172b0dc0d63807d2009b312c6a62d — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] fb4578f

Verdict parsed from the review's SHA-scoped output markers for commit fb4578fbb5b172b0dc0d63807d2009b312c6a62d.

False positive or not applicable? A repository writer can comment:
/ai-review override fable fb4578fbb5b172b0dc0d63807d2009b312c6a62d false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of fb4578fbb5b172b0dc0d63807d2009b312c6a62d and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] fb4578f

False positive or not applicable? A repository writer can comment:
/ai-review override gpt fb4578fbb5b172b0dc0d63807d2009b312c6a62d false-positive: <reason, 20 to 500 characters>

@javenciu

Copy link
Copy Markdown
Contributor Author

span=c0c03021e8fd

fixed fb4578f: test_a_trailing_newline_never_reaches_a_deck_directory creates its newline-named directory inside try/except OSError and skips where the file system refuses the name, as test_symlink_escaping_the_deck_is_refused in the same file already does. test_a_trailing_newline_never_reaches_a_library_file creates no file: a library target need not exist (test_target_need_not_exist), so the name alone decides.
Both tests still fail on the merge-base and pass with the change (prove.py lists them as PROVEN at fb4578f); the pptx-maker and contract tests give 617 passed, 1 skipped, three runs in a row.

@javenciu

Copy link
Copy Markdown
Contributor Author

span=633d73090175

fixed fb4578f: test_a_trailing_newline_never_reaches_a_deck_directory creates its newline-named directory inside try/except OSError and skips where the file system refuses the name, as test_symlink_escaping_the_deck_is_refused in the same file already does. test_a_trailing_newline_never_reaches_a_library_file creates no file: a library target need not exist (test_target_need_not_exist), so the name alone decides.
Both tests still fail on the merge-base and pass with the change (prove.py lists them as PROVEN at fb4578f); the pptx-maker and contract tests give 617 passed, 1 skipped, three runs in a row.

@javenciu

Copy link
Copy Markdown
Contributor Author

span=0d7e9d018744

fixed fb4578f: the same three \Z anchors (SEGMENT_RE in backend/paths.py, _EPOCH_RE and _SLUG_EPOCH_RE in backend/decks.py) are in KiroCrewCaptain/kirocrew-app-pptx-maker#7, with the same three tests in its tests/test_paths.py, and the description names it on an App repo: line.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 10, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $.

@javenciu
javenciu merged commit 3071ec8 into main Nov 10, 2026
101 of 106 checks passed
@javenciu
javenciu deleted the fix/pptx-maker-anchor-validators branch November 10, 2026 10:38
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 10, 2026
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