• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 30490183440 / 3
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: fix/adversarial-sweep-2026-08
DEFAULT BRANCH: master
Ran 29 Jul 2026 08:55PM UTC
Files 166
Run time 8s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

29 Jul 2026 08:53PM UTC coverage: 47.801% (-0.06%) from 47.856%
30490183440.3

Pull #2838

github

ericproulx
Reject params nested deeper than the array scope declares

`AttributesIterator#do_each` recursed into any element that was an Array.
That recursion is required when the declaration itself nests array scopes —
`map_params` adds one level of nesting per Array-typed scope on the chain, so
the params for the inner scope really are an array of arrays — but nothing
compared the incoming depth against the declared one.

A request could therefore wrap its elements in extra arrays and have them
silently unwrapped:

    params do
      requires :lines, type: Array do
        requires :book_id, type: String
        requires :qty, type: Integer
      end
    end

`{"lines":[[{"book_id":"x","qty":1}]]}` passed validation, and `params[:lines]`
/ `declared` then handed the endpoint `[[{...}]]`. Any ordinary body assuming
the declared shape (`params[:lines].sum { |l| l[:qty] }`) died with a
`TypeError`, i.e. a 500 on malformed input. `[[]]` passed the same way.

Each scope now records, at definition time, how many Array-typed scopes sit on
its chain; the iterator descends that many levels less the one `Array.wrap`
already consumes, and yields anything deeper as-is. The attribute validators
then see a non-hash and fail it exactly as they do for any other unexpected
element type, so these requests get the 400 they always should have.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Pull Request #2838: Reject params nested deeper than the array scope declares

171 of 1287 branches covered (13.29%)

Branch coverage included in aggregate %.

2296 of 3874 relevant lines covered (59.27%)

0.98 hits per line

Source Files on job run-4.0-gemfiles/multi_json_1_20.gemfile - 30490183440.3
  • Tree
  • List 166
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 30490183440
  • b03b7a74 on github
  • Prev Job for on fix/nested-array-validation-bypass (#30486032579.30)
  • Next Job for on fix/nested-array-validation-bypass (#30697264547.13)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc