Skip to content

gemspec readers treat =begin blocks and heredocs as code: route gemspec_directives and dev_dependency_requirements through manifest::for_each_code_line #1932

Closed

Description

[agent] Filed by the scheduled architecture audit (audit-core). Register: register.

Kind: bug (bypassed shared helper). Register ID: A54.

Problem

formats/gem/manifest.rs has a code-line iterator that skips =begin/=end blocks and heredoc bodies: for_each_code_line L472. vex/product.rs already uses it to read gemspecs. The two gemspec readers in formats/gem/gemspec.rs scan raw lines instead:

Executed on verbatim copies of the main functions, compiled with rustc:

  • gemspec_directives("=begin\ngemspec\n=end\n…") → Ok([directive at line 1]). The commented-out directive counts.
  • dev_dependency_requirements("=begin\n s.add_development_dependency \"vuln-gem\", \"~> 2\"\n=end\n", "vuln-gem") → Ok(Some(["~> 2"])).
  • A heredoc body containing gemspec path: ROOT → Err, which refuses the whole Gemfile.

Effect: locked_exact_requirement would pin ~> 2, = 1.0.0 where Bundler locks = 1.0.0, and a frozen install then fails (the #985 shape). The heredoc case fails closed but refuses a valid project.

Proposed change

Drive both loops with manifest::for_each_code_line, keeping their 1-based line numbers. While there, remove the redundant trim_end_matches('\r').

Size

1 file, about ±30 lines, plus 3 unit tests.

Acceptance criteria

  • New tests: a directive and a dev dependency inside =begin/=end are ignored, and a heredoc body is not read.
  • Existing gemspec tests pass.

Activity

  1. added
    bugSomething isn't working
    arch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)
    on Nov 1, 2026
  2. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this for the architecture refactor routine (A54: the two gemspec readers bypass the shared Ruby code-line iterator; files are free of open PRs). Branch: arch-refactor/1932-gemspec-code-lines. Claim-ID: 2026-11-01T12:56:03Z-c88d11


    Generated by Claude Code

  3. added a commit that references this issue on Nov 1, 2026
    a68531b
  4. mikolalysenko commented on Nov 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triage: priority:p1 (Bundler). Handled by the open PR #1936.


    Generated by Claude Code

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

    agent:triagedarch-auditFiled by a scheduled architecture audit routine (see the architecture review discussion)bugSomething isn't workingpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions