@@ -52,9 +52,7 @@ class GrapeApiClass extends DataFlow::ClassNode {
5252 /**
5353 * Gets a `GrapeEndpoint` defined in this class.
5454 */
55- GrapeEndpoint getAnEndpoint ( ) {
56- result .getApiClass ( ) = this
57- }
55+ GrapeEndpoint getAnEndpoint ( ) { result .getApiClass ( ) = this }
5856
5957 /**
6058 * Gets a `self` that possibly refers to an instance of this class.
@@ -72,9 +70,7 @@ private DataFlow::ConstRef grapeApiBaseClass() {
7270 result = DataFlow:: getConstant ( "Grape" ) .getConstant ( "API" )
7371}
7472
75- private API:: Node grapeApiInstance ( ) {
76- result = any ( GrapeApiClass cls ) .getSelf ( ) .track ( )
77- }
73+ private API:: Node grapeApiInstance ( ) { result = any ( GrapeApiClass cls ) .getSelf ( ) .track ( ) }
7874
7975/**
8076 * A Grape API endpoint (get, post, put, delete, etc.) call within a `Grape::API` class.
@@ -83,15 +79,14 @@ class GrapeEndpoint extends DataFlow::CallNode {
8379 private GrapeApiClass apiClass ;
8480
8581 GrapeEndpoint ( ) {
86- this = apiClass .getAModuleLevelCall ( [ "get" , "post" , "put" , "delete" , "patch" , "head" , "options" ] )
82+ this =
83+ apiClass .getAModuleLevelCall ( [ "get" , "post" , "put" , "delete" , "patch" , "head" , "options" ] )
8784 }
8885
8986 /**
9087 * Gets the HTTP method for this endpoint (e.g., "GET", "POST", etc.)
9188 */
92- string getHttpMethod ( ) {
93- result = this .getMethodName ( ) .toUpperCase ( )
94- }
89+ string getHttpMethod ( ) { result = this .getMethodName ( ) .toUpperCase ( ) }
9590
9691 /**
9792 * Gets the API class containing this endpoint.
@@ -106,19 +101,15 @@ class GrapeEndpoint extends DataFlow::CallNode {
106101 /**
107102 * Gets the path pattern for this endpoint, if specified.
108103 */
109- string getPath ( ) {
110- result = this .getArgument ( 0 ) .getConstantValue ( ) .getString ( )
111- }
104+ string getPath ( ) { result = this .getArgument ( 0 ) .getConstantValue ( ) .getString ( ) }
112105}
113106
114107/**
115108 * A `RemoteFlowSource::Range` to represent accessing the
116109 * Grape parameters available via the `params` method within an endpoint.
117110 */
118111class GrapeParamsSource extends Http:: Server:: RequestInputAccess:: Range {
119- GrapeParamsSource ( ) {
120- this .asExpr ( ) .getExpr ( ) instanceof GrapeParamsCall
121- }
112+ GrapeParamsSource ( ) { this .asExpr ( ) .getExpr ( ) instanceof GrapeParamsCall }
122113
123114 override string getSourceType ( ) { result = "Grape::API#params" }
124115
@@ -174,9 +165,7 @@ private class GrapeHeadersCall extends MethodCall {
174165 * The request object can contain user input.
175166 */
176167class GrapeRequestSource extends Http:: Server:: RequestInputAccess:: Range {
177- GrapeRequestSource ( ) {
178- this .asExpr ( ) .getExpr ( ) instanceof GrapeRequestCall
179- }
168+ GrapeRequestSource ( ) { this .asExpr ( ) .getExpr ( ) instanceof GrapeRequestCall }
180169
181170 override string getSourceType ( ) { result = "Grape::API#request" }
182171
@@ -188,9 +177,7 @@ class GrapeRequestSource extends Http::Server::RequestInputAccess::Range {
188177 * Route parameters are extracted from the URL path and can be a source of user input.
189178 */
190179class GrapeRouteParamSource extends Http:: Server:: RequestInputAccess:: Range {
191- GrapeRouteParamSource ( ) {
192- this .asExpr ( ) .getExpr ( ) instanceof GrapeRouteParamCall
193- }
180+ GrapeRouteParamSource ( ) { this .asExpr ( ) .getExpr ( ) instanceof GrapeRouteParamCall }
194181
195182 override string getSourceType ( ) { result = "Grape::API#route_param" }
196183
@@ -316,12 +303,10 @@ private class GrapeHelperMethodTaintStep extends AdditionalTaintStep {
316303 exists ( GrapeHelperMethod helperMethod , MethodCall call , int i |
317304 // Find calls to helper methods from within Grape endpoints
318305 call .getMethodName ( ) = helperMethod .getName ( ) and
319- exists ( GrapeEndpoint endpoint |
320- call .getParent + ( ) = endpoint .getBody ( ) .asExpr ( ) .getExpr ( )
321- ) and
306+ exists ( GrapeEndpoint endpoint | call .getParent + ( ) = endpoint .getBody ( ) .asExpr ( ) .getExpr ( ) ) and
322307 // Map argument to parameter
323308 nodeFrom .asExpr ( ) .getExpr ( ) = call .getArgument ( i ) and
324309 nodeTo .asParameter ( ) = helperMethod .getParameter ( i )
325310 )
326311 }
327- }
312+ }
0 commit comments