Skip to content

Commit 0978229

Browse files
committed
Ruby: use new dataflow api in NetHttp.qll
1 parent fc7e753 commit 0978229

File tree

1 file changed

+7
-11
lines changed
  • ruby/ql/lib/codeql/ruby/frameworks/http_clients

1 file changed

+7
-11
lines changed

ruby/ql/lib/codeql/ruby/frameworks/http_clients/NetHttp.qll

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ private import codeql.ruby.dataflow.RemoteFlowSources
88
private import codeql.ruby.ApiGraphs
99
private import codeql.ruby.dataflow.internal.DataFlowPublic
1010
private import codeql.ruby.DataFlow
11-
private import codeql.ruby.dataflow.internal.DataFlowImplForHttpClientLibraries as DataFlowImplForHttpClientLibraries
1211

1312
/**
1413
* A `Net::HTTP` call which initiates an HTTP request.
@@ -88,26 +87,23 @@ class NetHttpRequest extends Http::Client::Request::Range, DataFlow::CallNode {
8887
override predicate disablesCertificateValidation(
8988
DataFlow::Node disablingNode, DataFlow::Node argumentOrigin
9089
) {
91-
any(NetHttpDisablesCertificateValidationConfiguration config)
92-
.hasFlow(argumentOrigin, disablingNode) and
90+
NetHttpDisablesCertificateValidationFlow::flow(argumentOrigin, disablingNode) and
9391
disablingNode = this.getCertificateValidationControllingValue()
9492
}
9593

9694
override string getFramework() { result = "Net::HTTP" }
9795
}
9896

9997
/** A configuration to track values that can disable certificate validation for NetHttp. */
100-
private class NetHttpDisablesCertificateValidationConfiguration extends DataFlowImplForHttpClientLibraries::Configuration
101-
{
102-
NetHttpDisablesCertificateValidationConfiguration() {
103-
this = "NetHttpDisablesCertificateValidationConfiguration"
104-
}
105-
106-
override predicate isSource(DataFlow::Node source) {
98+
private module NetHttpDisablesCertificateValidationConfig implements DataFlow::ConfigSig {
99+
predicate isSource(DataFlow::Node source) {
107100
source = API::getTopLevelMember("OpenSSL").getMember("SSL").getMember("VERIFY_NONE").asSource()
108101
}
109102

110-
override predicate isSink(DataFlow::Node sink) {
103+
predicate isSink(DataFlow::Node sink) {
111104
sink = any(NetHttpRequest req).getCertificateValidationControllingValue()
112105
}
113106
}
107+
108+
private module NetHttpDisablesCertificateValidationFlow =
109+
DataFlow::Global<NetHttpDisablesCertificateValidationConfig>;

0 commit comments

Comments
 (0)