Skip to content

Commit

Permalink
Ruby: use new dataflow api in Typhoeus.qll
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrford committed Sep 21, 2023
1 parent 699f752 commit a64d372
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions ruby/ql/lib/codeql/ruby/frameworks/http_clients/Typhoeus.qll
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ private import codeql.ruby.CFG
private import codeql.ruby.Concepts
private import codeql.ruby.ApiGraphs
private import codeql.ruby.DataFlow
private import codeql.ruby.dataflow.internal.DataFlowImplForHttpClientLibraries as DataFlowImplForHttpClientLibraries

/**
* A call that makes an HTTP request using `Typhoeus`.
Expand Down Expand Up @@ -38,26 +37,21 @@ class TyphoeusHttpRequest extends Http::Client::Request::Range, DataFlow::CallNo
override predicate disablesCertificateValidation(
DataFlow::Node disablingNode, DataFlow::Node argumentOrigin
) {
any(TyphoeusDisablesCertificateValidationConfiguration config)
.hasFlow(argumentOrigin, disablingNode) and
TyphoeusDisablesCertificateValidationFlow::flow(argumentOrigin, disablingNode) and
disablingNode = this.getCertificateValidationControllingValue()
}

override string getFramework() { result = "Typhoeus" }
}

/** A configuration to track values that can disable certificate validation for Typhoeus. */
private class TyphoeusDisablesCertificateValidationConfiguration extends DataFlowImplForHttpClientLibraries::Configuration
{
TyphoeusDisablesCertificateValidationConfiguration() {
this = "TyphoeusDisablesCertificateValidationConfiguration"
}

override predicate isSource(DataFlow::Node source) {
source.asExpr().getExpr().(BooleanLiteral).isFalse()
}
private module TyphoeusDisablesCertificateValidationConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source.asExpr().getExpr().(BooleanLiteral).isFalse() }

override predicate isSink(DataFlow::Node sink) {
predicate isSink(DataFlow::Node sink) {
sink = any(TyphoeusHttpRequest req).getCertificateValidationControllingValue()
}
}

private module TyphoeusDisablesCertificateValidationFlow =
DataFlow::Global<TyphoeusDisablesCertificateValidationConfig>;

0 comments on commit a64d372

Please sign in to comment.