Skip to content

Commit 75cbcab

Browse files
authored
Merge pull request #22282 from aschackmull/ruby/vendored-lib-exclude
Ruby: Exclude vendored library parameters from taint sources.
2 parents 2bc1b22 + 1430dfe commit 75cbcab

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Removed library input to vendored gems from the set of taint sources. This should reduce false positives for `rb/polynomial-redos`, `rb/regex/badly-anchored-regexp`, `rb/unsafe-code-construction`, `rb/html-constructed-from-input`, and `rb/shell-command-constructed-from-input` whenever vendoring is used.

ruby/ql/lib/codeql/ruby/frameworks/core/Gem.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ module Gem {
9090
result = this.getAPublicModule().getStmt(_).(SingletonClass)
9191
}
9292

93+
/** Holds if this gem is vendored in this codebase. */
94+
predicate isVendored() { File.super.getParentContainer+().getBaseName() = "vendor" }
95+
9396
/** Gets a parameter from an exported method, which is an input to this gem. */
9497
DataFlow::ParameterNode getAnInputParameter() {
9598
exists(MethodBase method |
@@ -107,6 +110,7 @@ module Gem {
107110
DataFlow::ParameterNode getALibraryInput() {
108111
exists(GemSpec spec |
109112
exists(spec.getName()) and // we only consider `.gemspec` files that have a name
113+
not spec.isVendored() and // if the gem is vendored its parameters are not external inputs
110114
result = spec.getAnInputParameter()
111115
)
112116
}

0 commit comments

Comments
 (0)