Skip to content

Commit 738ab6f

Browse files
committed
Refactor Grape framework code for improved readability and consistency
1 parent d295acc commit 738ab6f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

ruby/ql/lib/codeql/ruby/frameworks/Grape.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class GrapeEndpoint extends DataFlow::CallNode {
115115
* Grape parameters available via the `params` method within an endpoint.
116116
*/
117117
class GrapeParamsSource extends Http::Server::RequestInputAccess::Range {
118-
GrapeParamsSource() {
118+
GrapeParamsSource() {
119119
this.asExpr().getExpr() instanceof GrapeParamsCall
120120
}
121121

ruby/ql/test/library-tests/frameworks/grape/Grape.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import codeql.ruby.AST
55

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

8-
query predicate grapeEndpoints(GrapeAPIClass api, GrapeEndpoint endpoint, string method, string path) {
8+
query predicate grapeEndpoints(GrapeAPIClass api, GrapeEndpoint endpoint, string method, string path) {
99
endpoint = api.getAnEndpoint() and
1010
method = endpoint.getHttpMethod() and
1111
path = endpoint.getPath()

ruby/ql/test/library-tests/frameworks/grape/app.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class MyAPI < Grape::API
99
user_agent = headers['User-Agent']
1010
"Hello #{name}!"
1111
end
12-
12+
1313
desc 'Post endpoint with params'
1414
params do
1515
requires :message, type: String
@@ -18,36 +18,36 @@ class MyAPI < Grape::API
1818
msg = params[:message]
1919
{ status: 'received', message: msg }
2020
end
21-
21+
2222
desc 'Put endpoint accessing request'
2323
put '/update/:id' do
2424
id = params[:id]
2525
body = request.body.read
2626
{ id: id, body: body }
2727
end
28-
29-
desc 'Delete endpoint'
28+
29+
desc 'Delete endpoint'
3030
delete '/items/:id' do
3131
params[:id]
3232
end
33-
33+
3434
desc 'Patch endpoint'
3535
patch '/items/:id' do
3636
params[:id]
3737
end
38-
38+
3939
desc 'Head endpoint'
4040
head '/status' do
4141
# Just return status
4242
end
43-
43+
4444
desc 'Options endpoint'
4545
options '/info' do
4646
headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
4747
end
4848
end
4949

50-
class AdminAPI < Grape::API
50+
class AdminAPI < Grape::API
5151
get '/admin' do
5252
params[:token]
5353
end

0 commit comments

Comments
 (0)