Skip to content

repo_shape.py: COMMIT_RE and SHA256_RE end in $ and are used with .match, so a pin commit: or tree_sha256: that ends in a line break passes as well formed #1017

Closed

Description

@brettheap

Lane: openreposhape-1 (openRepoShape-1)

Found by lane 1's writer on #901 (PR #1015). It is not taken there, because it is outside #901's options.

COMMIT_RE and SHA256_RE in scripts/repo_shape.py (lines 68-69 on main) are ^[0-9a-fA-F]{40}$ and ^[0-9a-fA-F]{64}$, and they are used with .match. In Python, $ also matches just before a trailing newline. So a pin's commit: or tree_sha256: that ends in a line break passes as well formed.

Measured on main:

Pattern Value .match result
COMMIT_RE 40 hex digits True
COMMIT_RE 40 hex digits + "\n" True
SHA256_RE 64 hex digits True
SHA256_RE 64 hex digits + "\n" True

The writer's in-process probe of adopt-project.py's _pin_row_problem, with a commit: value that ends in a line break, returned None, that is no problem. Whether a YAML spelling reaches it (for example a block scalar) is not measured.

  • Fix: use \Z in place of $, or .fullmatch, in both patterns.
    • repo_shape.py is a pinned shape copy, so the change follows the copy rules in scripts/shape_materialize.py.
    • Grep for every other user of the two patterns, and for other ^...$ patterns used with .match on values read from YAML.
  • Test: a row per pattern with a trailing "\n", "\r\n" and " ", each refused.

Filed in v1.2.0 as #901's follow-up. Lane 3, the release owner, may place it otherwise.

Activity

  1. brettheap commented on Oct 21, 2026

    @brettheap
    ContributorAuthor

    CLAIMED — lane openRepoShape-5, session 50cede29-ab82-4ca3-9f67-d98e1a58c8d2@Eagle, 2026-10-21T10:50:45Z, for #1017

    Logged in lanes/log/openRepoShape-5.md at 27174a99a9f51535703e36cff5be405ffa01956f.

    The three reads (lane-collision-protocol Rule 1):

    1. existing `CLAIMED —` comments on opensoft/openRepoShape#1017:
       none
    2. `gh pr list --repo opensoft/openRepoShape --state all --search "#1017"`, kept where the row or its body names `#1017`:
       none
    3. `git ls-remote --heads [email protected]:opensoft/openRepoShape` branches naming `1017` as a whole token:
       none
    
  2. added this to the v1.2.1 milestone on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions