Skip to content

Commit 25814f7

Browse files
committed
Apply suggested changes
1 parent f6887c8 commit 25814f7

File tree

5 files changed

+45
-173
lines changed

5 files changed

+45
-173
lines changed

ruby/ql/lib/codeql/ruby/Frameworks.qll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,3 @@ private import codeql.ruby.frameworks.Slim
3232
private import codeql.ruby.frameworks.Sinatra
3333
private import codeql.ruby.frameworks.Twirp
3434
private import codeql.ruby.frameworks.Sqlite3
35-
private import codeql.ruby.frameworks.Rexml
36-
private import codeql.ruby.frameworks.Nokogiri
37-
private import codeql.ruby.frameworks.LibXml

ruby/ql/lib/codeql/ruby/frameworks/LibXml.qll

Lines changed: 0 additions & 68 deletions
This file was deleted.

ruby/ql/lib/codeql/ruby/frameworks/Nokogiri.qll

Lines changed: 0 additions & 54 deletions
This file was deleted.

ruby/ql/lib/codeql/ruby/frameworks/Rexml.qll

Lines changed: 0 additions & 48 deletions
This file was deleted.

ruby/ql/lib/codeql/ruby/frameworks/XmlParsing.qll

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ private class NokogiriXmlParserCall extends XmlParserCall::Range, DataFlow::Call
4545
}
4646
}
4747

48+
/** Execution of a XPath statement. */
49+
private class NokogiriXPathExecution extends XPathExecution::Range, DataFlow::CallNode {
50+
NokogiriXPathExecution() {
51+
exists(NokogiriXmlParserCall parserCall |
52+
this = parserCall.getAMethodCall(["xpath", "at_xpath", "search", "at"])
53+
)
54+
}
55+
56+
override DataFlow::Node getXPath() { result = this.getArgument(0) }
57+
}
58+
4859
/**
4960
* Holds if `assign` enables the `default_substitute_entities` option in
5061
* libxml-ruby.
@@ -123,6 +134,40 @@ private predicate xmlMiniEntitySubstitutionEnabled() {
123134
enablesLibXmlDefaultEntitySubstitution(_)
124135
}
125136

137+
/** Execution of a XPath statement. */
138+
private class LibXmlXPathExecution extends XPathExecution::Range, DataFlow::CallNode {
139+
LibXmlXPathExecution() {
140+
exists(LibXmlRubyXmlParserCall parserCall |
141+
this = parserCall.getAMethodCall(["find", "find_first"])
142+
)
143+
}
144+
145+
override DataFlow::Node getXPath() { result = this.getArgument(0) }
146+
}
147+
148+
/** A call to `REXML::Document.new`, considered as a XML parsing. */
149+
private class RexmlParserCall extends XmlParserCall::Range, DataFlow::CallNode {
150+
RexmlParserCall() {
151+
this = API::getTopLevelMember("REXML").getMember("Document").getAnInstantiation()
152+
}
153+
154+
override DataFlow::Node getInput() { result = this.getArgument(0) }
155+
156+
/** No option for parsing */
157+
override predicate externalEntitiesEnabled() { none() }
158+
}
159+
160+
/** Execution of a XPath statement. */
161+
private class RexmlXPathExecution extends XPathExecution::Range, DataFlow::CallNode {
162+
RexmlXPathExecution() {
163+
this =
164+
[API::getTopLevelMember("REXML").getMember("XPath"), API::getTopLevelMember("XPath")]
165+
.getAMethodCall(["each", "first", "match"])
166+
}
167+
168+
override DataFlow::Node getXPath() { result = this.getArgument(1) }
169+
}
170+
126171
/**
127172
* A call to `ActiveSupport::XmlMini.parse` considered as an `XmlParserCall`.
128173
*/

0 commit comments

Comments
 (0)