Skip to content

Commit 2bdea01

Browse files
committed
Add HTTP::Client concept
1 parent 21e31a4 commit 2bdea01

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

ql/lib/codeql/ruby/Concepts.qll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,49 @@ module HTTP {
404404
}
405405
}
406406
}
407+
408+
/** Provides classes for modeling HTTP clients. */
409+
module Client {
410+
/**
411+
* A method call that makes an outgoing HTTP request.
412+
*
413+
* Extend this class to refine existing API models. If you want to model new APIs,
414+
* extend `Request::Range` instead.
415+
*/
416+
class Request extends MethodCall instanceof Request::Range {
417+
/** Gets a node which returns the body of the response */
418+
DataFlow::Node getResponseBody() { result = super.getResponseBody() }
419+
420+
/** Gets a string that identifies the framework used for this request. */
421+
string getFramework() { result = super.getFramework() }
422+
}
423+
424+
/** Provides a class for modeling new HTTP requests. */
425+
module Request {
426+
/**
427+
* A method call that makes an outgoing HTTP request.
428+
*
429+
* Extend this class to model new APIs. If you want to refine existing API models,
430+
* extend `Request` instead.
431+
*/
432+
abstract class Range extends MethodCall {
433+
/** Gets a node which returns the body of the response */
434+
abstract DataFlow::Node getResponseBody();
435+
436+
/** Gets a string that identifies the framework used for this request. */
437+
abstract string getFramework();
438+
}
439+
}
440+
441+
/** The response body from an outgoing HTTP request, considered as a remote flow source */
442+
private class RequestResponseBody extends RemoteFlowSource::Range, DataFlow::Node {
443+
Request request;
444+
445+
RequestResponseBody() { this = request.getResponseBody() }
446+
447+
override string getSourceType() { result = request.getFramework() }
448+
}
449+
}
407450
}
408451

409452
/**

0 commit comments

Comments
 (0)