Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor Grape framework code for improved readability and consistency
  • Loading branch information
felickz committed Sep 12, 2025
commit 738ab6fba7ff64b97c60cf7f2593f136c5bf0f04
2 changes: 1 addition & 1 deletion ruby/ql/lib/codeql/ruby/frameworks/Grape.qll
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class GrapeEndpoint extends DataFlow::CallNode {
* Grape parameters available via the `params` method within an endpoint.
*/
class GrapeParamsSource extends Http::Server::RequestInputAccess::Range {
GrapeParamsSource() {
GrapeParamsSource() {
this.asExpr().getExpr() instanceof GrapeParamsCall
}

Expand Down
2 changes: 1 addition & 1 deletion ruby/ql/test/library-tests/frameworks/grape/Grape.ql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import codeql.ruby.AST

query predicate grapeAPIClasses(GrapeAPIClass api) { any() }

query predicate grapeEndpoints(GrapeAPIClass api, GrapeEndpoint endpoint, string method, string path) {
query predicate grapeEndpoints(GrapeAPIClass api, GrapeEndpoint endpoint, string method, string path) {
endpoint = api.getAnEndpoint() and
method = endpoint.getHttpMethod() and
path = endpoint.getPath()
Expand Down
16 changes: 8 additions & 8 deletions ruby/ql/test/library-tests/frameworks/grape/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MyAPI < Grape::API
user_agent = headers['User-Agent']
"Hello #{name}!"
end

desc 'Post endpoint with params'
params do
requires :message, type: String
Expand All @@ -18,36 +18,36 @@ class MyAPI < Grape::API
msg = params[:message]
{ status: 'received', message: msg }
end

desc 'Put endpoint accessing request'
put '/update/:id' do
id = params[:id]
body = request.body.read
{ id: id, body: body }
end
desc 'Delete endpoint'

desc 'Delete endpoint'
delete '/items/:id' do
params[:id]
end

desc 'Patch endpoint'
patch '/items/:id' do
params[:id]
end

desc 'Head endpoint'
head '/status' do
# Just return status
end

desc 'Options endpoint'
options '/info' do
headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
end
end

class AdminAPI < Grape::API
class AdminAPI < Grape::API
get '/admin' do
params[:token]
end
Expand Down