Skip to content

Commit 2e95e25

Browse files
authored
Merge pull request #10406 from RasmusWL/ruby-instanceof
Ruby: Rewrite a few `::Range` uses to `instanceof`
2 parents aacc368 + 511030d commit 2e95e25

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

ruby/ql/lib/codeql/ruby/Concepts.qll

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -611,16 +611,12 @@ module CodeExecution {
611611
* Extend this class to refine existing API models. If you want to model new APIs,
612612
* extend `XmlParserCall::Range` instead.
613613
*/
614-
class XmlParserCall extends DataFlow::Node {
615-
XmlParserCall::Range range;
616-
617-
XmlParserCall() { this = range }
618-
614+
class XmlParserCall extends DataFlow::Node instanceof XmlParserCall::Range {
619615
/** Gets the argument that specifies the XML content to be parsed. */
620-
DataFlow::Node getInput() { result = range.getInput() }
616+
DataFlow::Node getInput() { result = super.getInput() }
621617

622618
/** Holds if this XML parser call is configured to process external entities */
623-
predicate externalEntitiesEnabled() { range.externalEntitiesEnabled() }
619+
predicate externalEntitiesEnabled() { super.externalEntitiesEnabled() }
624620
}
625621

626622
/** Provides a class for modeling new XML parsing APIs. */
@@ -790,13 +786,9 @@ module CookieSecurityConfigurationSetting {
790786
* Extend this class to refine existing API models. If you want to model new APIs,
791787
* extend `Logging::Range` instead.
792788
*/
793-
class Logging extends DataFlow::Node {
794-
Logging::Range range;
795-
796-
Logging() { this = range }
797-
789+
class Logging extends DataFlow::Node instanceof Logging::Range {
798790
/** Gets an input that is logged. */
799-
DataFlow::Node getAnInput() { result = range.getAnInput() }
791+
DataFlow::Node getAnInput() { result = super.getAnInput() }
800792
}
801793

802794
/** Provides a class for modeling new logging mechanisms. */

ruby/ql/lib/codeql/ruby/dataflow/RemoteFlowSources.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ private import codeql.ruby.Frameworks
1313
* Extend this class to refine existing API models. If you want to model new APIs,
1414
* extend `RemoteFlowSource::Range` instead.
1515
*/
16-
class RemoteFlowSource extends DataFlow::Node {
17-
RemoteFlowSource::Range self;
18-
19-
RemoteFlowSource() { this = self }
20-
16+
class RemoteFlowSource extends DataFlow::Node instanceof RemoteFlowSource::Range {
2117
/** Gets a string that describes the type of this remote flow source. */
22-
string getSourceType() { result = self.getSourceType() }
18+
string getSourceType() { result = super.getSourceType() }
2319
}
2420

2521
/** Provides a class for modeling new sources of remote user input. */

0 commit comments

Comments
 (0)