Conversation
Adds request.body.read/.string, .params, .GET, .POST, .cookies, .env, .query_string, and .path_info as Http::Server::RequestInputAccess sources within Grape::API endpoints, plus matching Grape.ql test predicates and app.rb coverage. Also adds ConnectedToInjection.rb, exercising ActiveRecord connected_to role-switch blocks with captured variables as an SQL injection regression fixture. .expected files intentionally not yet updated pending a CodeQL CLI upgrade/test pass.
…089 tests Adds # $ Source / # $ Alert annotations to ConnectedToInjection.rb matching the sibling fixtures' convention. Regenerated Grape.expected/Flow.expected and SqlInjection.expected from verified actual output (codeql test run, CLI 2.27.0). All 3 tests pass: Flow.ql, Grape.ql, SqlInjection.qlref.
grapeRequestGET/grapeRequestPOST -> grapeRequestGet/grapeRequestPost, per CodeQL code-scanning naming-convention review comments on the PR.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Three moderate source-modeling issues remain in Grape.qll.
Get a fresh assessment by requesting another Copilot review.
Review tier: Lite (auto)
Findings: 2
Note
Copilot is running an experiment and ran this review at Lite.
Open (2)
What changed in this PR
Extends Ruby Grape request modeling with remote-flow sources and adds regression coverage.
Changes:
- Models nine request sub-accessors as sources.
- Expands Grape and SQL-injection tests.
- Adds generated expectations and a feature change note.
| File | Description |
|---|---|
ruby/ql/test/query-tests/security/cwe-089/SqlInjection.expected |
Updates SQL-injection expectations. |
ruby/ql/test/query-tests/security/cwe-089/ConnectedToInjection.rb |
Adds connected_to SQL-injection regression cases. |
ruby/ql/test/library-tests/frameworks/grape/Grape.ql |
Queries the new source types. |
ruby/ql/test/library-tests/frameworks/grape/Grape.expected |
Records Grape test results. |
ruby/ql/test/library-tests/frameworks/grape/Flow.expected |
Records flow-test results. |
ruby/ql/test/library-tests/frameworks/grape/app.rb |
Adds request accessor flow cases. |
ruby/ql/lib/codeql/ruby/frameworks/Grape.qll |
Adds Grape request sub-accessor source models. |
ruby/ql/lib/change-notes/2026-09-15-grape-request-sources.md |
Documents the feature. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+226
to
+228
| override Http::Server::RequestInputKind getKind() { | ||
| result = Http::Server::parameterInputKind() | ||
| } |
Contributor
There was a problem hiding this comment.
Sounds like Copilot is right here. I would also expect bodyInputKind on line 291 and cookieInputKind on line 305.
| override string getSourceType() { result = "Grape::Request#path_info" } | ||
|
|
||
| override Http::Server::RequestInputKind getKind() { | ||
| result = Http::Server::parameterInputKind() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Follow-up to #20427 (Grape framework support). Models the
requestobject's common sub-accessors within aGrape::APIendpoint as remote flow sources, so taint tracking recognizes them the same way it already recognizesparams,headers,cookies, and barerequest.Grape's
requestis aRack::Request-like object; the following accessors are now modeled as sources:request.body.read/request.body.stringrequest.paramsrequest.GET/request.POSTrequest.cookiesrequest.envrequest.query_stringrequest.path_infoTesting
ruby/ql/test/library-tests/frameworks/grape: extendedapp.rbwith aRequestAccessorsAPIclass covering all 9 accessors, with matchingGrape.qlquery predicates and inline# $ hasTaintFlowexpectations inFlow.ql.ruby/ql/test/query-tests/security/cwe-089: addedConnectedToInjection.rb, a regression fixture forActiveRecord'sconnected_torole-switch block pattern (block-captured remote input interpolated into raw SQL, including a deferred/post-block variant), with inline# $ Source/# $ Alertannotations matching the sibling fixtures' convention.All three tests pass (
Flow.ql,Grape.ql,SqlInjection.qlref).Change note
Added
ruby/ql/lib/change-notes/2026-09-15-grape-request-sources.md(categoryfeature).