Skip to content

Commit 2033dd2

Browse files
committed
remove parameters named "code" as source
1 parent e7c6571 commit 2033dd2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

ruby/ql/lib/codeql/ruby/security/UnsafeCodeConstructionCustomizations.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ module UnsafeCodeConstruction {
1919

2020
/** An input parameter to a gem seen as a source. */
2121
private class LibraryInputAsSource extends Source instanceof DataFlow::ParameterNode {
22-
LibraryInputAsSource() { this = Gem::getALibraryInput() }
22+
LibraryInputAsSource() {
23+
this = Gem::getALibraryInput() and
24+
not this.getName() = "code"
25+
}
2326
}
2427

2528
/** A sink for code constructed from library input vulnerabilities. */

ruby/ql/test/query-tests/security/cwe-094/UnsafeCodeConstruction/impl/unsafeCode.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ def indirect_eval(x)
2020
def send_stuff(x)
2121
foo.send("foo_#{x}") # OK - attacker cannot control entire string.
2222
end
23+
24+
def named_code(code)
25+
foo.send("def \n #{code} \n end") # OK - parameter is named code
26+
end
2327
end

0 commit comments

Comments
 (0)